Search in sources :

Example 1 with Formatter

use of com.vladsch.flexmark.formatter.internal.Formatter in project flexmark-java by vsch.

the class FormatConverterCommonMark method main.

public static void main(String[] args) {
    final String markdown = "Text\n" + "\n" + "1. numbered list one\n" + " - unnumbered list\n" + " unnumbered list cont. same line\n" + " - unnumbered list  \n" + " unnumbered list cont. next line\n" + "\n" + " numbered list one cont. after unnumbered list" + "";
    System.out.println("\nMarkdown: --------------------------------------------------------------------------------\n");
    System.out.println(markdown);
    System.out.println("\n--------------------------------------------------------------------------------\n");
    final Parser PARSER = Parser.builder(OPTIONS).build();
    final Formatter RENDERER = Formatter.builder(OPTIONS).build();
    final Formatter RENDERER_FIXED4 = Formatter.builder(FORMATTER_OPTIONS).build();
    Node document = PARSER.parse(markdown);
    System.out.println(new AstCollectingVisitor().collectAndGetAstText(document));
    System.out.println("\n--------------------------------------------------------------------------------\n");
    String formatted = RENDERER.render(document);
    // or to control the package
    System.out.println("\nFormatted as is: --------------------------------------------------------------------------------\n");
    System.out.println(formatted);
    System.out.println("\n--------------------------------------------------------------------------------\n");
    String formattedFixed4 = RENDERER_FIXED4.render(document);
    // or to control the package
    System.out.println("\nFormatted fixed 4: --------------------------------------------------------------------------------\n");
    System.out.println(formattedFixed4);
    System.out.println("\n--------------------------------------------------------------------------------\n");
}
Also used : Formatter(com.vladsch.flexmark.formatter.internal.Formatter) AstCollectingVisitor(com.vladsch.flexmark.test.AstCollectingVisitor) Node(com.vladsch.flexmark.ast.Node) Parser(com.vladsch.flexmark.parser.Parser)

Aggregations

Node (com.vladsch.flexmark.ast.Node)1 Formatter (com.vladsch.flexmark.formatter.internal.Formatter)1 Parser (com.vladsch.flexmark.parser.Parser)1 AstCollectingVisitor (com.vladsch.flexmark.test.AstCollectingVisitor)1