Search in sources :

Example 36 with Node

use of org.commonmark.node.Node in project hippo by NHS-digital-website.

the class ThematicBreakAttributeProviderTest method setsThematicBreakInlineCssClassOnCodeElement.

@Test
public void setsThematicBreakInlineCssClassOnCodeElement() {
    // given
    final Node thematicBreakNode = new ThematicBreak();
    // when
    thematicBreakAttributeProvider.setAttributes(thematicBreakNode, "tagName is ignored", attributes);
    // then
    then(attributes).should().put("class", "nhsd-a-horizontal-rule");
    then(attributes).shouldHaveNoMoreInteractions();
}
Also used : ThematicBreak(org.commonmark.node.ThematicBreak) Node(org.commonmark.node.Node) Test(org.junit.Test)

Example 37 with Node

use of org.commonmark.node.Node in project TOSCAna by StuPro-TOSCAna.

the class ReadmeBuilder method toString.

@Override
public String toString() {
    Parser markdownParser = Parser.builder().build();
    Node markdownDocument = markdownParser.parse(this.markdownText);
    HtmlRenderer renderer = HtmlRenderer.builder().build();
    return TEMPLATE.replace(README_TEMPLATE_TITLE_KEY, this.pageTitle).replace(README_TEMPLATE_BODY_KEY, renderer.render(markdownDocument));
}
Also used : Node(org.commonmark.node.Node) HtmlRenderer(org.commonmark.renderer.html.HtmlRenderer) Parser(org.commonmark.parser.Parser)

Example 38 with Node

use of org.commonmark.node.Node in project FastHub by k0shk0sh.

the class MarkDownProvider method stripMdText.

@NonNull
public static String stripMdText(String markdown) {
    if (!InputHelper.isEmpty(markdown)) {
        Parser parser = Parser.builder().build();
        Node node = parser.parse(markdown);
        return stripHtml(HtmlRenderer.builder().build().render(node));
    }
    return "";
}
Also used : Node(org.commonmark.node.Node) Parser(org.commonmark.parser.Parser) NonNull(android.support.annotation.NonNull)

Example 39 with Node

use of org.commonmark.node.Node in project FastHub by k0shk0sh.

the class EmojiNodeRenderer method renderChildren.

private void renderChildren(Node parent) {
    Node node = parent.getFirstChild();
    while (node != null) {
        Node next = node.getNext();
        context.render(node);
        node = next;
    }
}
Also used : Node(org.commonmark.node.Node)

Example 40 with Node

use of org.commonmark.node.Node in project symja_android_library by axkr.

the class DocumentationPod method generateHTMLString.

private static String generateHTMLString(final String markdownStr) {
    Set<Extension> EXTENSIONS = Collections.singleton(TablesExtension.create());
    Parser parser = Parser.builder().extensions(EXTENSIONS).build();
    Node document = parser.parse(markdownStr);
    HtmlRenderer renderer = HtmlRenderer.builder().extensions(EXTENSIONS).build();
    return renderer.render(document);
}
Also used : Extension(org.commonmark.Extension) TablesExtension(org.commonmark.ext.gfm.tables.TablesExtension) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Node(org.commonmark.node.Node) HtmlRenderer(org.commonmark.renderer.html.HtmlRenderer) Parser(org.commonmark.parser.Parser)

Aggregations

Node (org.commonmark.node.Node)42 Parser (org.commonmark.parser.Parser)18 HtmlRenderer (org.commonmark.renderer.html.HtmlRenderer)12 Test (org.junit.Test)9 Extension (org.commonmark.Extension)7 TablesExtension (org.commonmark.ext.gfm.tables.TablesExtension)7 IOException (java.io.IOException)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 DateFormat (java.text.DateFormat)2 HashMap (java.util.HashMap)2 TableBlock (org.commonmark.ext.gfm.tables.TableBlock)2 Code (org.commonmark.node.Code)2 CustomNode (org.commonmark.node.CustomNode)2 AppWidgetManager (android.appwidget.AppWidgetManager)1 ActivityNotFoundException (android.content.ActivityNotFoundException)1 ComponentName (android.content.ComponentName)1 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1