Skip to content
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

Feature suggestion: Support GFM YAML metadata block #66

Closed
zmwangx opened this issue Jan 8, 2016 · 5 comments
Closed

Feature suggestion: Support GFM YAML metadata block #66

zmwangx opened this issue Jan 8, 2016 · 5 comments

Comments

@zmwangx
Copy link

zmwangx commented Jan 8, 2016

Some Markdown implementations, e.g., GFM and Pandoc, support YAML metadata blocks. For GFM (according to testing, since it seems undocumented) the YAML block must start at the beginning at the document (even blank lines before it are not allowed) and be wrapped in --- (exactly three dashes) at the opening and closing, so an example document would be

---
title: README
author: Zhiming Wang
date: January 8, 2016

---

This is an example GFM document with a YAML metadata block.

and this will be rendered like

screen shot 2016-01-08 at 12 21 10 pm

Note that the blank line after the closing --- line is optional.

(Pandoc, on the other hand, has very lax rules for YAML metadata blocks, which allows them to be placed anywhere in the document, and allows closing with ... instead of ---. But Pandoc Markdown doesn't need to be supported.)

Currently, the line immediately above the closing --- is interpreted as a setext header, which looks rather weird (especially if you have a real header):

screen shot 2016-01-08 at 12 22 42 pm

Would you please consider supporting the metadata block? I suppose the block itself could be highlighted just like a fenced code block, and I suppose it shouldn't be too hard to adapt the parsing code of fenced code blocks to this particular block. Thanks.

@jrblevin
Copy link
Owner

jrblevin commented Jan 8, 2016

Supporting this would be fine with me. I'll add this to the todo list. If anyone would like to submit a patch for this, that would be helpful. The existing Pandoc and MultiMarkdown metadata parsing functions should serve as good examples.

@zmwangx
Copy link
Author

zmwangx commented Jan 8, 2016

Cool, thanks. I may give it a try myself when I have time.

cosmicexplorer pushed a commit to cosmicexplorer/markdown-mode that referenced this issue Feb 9, 2016
also add testing and allow multiple pandoc metadata

fix jrblevin#66
cosmicexplorer pushed a commit to cosmicexplorer/markdown-mode that referenced this issue Feb 9, 2016
Also allow multiple pandoc metadata, with tests. Fix jrblevin#66.
cosmicexplorer pushed a commit to cosmicexplorer/markdown-mode that referenced this issue Feb 9, 2016
Also allow multiple pandoc metadata, with tests. Fix jrblevin#66.
cosmicexplorer pushed a commit to cosmicexplorer/markdown-mode that referenced this issue Feb 9, 2016
Also allow multiple pandoc metadata, with tests. Fix jrblevin#66.
@cosmicexplorer
Copy link
Contributor

I made a pull request that seems to fix this. It's unfortunate that YAML is actually kinda hard to parse in its entirety; this doesn't attempt to highlight outside of simple key: value pairs, even though more complex constructions are sometimes used too. This should work for github pages editing, though.

cosmicexplorer pushed a commit to cosmicexplorer/markdown-mode that referenced this issue Feb 10, 2016
- Also allow multiple pandoc metadata, with tests. Fix jrblevin#66.
- Add defvar for markdown-search-until-condition
- Update with comments from @syohex
cosmicexplorer pushed a commit to cosmicexplorer/markdown-mode that referenced this issue Feb 10, 2016
Also allow multiple pandoc metadata, with tests. Fix jrblevin#66.
@syohex
Copy link
Collaborator

syohex commented Feb 10, 2016

I have merged @cosmicexplorer PR(#91). Please check latest version. If you have still problems, please reopen the issue and report us.

@khatchad
Copy link

This isn't working in pandoc 2.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants