mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-03 21:36:36 +00:00
Support for Pandoc YAML front matter #137
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.
@xoofx commented on GitHub (Aug 29, 2017):
From YAML specs:
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.@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.
@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)