-
Notifications
You must be signed in to change notification settings - Fork 150
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
skip yaml (front matter)? #209
Comments
I'm not familiar with Jekyll or its front matters or whatever other tools support it. But if I understand it correctly, it's some sort of templating system and the document can contain references to variables defined in the front-matter. Also note the templating system itself seems to be more or less independent of the document format after the front-matter: E.g. you might have a static HTML page below the front-matter instead of Markdown. Consequently it seems to me that such raw documents shouldn't really be passed to Markdown or HTML or whatever parser before the templating system does its job, i.e. replaces the variable references with their respective value, removes the front-matter and then passes the result to the actual document parser, here MD4C. |
I think yaml front matter is turning into the standard way to add metadata, not only for templating systems. https://obsidian.md/ does that, and I'm trying to prototype a similar app with Qt. But ok I will see if I can get Qt to deal with it ahead of time, for now. (just the front matter, not template replacement) Turning a line of yaml into an H2 is just wrong.
becomes (with md2html)
|
I see. Then it might make sense. With the objection that no validation of the stuff between the two What should MD4C with it? Skipping it silently, propagating it as a code block (possibly with Also as it's not in vanilla CommonMark spec, it would likely be recognized only with some new parser option. |
I'm not sure yet what the md4c block type should be. Maybe other people will have comments on this in the meantime. I'm playing with https://codereview.qt-project.org/c/qt/qtbase/+/529543 for now. |
Markdown can have yaml headers (yeah it's not in commonmark, maybe not a good idea either... but it happened). I think maybe md4c should skip parsing of "front matter" but also make it available for further parsing with a yaml parser. I.e. if the first line of the file is just three hyphens, that's a special case, not a thematic break, and everything from there until the next line with three hyphens can be assumed to be front matter. (I guess someone was thinking that nobody starts a document with a thematic break, so it can be treated as a special case.) But I'm not sure where's the most-formal specification (to verify that it must begin on the first line, must be three hyphens, and so on).
https://docs.github.com/en/contributing/writing-for-github-docs/using-yaml-frontmatter
https://jekyllrb.com/docs/front-matter/
readthedocs/commonmark.py#208
https://assemble.io/docs/YAML-front-matter.html
ATM I'm trying to figure out what Qt should do with this, since it's currently a mess if you give such a document to https://doc-snapshots.qt.io/qt6-6.7/qml-qtquick-textdocument.html#source-prop I figured if md4c would give me that chunk, I can stash it away somehow so that QTextMarkdownWriter can re-write it verbatim when the file is saved; but Qt doesn't have a yaml parser, so an application that cares about that might need to subclass QTextDocument, retrieve the saved front-matter string, and parse it with https://github.com/jbeder/yaml-cpp or something like that. But QTD won't even skip it yet, so it's going to be a bit less convenient for now.
The text was updated successfully, but these errors were encountered: