Class MarkdownRenderer

  • All Implemented Interfaces:
    Renderer

    public class MarkdownRenderer
    extends java.lang.Object
    implements Renderer
    Renders nodes to Markdown (CommonMark syntax); use builder() to create a renderer.

    Note that it doesn't currently preserve the exact syntax of the original input Markdown (if any):

    • Headings are output as ATX headings if possible (multi-line headings need Setext headings)
    • Links are always rendered as inline links (no support for reference links yet)
    • Escaping might be over-eager, e.g. a plain * might be escaped even though it doesn't need to be in that particular context
    • Leading whitespace in paragraphs is not preserved
    However, it should produce Markdown that is semantically equivalent to the input, i.e. if the Markdown was parsed again and compared against the original AST, it should be the same (minus bugs).
    • Method Detail

      • render

        public void render​(Node node,
                           java.lang.Appendable output)
        Description copied from interface: Renderer
        Render the tree of nodes to output.
        Specified by:
        render in interface Renderer
        Parameters:
        node - the root node
        output - output for rendering
      • render

        public java.lang.String render​(Node node)
        Description copied from interface: Renderer
        Render the tree of nodes to string.
        Specified by:
        render in interface Renderer
        Parameters:
        node - the root node
        Returns:
        the rendered string