-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Support YAML metadata block in gfm #6537
Comments
GitHub has had special rendering for YAML metadata in Markdown for a few years now, so it might make sense to support YAML blocks even when just using |
I can't think of any good reason not to support this. I wasted an hour or two trying to figure out why the YAML was being spit as part of the PDF before I stumbled upon the workaround. |
I think the merits of this request are undisputed. What's missing is the
contributor power to make it happen.
|
@taleb so the task is to find the code for |
GitHub Flavored Markdown is a variant of CommonMark and pandoc uses the commonmark-hs library for parsing it. The challenge is to add YAML support there. The repo is https://github.com/jgm/commonmark-hs. |
See also jgm/commonmark-hs#17 |
This is a bit more complicated than the average commonmark extension, because here we need to parse the YAML into a YAML object, and then parse the terminal nodes as commonmark. I have to think about the best way to handle this. |
In the mean time, is there any way to hide the metadata block from the output? For my purposes, just discarding it is fine. |
Your best bet is probably to preprocess the input and strip it off before passing to pandoc. |
Ended up doing this. --- worked out to return as horizontal rule, so for my needs, I just sort of modified one of the example scripts. from pandocfilters import toJSONFilter
incomment = False
firstLine = True
def comment(k, v, fmt, meta):
global incomment
global firstLine
if(firstLine and k == 'HorizontalRule'):
incomment = True
firstLine = False
return []
elif(incomment and k == 'HorizontalRule'):
incomment = False
return []
if incomment:
return [] # suppress anything in a header
if __name__ == "__main__":
toJSONFilter(comment) |
As explained in #2827 (comment) the
gfm
format specifier doesn't support YAML metadata blocks. This doesn't work currently.The workaround for now is to use deprecated
markdown_github
format specifier.✗ pandoc -v
The text was updated successfully, but these errors were encountered: