Skip to content

Flexmark Spec Example Extension

Vladimir Schneider edited this page May 1, 2023 · 2 revisions

flexmark-java extension for flexmark-java spec test example processing

Overview

Converts spec example syntax into flexmark-java AST node.

This extension is used by Markdown Navigator plugin for JetBrains IDEs to facilitate work with flexmark-java test spec files.

```````````````````````````````` example SpecExample: 1
markdown content
.
html content
.
AST content
````````````````````````````````

Example test spec:

```````````````````````````````` example GFM Emphasis: 7
**a*b*c**

.
<p><strong>a<em>b</em>c</strong></p>
.
Document[0, 11]
  Paragraph[0, 10] isTrailingBlankLine
    StrongEmphasis[0, 9] textOpen:[0, 2, "**"] text:[2, 7, "a*b*c"] textClose:[7, 9, "**"]
      Text[2, 3] chars:[2, 3, "a"]
      Emphasis[3, 6] textOpen:[3, 4, "*"] text:[4, 5, "b"] textClose:[5, 6, "*"]
        Text[4, 5] chars:[4, 5, "b"]
      Text[6, 7] chars:[6, 7, "c"]
````````````````````````````````

Syntax

The syntax is very specific and the elements start with:

```````````````````````````````` example GFM Emphasis: 7

or with options:

```````````````````````````````` example(GFM Emphasis: 7) options(option1, option2, etc)

Contains 1 to 3 sections: markdown, html and AST. Sections are separated by a line containing a single .:

.

and ends with:

````````````````````````````````

Parsing Details

Use class SpecExampleExtension from artifact flexmark-ext-spec-example.

The following options are available:

Defined in SpecExampleExtension class:

Static Field Default Value Description
SPEC_EXAMPLE_RENDER_HTML true whether to render the HTML section as raw HTML in addition to fenced code HTML
SPEC_EXAMPLE_RENDERED_HTML_PREFIX <div style="border:solid #cccccc 1px;padding:0 20px 10px 20px;"> prefix for the rendered HTML section, default grey 1 pixel box around html
SPEC_EXAMPLE_RENDERED_HTML_SUFFIX </div> suffix for the rendered HTML section
SPEC_EXAMPLE_RENDER_AS RenderAs.FENCED_CODE how to render the example: fenced code, simple or definition list
SPEC_EXAMPLE_BREAK spec example break back ticks changes the prefix recognized. Used for testing. Used for testing to change default since the tests are specified in spec examples.
SPEC_TYPE_BREAK . section break in the spec example body. Used for testing to change default since the tests are specified in spec examples.
SPEC_OPTION_NODES true whether to include SpecExampleOptionsList and SpecExampleOption nodes in the AST