Support for Pandoc YAML front matter #137

Closed
opened 2026-01-29 14:28:24 +00:00 by claunia · 3 comments
Owner

Originally created by @kenmuse on GitHub (Aug 29, 2017).

YAML front matter support was added to resolve #37. Wanted to see about adding support for Pandoc-flavored YAML front matter. That flavor allows either leading dots (...) or leading dashes (---). Similarly, it can end with either dots or dashes; it is not required that the end match the start of the fence. The most common pattern with Pandoc seems to be leading with dashes and ending with dots. I'm trying to help improve the support for Pandoc markdown previews in Markdown Monster.

I can provide a PR on this -- either adding it to the main front matter parser or as a separate extension that can be enabled.

Originally created by @kenmuse on GitHub (Aug 29, 2017). YAML front matter support was added to resolve #37. Wanted to see about adding support for Pandoc-flavored YAML front matter. That flavor allows either leading dots (...) or leading dashes (---). Similarly, it can end with either dots or dashes; it is not required that the end match the start of the fence. The most common pattern with Pandoc seems to be leading with dashes and ending with dots. I'm trying to help improve the support for Pandoc markdown previews in Markdown Monster. I can provide a PR on this -- either adding it to the main front matter parser or as a separate extension that can be enabled.
claunia added the enhancement label 2026-01-29 14:28:24 +00:00
Author
Owner

@xoofx commented on GitHub (Aug 29, 2017):

From YAML specs:

  • Three dashes --- is used to separate directives from document content. This also serves to signal the start of a document if no directives are present
  • Three dots ... indicate the end of a document without starting a new one, for use in communication channels

So while ... could be used for ending a YAML frontmatter, I'm not really fan that it could also start a document. On babelmark, seems pandoc is correctly parsing a beginning --- and trailing ..., but not a beginning ...

I'm not against adding support for a trailing ... It will just require a bit more work, as the current code path is re-using the fenced code block parser, which expects starting/ending marker to be identical (it is also a bit innaccurate for YAML, as Markdown expects the same number of characters >=3, while YAML expects exactly 3). So the YAML frontmatter parser will require a - small - dedicated parser then.

@xoofx commented on GitHub (Aug 29, 2017): From [YAML specs](http://www.yaml.org/spec/1.2/spec.html#id2760395): > - Three dashes `---` is used to separate directives from document content. This also serves to signal the start of a document if no directives are present > - Three dots `...` indicate the end of a document without starting a new one, for use in communication channels So while `...` could be used for ending a YAML frontmatter, I'm not really fan that it could also start a document. On [babelmark](https://babelmark.github.io/?text=---%0AThis+is+a+yaml+test%0A...%0Anot+yaml), seems pandoc is correctly parsing a beginning `---` and trailing `...`, but not a beginning `...` I'm not against adding support for a trailing `...` It will just require a bit more work, as the current code path is re-using the fenced code block parser, which expects starting/ending marker to be identical (it is also a bit innaccurate for YAML, as Markdown expects the same number of characters >=3, while YAML expects exactly 3). So the YAML frontmatter parser will require a - small - dedicated parser then.
Author
Owner

@kenmuse commented on GitHub (Aug 29, 2017):

Double checked Pandoc's spec and it appears that they document it as a leading triple-dash, trailing dots or dash. Would it make sense for this enhancement to be in the current YAML frontmatter parser? If so, I could submit a PR that enhances the TryContinue method to handle this case by matching on 3 dashes or dots.

@kenmuse commented on GitHub (Aug 29, 2017): Double checked [Pandoc's spec](http://pandoc.org/MANUAL.html#extension-yaml_metadata_block) and it appears that they document it as a leading triple-dash, trailing dots or dash. Would it make sense for this enhancement to be in the current YAML frontmatter parser? If so, I could submit a PR that enhances the TryContinue method to handle this case by matching on 3 dashes or dots.
Author
Owner

@xoofx commented on GitHub (Aug 29, 2017):

Yes, it should be in the current YAML frontmatter, but as I said, the parser should be rewritten with a simpler logic, just handling the YAML frontmatter (but taking inspiration from FencedCodeBlockParser for handling correctly the lines between the markers)

@xoofx commented on GitHub (Aug 29, 2017): Yes, it should be in the current YAML frontmatter, but as I said, the parser should be rewritten with a simpler logic, just handling the YAML frontmatter (but taking inspiration from FencedCodeBlockParser for handling correctly the lines between the markers)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#137