Search in sources :

Example 1 with HtmlNodeRendererContext

use of org.commonmark.renderer.html.HtmlNodeRendererContext in project symja_android_library by axkr.

the class AJAXDocServlet method generateHTMLString.

public static String generateHTMLString(final String markdownStr) {
    List<Extension> EXTENSIONS = // 
    Arrays.asList(TeXExtension.create(), TablesExtension.create());
    Parser parser = // 
    Parser.builder().extensions(EXTENSIONS).build();
    Node document = parser.parse(markdownStr);
    HtmlRenderer renderer = // 
    HtmlRenderer.builder().extensions(EXTENSIONS).nodeRendererFactory(new HtmlNodeRendererFactory() {

        @Override
        public NodeRenderer create(HtmlNodeRendererContext context) {
            return new DocNodeRenderer(context);
        }
    }).build();
    return renderer.render(document);
}
Also used : TablesExtension(org.commonmark.ext.gfm.tables.TablesExtension) Extension(org.commonmark.Extension) CustomNode(org.commonmark.node.CustomNode) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Node(org.commonmark.node.Node) HtmlRenderer(org.commonmark.renderer.html.HtmlRenderer) HtmlNodeRendererContext(org.commonmark.renderer.html.HtmlNodeRendererContext) HtmlNodeRendererFactory(org.commonmark.renderer.html.HtmlNodeRendererFactory) Parser(org.commonmark.parser.Parser) ExprParser(org.matheclipse.core.parser.ExprParser)

Aggregations

ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Extension (org.commonmark.Extension)1 TablesExtension (org.commonmark.ext.gfm.tables.TablesExtension)1 CustomNode (org.commonmark.node.CustomNode)1 Node (org.commonmark.node.Node)1 Parser (org.commonmark.parser.Parser)1 HtmlNodeRendererContext (org.commonmark.renderer.html.HtmlNodeRendererContext)1 HtmlNodeRendererFactory (org.commonmark.renderer.html.HtmlNodeRendererFactory)1 HtmlRenderer (org.commonmark.renderer.html.HtmlRenderer)1 ExprParser (org.matheclipse.core.parser.ExprParser)1