Markdown Generator

Java library to generate markdown

License

License

Categories

Categories

Net
GroupId

GroupId

net.steppschuh.markdowngenerator
ArtifactId

ArtifactId

markdowngenerator
Last Version

Last Version

1.3.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

Markdown Generator
Java library to generate markdown
Project URL

Project URL

https://github.com/Steppschuh/Java-Markdown-Generator
Source Code Management

Source Code Management

https://github.com/Steppschuh/Java-Markdown-Generator.git

Download markdowngenerator

How to add to project

<!-- https://jarcasting.com/artifacts/net.steppschuh.markdowngenerator/markdowngenerator/ -->
<dependency>
    <groupId>net.steppschuh.markdowngenerator</groupId>
    <artifactId>markdowngenerator</artifactId>
    <version>1.3.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/net.steppschuh.markdowngenerator/markdowngenerator/
implementation 'net.steppschuh.markdowngenerator:markdowngenerator:1.3.1.1'
// https://jarcasting.com/artifacts/net.steppschuh.markdowngenerator/markdowngenerator/
implementation ("net.steppschuh.markdowngenerator:markdowngenerator:1.3.1.1")
'net.steppschuh.markdowngenerator:markdowngenerator:jar:1.3.1.1'
<dependency org="net.steppschuh.markdowngenerator" name="markdowngenerator" rev="1.3.1.1">
  <artifact name="markdowngenerator" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.steppschuh.markdowngenerator', module='markdowngenerator', version='1.3.1.1')
)
libraryDependencies += "net.steppschuh.markdowngenerator" % "markdowngenerator" % "1.3.1.1"
[net.steppschuh.markdowngenerator/markdowngenerator "1.3.1.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

Java Markdown Generator

Travis JitPack Bintray Maven Central Codecov

Simple to use Java library to generate beautiful markdown.

Screenshot

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");
    ```

Versions

Version
1.3.1.1
1.3.0.0
1.2