-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement YAML block additional feature #104
base: master
Are you sure you want to change the base?
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.YamlBlock
is defined, andFencedCodeData
is 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.YamlBlock
blocks the same way asBlockTag.FencedCode
blocks, except that instead of writing the info string, aclass="language-yaml"
attribute will be written.