Conversation
|
Seems ok, however a few notes (disclaimer - I haven't ever actually used yaml):
|
|
I don't particularly have any objection to extending the YAML support to be more like fenced code blocks. I implemented it to strictly conform to Pandoc's handling of these blocks, however (at least per their documentation). From a document processing perspective, extending YAML support in the way you describe could certainly be useful. In particular, it could allow for specifying the metadata format (e.g. not restricted to implied YAML). The one thing I do not quite feel right about is providing support in the HTML formatter for these blocks at all, or at least by default, since it's specifically meta data. I think from a CommonMark.NET perspective, using this additional feature should imply that you are always doing your own tree processing, since you need to separate metadata from markdown. So I propose:
|
|
Yes, using the more generic As for the HtmlFormatter - my guess is that the best default behavior would be to not render them at all. At least situations where I see I could be using the metadata it would not be something that I would want to be visible in the output. As for the delegate - I think that the ability to derive from |
This implements support for parsing YAML blocks and front-matter
following the Pandoc rules:
1. Delimited by three hyphens (---) at the top
2. Delimited by three hyphens (---) or dots (...) at the bottom
3. May occur anywhere in the document, but if not at the beginning
must be preceded by a blank line.
BlockTag.YamlBlock is defined, and FencedCodeData is used to store the
closing fence character (either `-` or `.`) and to indicate whether the
closing fence has been seen in the same manner as BlockTag.FencedCode.
YAML support may be enabled via two-flavors:
1. CommonMarkAdditionalFeatures.YamlBlocks: this allows for any
number of YAML blocks anywhere in the document.
2. CommonMarkAdditionalFeatures.YamlFrontMatterOnly: allows for
exactly one YAML block, defined on the first line of the document.
The HTML formatters treat BlockTag.YamlBlock blocks the same way as
BlockTag.FencedCode blocks, except that instead of writing the info
string, a `class="language-yaml"` attribute will be written.
This implements support for parsing YAML blocks and front-matter following the Pandoc rules:
BlockTag.YamlBlockis defined, andFencedCodeDatais used to store the closing fence character (either-or.) and to indicate whether the closing fence has been seen in the same manner asBlockTag.FencedCode.YAML support may be enabled via two-flavors:
CommonMarkAdditionalFeatures.YamlBlocks: this allows for any number of YAML blocks anywhere in the document.CommonMarkAdditionalFeatures.YamlFrontMatterOnly: allows for exactly one YAML block, defined on the first line of the document.The HTML formatters treat
BlockTag.YamlBlockblocks the same way asBlockTag.FencedCodeblocks, except that instead of writing the info string, aclass="language-yaml"attribute will be written.