aboutsummaryrefslogblamecommitdiffstats
path: root/src/main/java/com/terminaldweller/doc/Md.java
blob: b7399d42269185b63a2a7ad053a6f3efbf7f438f (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15














                                                               
                                             




                                                           
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);
  }
}