From b9047281771af59bc9dc5c6380321c3cfc81f1c0 Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Tue, 22 Mar 2022 02:27:51 +0430 Subject: wip --- src/main/java/com/terminaldweller/doc/Md.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/main/java/com/terminaldweller/doc/Md.java (limited to 'src/main/java/com/terminaldweller') 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); + } +} -- cgit v1.2.3