Search in sources :

Example 11 with Node

use of com.vladsch.flexmark.ast.Node in project flexmark-java by vsch.

the class PdfConverter method main.

public static void main(String[] args) {
    final String pegdown = "#Heading\n" + "-----\n" + "paragraph text \n" + "lazy continuation\n" + "\n" + "* list item\n" + "    > block quote\n" + "    lazy continuation\n" + "\n" + "~~~info\n" + "   with uneven indent\n" + "      with uneven indent\n" + "indented code\n" + "~~~ \n" + "\n" + "       with uneven indent\n" + "          with uneven indent\n" + "    indented code\n" + "1. numbered item 1   \n" + "1. numbered item 2   \n" + "1. numbered item 3   \n" + "    - bullet item 1   \n" + "    - bullet item 2   \n" + "    - bullet item 3   \n" + "        1. numbered sub-item 1   \n" + "        1. numbered sub-item 2   \n" + "        1. numbered sub-item 3   \n" + "    \n" + "    ~~~info\n" + "       with uneven indent\n" + "          with uneven indent\n" + "    indented code\n" + "    ~~~ \n" + "    \n" + "           with uneven indent\n" + "              with uneven indent\n" + "        indented code\n" + "";
    System.out.println("pegdown\n");
    System.out.println(pegdown);
    final Parser PARSER = Parser.builder(OPTIONS).build();
    final HtmlRenderer RENDERER = HtmlRenderer.builder(OPTIONS).build();
    Node document = PARSER.parse(pegdown);
    String html = RENDERER.render(document);
    PdfConverterExtension.exportToPdf("/Users/vlad/src/pdf/flexmark-java.pdf", html, "", OPTIONS);
}
Also used : Node(com.vladsch.flexmark.ast.Node) HtmlRenderer(com.vladsch.flexmark.html.HtmlRenderer) Parser(com.vladsch.flexmark.parser.Parser)

Example 12 with Node

use of com.vladsch.flexmark.ast.Node 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 13 with Node

use of com.vladsch.flexmark.ast.Node in project flexmark-java by vsch.

the class PegdownToCommonMark method main.

// use the PARSER to parse and RENDERER to parse pegdown indentation rules and render CommonMark
public static void main(String[] args) {
    final String pegdown = "#Heading\n" + "-----\n" + "paragraph text \n" + "lazy continuation\n" + "\n" + "* list item\n" + "    > block quote\n" + "    lazy continuation\n" + "\n" + "~~~info\n" + "        with uneven indent\n" + "           with uneven indent\n" + "     indented code\n" + "~~~ \n" + "\n" + "        with uneven indent\n" + "           with uneven indent\n" + "     indented code\n" + "1. numbered item 1   \n" + "1. numbered item 2   \n" + "1. numbered item 3   \n" + "    - bullet item 1   \n" + "    - bullet item 2   \n" + "    - bullet item 3   \n" + "        1. numbered sub-item 1   \n" + "        1. numbered sub-item 2   \n" + "        1. numbered sub-item 3   \n" + "    \n" + "    ~~~info\n" + "            with uneven indent\n" + "               with uneven indent\n" + "         indented code\n" + "    ~~~ \n" + "    \n" + "            with uneven indent\n" + "               with uneven indent\n" + "         indented code\n" + "";
    System.out.println("pegdown\n");
    System.out.println(pegdown);
    Node document = PARSER.parse(pegdown);
    String commonmark = RENDERER.render(document);
    System.out.println("\n\nCommonMark\n");
    System.out.println(commonmark);
}
Also used : Node(com.vladsch.flexmark.ast.Node)

Example 14 with Node

use of com.vladsch.flexmark.ast.Node 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 15 with Node

use of com.vladsch.flexmark.ast.Node 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)

Aggregations

Node (com.vladsch.flexmark.ast.Node)87 Parser (com.vladsch.flexmark.parser.Parser)29 HtmlRenderer (com.vladsch.flexmark.html.HtmlRenderer)21 Test (org.junit.Test)19 MutableDataSet (com.vladsch.flexmark.util.options.MutableDataSet)14 DataHolder (com.vladsch.flexmark.util.options.DataHolder)11 List (java.util.List)8 BasedSequence (com.vladsch.flexmark.util.sequence.BasedSequence)6 MutableDataHolder (com.vladsch.flexmark.util.options.MutableDataHolder)5 Text (com.vladsch.flexmark.ast.Text)3 TextCollectingVisitor (com.vladsch.flexmark.ast.util.TextCollectingVisitor)3 Extension (com.vladsch.flexmark.Extension)2 Block (com.vladsch.flexmark.ast.Block)2 CustomNode (com.vladsch.flexmark.ast.CustomNode)2 Document (com.vladsch.flexmark.ast.Document)2 Heading (com.vladsch.flexmark.ast.Heading)2 DocxRenderer (com.vladsch.flexmark.docx.converter.internal.DocxRenderer)2 MacroClose (com.vladsch.flexmark.ext.xwiki.macros.MacroClose)2 AstCollectingVisitor (com.vladsch.flexmark.test.AstCollectingVisitor)2 Attributes (com.vladsch.flexmark.util.html.Attributes)2