-
-
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
Enhancement: Hide metadata header in markdown #7183
Comments
You can do |
Or, if you want the metadata in an HTML comment, here's another trick you can already do: create a template
Then
|
By the way, I kind of like the idea of putting metadata inside an HTML comment. I suggested exactly this in 2011 on the markdown-discuss mailing list. In principle, we could create a new extension, |
Hi @jgm, Many thanks for the feedback - and sorry I could not respond earlier!
Was not aware of that option - however, I think it only helps if it is Here is an example: I have an When I access GitBucket, and try to open this In other words - the Markdown-HTML parser of Gitbucket did not recognize the YAML header block, and started interpreting eveything inside it as Markdown. Specifically, I have a line in the header:
... and indeed, So, if we could alternatively use say
Thanks - that seems to be specific to Jupyter notebooks; I haven't really tried it, but it does not look to me, that it would help with my use case ( I want to keep a YAML header block in
I guess that a new extension would help my use case personally - however, I see your point with "gratuitous proliferation", and I agree with it... So, maybe my suggestion above is worth considering:
... and all this "built-in" |
With all due respect I think the onus should be on your other parser to support YAML meta data, not on Pandoc to hide it. If it doesn't need to do anything with it all they need to do is spot the standard YAML separators and discard the block. This is a very standard extension to Markdown and used by many many parsers. If you need to support something less featured then some kind of build step that exports the variant you need should be considered par for the course. Hidden behind a non-default option flag I couldn't actually object to this being a "feature", but both the proliferation of options and the proliferation of format variants seems like a bad thing to me. |
Playing my broken "Lua filter" record again: if all else fails, here's a filter to make pandoc work with the syntax proposed by @sdbbs: -- file: yaml-in-html-comments.lua
local meta
function RawBlock (raw)
if raw.format == 'html' and raw.text:match '%<%!%-%-%-'then
local yaml = raw.text:gsub('^<!%-%-%-', '---'):gsub('%-%-%->$', '---')
meta = pandoc.read(yaml, 'markdown+yaml_metadata_block').meta
end
end
-- set as document's metadata; could also do a merge instead (if necessary).
function Meta (_) return meta end Use with |
I think the Lua filter solution should work well enough, so I'm closing this. Please reopen if the proposed solution proves to be insufficient. |
I'd like to keep this open for further consideration. |
Thanks all for the comments:
Yes, I should have mentioned, that I didn't easily decide to post this, because it obviously would increase the work/support load on the
OK, I was not aware of this, thanks for mentioning it. However,
Fully agree there. But now that I have seen the lua filter in #7183 (comment) - I actually think I could live with it, since I use lua filters in my workflow anyways; so I guess, that particular lua filter solves my problem. |
These days the Common Mark project is a much better place to point projects toward if you want them to have interoperable Markdown than the original Daring Fireball post, but you do have a point — as widespread as YAML meta data is (used by many publishing platforms, static side generators, even Markdown note taking applications!) it is still an extension to Markdown not part of Markdown itself. Even CommonMark thinks of it that way. The Pandoc flavor includes it by default, but having a way to wrap the extra data in a way that any CommonMark compatible parser would not break would be an interesting extension. |
Thanks, @alerque :
Thanks, good to know this! Btw, I just found something going against my suggestion of https://stackoverflow.com/questions/4823468/comments-in-markdown
Not sure if this is still applicable though, tried |
Triple dashes being treated differently was probably a bug. HTML comments are a nightmare to parse. Did you know |
This was suggested in jgm/pandoc#7183 but I expect this might not be what I want Signed-off-by: Y. Meyer-Norwood <106889957+norwd@users.noreply.github.com>
I would like to propose, as an enhancement, the same approach taken here Hide metadata header in markdown · Issue #527 · mwouts/jupytext :
In other words - allow that, instead of the default opening and closing "three-dashes" (
---
) strings, that define start and end of a YAML header block in Pandoc Markdown - the opening (<!--
) and closing (-->
) tags for HTML comments are used. In that way, the header would still be interpreted by Pandoc - while being fully hidden from typical automatic online parsers of Markdown to HTML (such as GitHub's).Alternatively, allow that the very first line in a Pandoc Markdown document can start with an HTML comment, and that the starting
---
of a Pandoc Markdown YAML header can be on the second line of the Markdown text file; in that way, probably most of the code that parses the YAML header can be kept (including starting and stopping---
), while still allowing for hiding the YAML header from online Markdown parsers.The text was updated successfully, but these errors were encountered: