diff options
author | terminaldweller <thabogre@gmail.com> | 2022-03-21 21:57:51 +0000 |
---|---|---|
committer | terminaldweller <thabogre@gmail.com> | 2022-03-21 21:57:51 +0000 |
commit | b9047281771af59bc9dc5c6380321c3cfc81f1c0 (patch) | |
tree | e21c3e54541b12db4a100e765fd7bcaa11856250 /src/main/java | |
parent | wip (diff) | |
download | mdrtl-b9047281771af59bc9dc5c6380321c3cfc81f1c0.tar.gz mdrtl-b9047281771af59bc9dc5c6380321c3cfc81f1c0.zip |
wip
Diffstat (limited to 'src/main/java')
-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); + } +} |