Class YamlFrontMatterExtension

java.lang.Object
org.commonmark.ext.front.matter.YamlFrontMatterExtension
All Implemented Interfaces:
org.commonmark.Extension, org.commonmark.parser.Parser.ParserExtension, org.commonmark.renderer.markdown.MarkdownRenderer.MarkdownRendererExtension

public class YamlFrontMatterExtension extends Object implements org.commonmark.parser.Parser.ParserExtension, org.commonmark.renderer.markdown.MarkdownRenderer.MarkdownRendererExtension
Extension for YAML-like metadata.

Create it with create() and then configure it on the builders (Parser.Builder.extensions(Iterable), HtmlRenderer.Builder.extensions(Iterable)).

By default, the extension parses the subset of YAML with a built-int YamlSubsetParser. The parsed metadata is turned into YamlFrontMatterNode. You can access the metadata using YamlFrontMatterVisitor.readData(Node).

Alternatively, you can create the extension with RawContentParser.Factory. It turns the YAML front matter into YamlFrontMatterRawContent node, which stores the entire front matter as a string. You can access the content with YamlFrontMatterVisitor.readRawContent(Node) to process it with other tools.

Implement FrontMatterParser interface and the corresponding factory to parse the front matter with a custom parser.

  • Method Details

    • extend

      public void extend(org.commonmark.parser.Parser.Builder parserBuilder)
      Specified by:
      extend in interface org.commonmark.parser.Parser.ParserExtension
    • create

      public static org.commonmark.Extension create()
    • create

      public static org.commonmark.Extension create(FrontMatterParser.Factory parser)
    • extend

      public void extend(org.commonmark.renderer.markdown.MarkdownRenderer.Builder rendererBuilder)
      Specified by:
      extend in interface org.commonmark.renderer.markdown.MarkdownRenderer.MarkdownRendererExtension