diff options
Diffstat (limited to '')
-rw-r--r-- | src/main/java/com/terminaldweller/doc/Md.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/main/java/com/terminaldweller/doc/Md.java b/src/main/java/com/terminaldweller/doc/Md.java new file mode 100644 index 0000000..be0c447 --- /dev/null +++ b/src/main/java/com/terminaldweller/doc/Md.java @@ -0,0 +1,21 @@ +package com.terminaldweller.doc; + +import org.commonmark.node.Node; +import org.commonmark.parser.Parser; +import org.commonmark.renderer.html.HtmlRenderer; + +/** The markdown class which provides the markdown parser. */ +public class Md { + /** + * Parses a markdown string and returns the result in html. + * + * @param markdown the string containing the markdown string. + * @return the rendered markdown document in html. + */ + public String mdparseService(String markdown) { + Parser parser = parser.builder().build(); + Node document = parser.parse(markdown); + HtmlRenderer renderer = HtmlRenderer.builder().build(); + return renderer.render(document); + } +} |