Search in sources :

Example 6 with HtmlRenderer

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

the class PegdownOptions2 method main.

public static void main(String[] args) {
    final MutableDataHolder OPTIONS = PegdownOptionsAdapter.flexmarkOptions(Extensions.ALL - (headerLinks ? 0 : Extensions.ANCHORLINKS) - (hardwrap ? 0 : Extensions.HARDWRAPS) + (allowHtml ? 0 : Extensions.SUPPRESS_ALL_HTML)).toMutable();
    final Parser PARSER = Parser.builder(OPTIONS).build();
    final HtmlRenderer RENDERER = HtmlRenderer.builder(OPTIONS).build();
    String input = "[[test page]]" + "";
    Node node = PARSER.parse(input);
    System.out.println(RENDERER.render(node));
}
Also used : MutableDataHolder(com.vladsch.flexmark.util.options.MutableDataHolder) Node(com.vladsch.flexmark.ast.Node) HtmlRenderer(com.vladsch.flexmark.html.HtmlRenderer) Parser(com.vladsch.flexmark.parser.Parser)

Example 7 with HtmlRenderer

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

the class ProfileEmulationFamilySamples method markdown.

void markdown() {
    MutableDataSet options = new MutableDataSet();
    options.setFrom(ParserEmulationProfile.MARKDOWN);
    Parser parser = Parser.builder(options).build();
    HtmlRenderer renderer = HtmlRenderer.builder(options).build();
    Node document = parser.parse("This is *Sparta*");
    // "<p>This is <em>Sparta</em></p>\n"
    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)

Example 8 with HtmlRenderer

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

the class SyntheticLinkSample method main.

public static void main(String[] args) {
    MutableDataSet options = new MutableDataSet();
    // set optional extensions
    options.set(Parser.EXTENSIONS, Arrays.asList(SyntheticLinkExtension.create()));
    // uncomment to convert soft-breaks to hard breaks
    // options.set(HtmlRenderer.SOFT_BREAK, "<br />\n");
    Parser parser = Parser.builder(options).build();
    HtmlRenderer renderer = HtmlRenderer.builder(options).build();
    // You can re-use parser and renderer instances
    Node document = parser.parse("Some markdown content");
    String html = renderer.render(document);
    System.out.println(html);
}
Also used : HtmlRenderer(com.vladsch.flexmark.html.HtmlRenderer) MutableDataSet(com.vladsch.flexmark.util.options.MutableDataSet) Parser(com.vladsch.flexmark.parser.Parser)

Example 9 with HtmlRenderer

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

the class TitleExtract method main.

public static void main(String[] args) {
    Parser parser = Parser.builder(OPTIONS).build();
    HtmlRenderer renderer = HtmlRenderer.builder(OPTIONS).build();
    // You can re-use parser and renderer instances
    Node document = parser.parse("\n" + "# Plugin commit-message-length-validator\n" + "\n" + "Vendor\n" + ":  Gerrit Code Review\n" + "\n" + "Version\n" + ":  v2.15-rc2\n" + "\n" + "commitmessage.maxSubjectLength\n" + ":       Maximum length of the commit message's subject line.  Defaults\n" + "        to 50 if not specified or less than 0.\n" + "\n" + "## About\n" + "\n" + "This plugin checks the length of a commit's commit message subject and body, and reports warnings and errors to the git client if the lentghts are exceeded.\n" + "\n" + "## Documentation\n" + "\n" + "* [Commit Message Length Configuration](config.md)\n" + "* More Items\n" + "\n" + "");
    String title = findTitle(document);
    System.out.println("Title: " + title + "\n");
    // "<p>This is <em>Sparta</em></p>\n"
    String html = renderer.render(document);
    System.out.println(html);
}
Also used : Node(com.vladsch.flexmark.ast.Node) HtmlRenderer(com.vladsch.flexmark.html.HtmlRenderer) Parser(com.vladsch.flexmark.parser.Parser)

Example 10 with HtmlRenderer

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

the class ComboParserTest method testWrap.

// @Test
public void testWrap() throws Exception {
    if (!example.isFullSpecExample())
        return;
    final HtmlRenderer RENDERER = HtmlRenderer.builder(OPTIONS).build();
    final Parser PARSER = Parser.builder(OPTIONS).build();
    String source = readResource("/wrap.md");
    String html = readResource("/wrap.html");
    assertRendering(source, html);
}
Also used : HtmlRenderer(com.vladsch.flexmark.html.HtmlRenderer) 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