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

Support yaml_metadata_block extension in more formats #3084

Closed
wants to merge 6 commits into from

Conversation

tarleb
Copy link
Collaborator

@tarleb tarleb commented Aug 22, 2016

This allows to specify metadata using yaml blocks with input formats RST, Org-mode, and LaTeX when the yaml_metadata_block extension is specified. Other than with Markdown, YAML blocks are not fully integrated into the language parser and may only appear at the top of a document. This should add enough flexibility to pass metadata in the form of a YAML block, yet limits the extend this feature has on language parsing.

This closes #1960.

tarleb added 6 commits October 1, 2016 22:27
Make it possible for other readers to use the YAML block parser.
The YAML metadata parser is useful for many formats and is specific
enough to warrant a separate module.
Enabling the yaml_metadata_block allows authors to include an optional
YAML metadata blocks at the top of an org file.
Enabling the yaml_metadata_block allows authors to include an optional
YAML metadata blocks at the top of an RST file.
Enabling the yaml_metadata_block allows authors to include an optional
YAML metadata blocks at the top of an LaTeX file.
@tarleb
Copy link
Collaborator Author

tarleb commented Oct 27, 2016

@jgm What do you think about the idea in general? Quite a few people asked about getting YAML blocks for org files in the past. Do you see a better way to handle this?

@jgm
Copy link
Owner

jgm commented Oct 28, 2016

I'm conflicted about the idea. Conceptually, there are two ways to think about YAML metadata. Either (a) it's an integral part of the format or (b) it's separate from the format. With option (b) you think of documents that start with YAML metadata as really two documents glued together, one a metadata bit and the other the document proper.

With pandoc's Markdown we took option (a), so it feels somewhat inconsistent to me to take option (b) with the other formats. But of course, with them, option (b) is the only option we could take.

There's also a question what to do about formats that have their own ways to specify metadata (as RST does) -- how does this interact with YAML metadata?

@tarleb
Copy link
Collaborator Author

tarleb commented Oct 29, 2016

Indeed, that conceptual view makes it look like like a bad idea. I was coming at this from the user perspective, aiming for somewhat uniform behavior, but I know see that it's less consistent than I hoped it would be.

How do you feel about the alternative solutions proposed in #1960, e.g. a command-line option --yaml-header which takes an optional format?

There are two main use-cases for this feature: One are markup-formats that allow no or only limited inclusion of metadata (basically all of them). The other are programs like hakyll which use pandoc but use YAML instead of pandoc's metadata.

There's also a question what to do about formats that have their own ways to specify metadata (as RST does) -- how does this interact with YAML metadata?

I'd prefer if YAML metadata were treated as default values which can be overwritten.

@tarleb
Copy link
Collaborator Author

tarleb commented Dec 11, 2016

@jgm, do you think there is a chance to somehow use YAML blocks with arbitrary formats in pandoc 2? Otherwise I'll just close this.

@jgm
Copy link
Owner

jgm commented Dec 11, 2016 via email

@hoelterhof
Copy link

To contribute to this issue with another opinion I would like to say that I agree with tarlebs view. I would like to underline the user perspecitve on pandoc as a flexible and multi propose document converter. Not all languages support their own metadata blocks and somehow YAML is intended to be a universal metadata language. So there is a reason to follow both concepts: a) and b).

Or let's put it in the view of usability: a user might easily expect YAML to be independent from the native file format, and it is difficult to explain why certain pandoc input formats should not support yaml...

@mb21
Copy link
Collaborator

mb21 commented Jan 4, 2017

While I can see the appeal of simply prepending some yaml metadata to existing rst/org-mode/latex files to quickly get some metadata fields set, doing so would make those files unparsable for the native rst program, pdflatex etc. In fact you would have a .tex file that isn't actually valid TeX.

Not sure how often-requested this feature is, but would it be too much to ask users to save the metadata in a separate yaml file which can be supplied as an argument as proposed in #1960?

@tarleb
Copy link
Collaborator Author

tarleb commented Jan 4, 2017

The main benefit of being able to put the YAML block into the file is that both pandoc and tools like hakyll can read it. Here's one such example file: https://raw.githubusercontent.com/turboMaCk/turboMaCk.github.io/develop/posts/2016-12-21-org-mode-in-hakyll.org (rendered version).

(I'm not arguing your general point, which I'm agree with, I just want to provide some context.)

@getreu
Copy link
Contributor

getreu commented Aug 20, 2017

I wrote a pandoc-notetaking tool for organizing notes in files. It uses the YAML header to synchronize the document title and subtitle with the filenames of notes. It relies on pandoc for rendering html. This feature #3084 would greatly improve my use case as it would enable the tool to support all markup languages that pandoc understands.

@tarleb tarleb closed this Sep 16, 2018
@tarleb tarleb deleted the yaml-blocks branch December 23, 2019 13:15
@saurabhnanda
Copy link

Did this get merged? Can I use YAML metadata blocks in RST? (I tried, but it doesn't seem to be working - I'm not sure if I'm doing something wrong).

The docs don't explicitly state that YAML metadata blocks work only with Markdown files (one can make an implicit assumption because all the examples are related to markdown).

@tarleb
Copy link
Collaborator Author

tarleb commented Aug 29, 2020

Not merged. You'd have to write a small wrapper around pandoc which splits the input into two temporary files, the YAML header and the content. The YAML would then be passed via --metadata-file.

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

Successfully merging this pull request may close these issues.

Feature request: Ability to specify a YAML metadata file for all reader types
6 participants