Java-Markdown-GeneratorJava library to generate markdown
Java Markdown Generator
Simple to use Java library to generate beautiful markdown.
Usage
Integration
Gradle
You can get snapshot and release builds from JitPack:
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
compile 'com.github.Steppschuh:Java-Markdown-Generator:master-SNAPSHOT'
}
Alternatively, release builds are also available on Bintray:
repositories {
maven { url 'http://dl.bintray.com/steppschuh/Markdown-Generator' }
}
dependencies {
compile 'net.steppschuh.markdowngenerator:markdowngenerator:1.3.2'
}
Maven
<dependency>
<groupId>net.steppschuh.markdowngenerator</groupId>
<artifactId>markdowngenerator</artifactId>
<version>1.3.2</version>
</dependency>
JAR
You can download the latest .jar files from GitHub or Bintray.
Examples
Most Markdown elements have static convenience methods in the Markdown
class. You can also use their repesctive constructors, as shown below.
Emphasis
@Test
public void example() throws Exception {
StringBuilder sb = new StringBuilder()
.append(new Text("I am normal")).append("\n")
.append(new BoldText("I am bold")).append("\n")
.append(new ItalicText("I am italic")).append("\n")
.append(new StrikeThroughText("I am strike-through"));
System.out.println(sb);
}
Output:
I am normal
**I am bold**
_I am italic_
~~I am strike-through~~
Headings
@Test
public void example() throws Exception {
StringBuilder sb = new StringBuilder()
.append(new Heading("Heading with level 1", 1)).append("\n")
.append(new Heading("Heading with level 2", 2)).append("\n")
.append(new Heading("Heading with level 3", 3)).append("\n")
.append(new Heading("Heading with level 4", 4)).append("\n")
.append(new Heading("Heading with level 5", 5)).append("\n")
.append(new Heading("Heading with level 6", 6));
System.out.println(sb);
}
Output:
Heading with level 1
====================
Heading with level 2
--------------------
### Heading with level 3
#### Heading with level 4
##### Heading with level 5
###### Heading with level 6
Rules
@Test
public void example() throws Exception {
System.out.println(new HorizontalRule());
System.out.println(new HorizontalRule(20, HorizontalRule.ASTERISK));
}
Output:
---
********************
Images
@Test
public void example() throws Exception {
String text = "I am an image";
String url = "https://dummyimage.com/300";
System.out.println(new Image(text, url));
}
Output:
![I am an image](https://dummyimage.com/300)
Lists
@Test
public void example() throws Exception {
List<Object> items = Arrays.asList(
"Items can be anything",
new Date(0),
1337
);
System.out.println(new UnorderedList<>(items));
}
Output:
- Items can be anything
- Thu Jan 01 01:00:00 CET 1970
- 1337
Tasks
@Test
public void example() throws Exception {
List<TaskListItem> items = Arrays.asList(
new TaskListItem("Task 1", true),
new TaskListItem("Task 2", false),
new TaskListItem("Task 3")
);
System.out.println(new TaskList(items));
}
Output:
- [x] Task 1
- [ ] Task 2
- [ ] Task 3
Tables
@Test
public void example() throws Exception {
Table.Builder tableBuilder = new Table.Builder()
.withAlignments(Table.ALIGN_RIGHT, Table.ALIGN_LEFT)
.withRowLimit(7)
.addRow("Index", "Boolean");
for (int i = 1; i <= 20; i++) {
tableBuilder.addRow(i, Math.random() > 0.5);
}
System.out.println(tableBuilder.build());
}
Output:
| Index | Boolean |
| -----:| ------- |
| 1 | false |
| 2 | true |
| 3 | false |
| ~~~~~ | ~~~~~~~ |
| 18 | false |
| 19 | true |
| 20 | false |
Code
@Test
public void example() throws Exception {
String code = "// notice this new line\n" +
"System.out.println(\"Hello\");";
System.out.println(new CodeBlock(code, "Java"));
}
Output:
```Java
// notice this new line
System.out.println("Hello");
```
评论
Markdown
Markdown是一个Web上使用的文本到HTML的转换工具,可以通过简单、易读易写的文本格式生成结构化的HTML文档。目前Stackoverflow网站使用这种格式来提问。一个文本实例:###Hea
Markdown
0
Generate Numly Copyright
RegistersdocumentsandblogsforNumlycopyright.NumlyNumbersareuniqueidentifiersofelectronicmediaandreco
Generate Numly Copyright
0
laravel-feedEasily generate RSS feeds
GenerateRSSfeedsinaLaravelappThispackageprovidesaneasywaytogenerateafeedforyourLaravelapplication.Su
laravel-feedEasily generate RSS feeds
0
蝉知markdown编辑器markdown
本插件是1.x版本基于osc开源的thinker-md制作的根据蝉知zentaophp框架插件扩展机制编写的只适合于蝉知4.4版本的markdown编辑器。基于thinker-md集成的开源marke
蝉知markdown编辑器markdown
0
laravel-feedEasily generate RSS feeds
Generate RSS feeds in a Laravel appThis package pr
laravel-feedEasily generate RSS feeds
0