Search in sources :

Example 26 with HtmlRenderer

use of com.vladsch.flexmark.html.HtmlRenderer in project flexmark-java by vsch.

the class ParserTest method ioReaderTest.

@Test
public void ioReaderTest() throws IOException {
    Parser parser = Parser.builder().build();
    InputStream input1 = SpecReader.getSpecInputStream();
    Node document1;
    InputStreamReader reader = new InputStreamReader(input1, "utf-8");
    document1 = parser.parseReader(reader);
    String spec = SpecReader.readSpec();
    Node document2 = parser.parse(spec);
    HtmlRenderer renderer = HtmlRenderer.builder().escapeHtml(true).build();
    assertEquals(renderer.render(document2), renderer.render(document1));
}
Also used : InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) HtmlRenderer(com.vladsch.flexmark.html.HtmlRenderer) Parser(com.vladsch.flexmark.parser.Parser) Test(org.junit.Test)

Example 27 with HtmlRenderer

use of com.vladsch.flexmark.html.HtmlRenderer in project flexmark-java by vsch.

the class UsageExampleTest method parseAndRender.

@Test
public void parseAndRender() {
    Parser parser = Parser.builder().build();
    Node document = parser.parse("This is *Sparta*");
    HtmlRenderer renderer = HtmlRenderer.builder().escapeHtml(true).build();
    assertEquals("<p>This is <em>Sparta</em></p>\n", renderer.render(document));
}
Also used : HtmlRenderer(com.vladsch.flexmark.html.HtmlRenderer) Parser(com.vladsch.flexmark.parser.Parser) Test(org.junit.Test)

Example 28 with HtmlRenderer

use of com.vladsch.flexmark.html.HtmlRenderer in project nzbhydra2 by theotherp.

the class Markdown method renderMarkdownAsHtml.

public static String renderMarkdownAsHtml(String markdown) {
    MutableDataSet options = new MutableDataSet();
    Parser parser = Parser.builder(options).build();
    HtmlRenderer renderer = HtmlRenderer.builder(options).build();
    Node document = parser.parse(markdown);
    return renderer.render(document);
}
Also used : Node(com.vladsch.flexmark.ast.Node) HtmlRenderer(com.vladsch.flexmark.html.HtmlRenderer) MutableDataSet(com.vladsch.flexmark.util.options.MutableDataSet) Parser(com.vladsch.flexmark.parser.Parser)

Aggregations

HtmlRenderer (com.vladsch.flexmark.html.HtmlRenderer)28 Parser (com.vladsch.flexmark.parser.Parser)27 Node (com.vladsch.flexmark.ast.Node)21 MutableDataSet (com.vladsch.flexmark.util.options.MutableDataSet)15 MutableDataHolder (com.vladsch.flexmark.util.options.MutableDataHolder)7 Test (org.junit.Test)6 Extension (com.vladsch.flexmark.Extension)2 Document (com.vladsch.flexmark.ast.Document)2 AutolinkExtension (com.vladsch.flexmark.ext.autolink.AutolinkExtension)1 JekyllTag (com.vladsch.flexmark.ext.jekyll.tag.JekyllTag)1 CustomNodeFormatter (com.vladsch.flexmark.formatter.CustomNodeFormatter)1 AttributeProvider (com.vladsch.flexmark.html.AttributeProvider)1 AttributeProviderFactory (com.vladsch.flexmark.html.AttributeProviderFactory)1 IndependentAttributeProviderFactory (com.vladsch.flexmark.html.IndependentAttributeProviderFactory)1 AttributablePart (com.vladsch.flexmark.html.renderer.AttributablePart)1 LinkResolverContext (com.vladsch.flexmark.html.renderer.LinkResolverContext)1 Attributes (com.vladsch.flexmark.util.html.Attributes)1 DataHolder (com.vladsch.flexmark.util.options.DataHolder)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1