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

Add an option to include arbitrary YAML documents #117

Closed
Witiko opened this issue Jan 17, 2022 · 2 comments
Closed

Add an option to include arbitrary YAML documents #117

Witiko opened this issue Jan 17, 2022 · 2 comments
Labels
feature request lua Related to the Lua interface and implementation yaml Related to the tinyyaml library.
Milestone

Comments

@Witiko
Copy link
Owner

Witiko commented Jan 17, 2022

Since #22, the Markdown package supports YAML metadata in markdown documents. The metadata may appear anywhere in a markdown document, but they must begin with three dashes (---) and end with either three dashes of three dots (...), which is vaguely in the spirit of the YAML spec and compatible with Pandoc.

Due to the separators, we can't include arbitrary YAML documents using the \markdownInput command:

\markdownInput[jekyllData]{metadata.yml}  % This won't work

There is a good reason for this behavior, too. For example, many documents would be ambiguous without the separators:

\usepackage[jekyllData]{markdown}
\begin{markdown}
---
- this
- is
- YAML
...
\end{markdown}
\begin{markdown}
- but
- this
- is
- markdown
\end{markdown}

However, it would be neat if we could ask the Markdown package to give preference to YAML when things are ambiguous.

I propose to add a boolean option (for example jekyllDataAlways or expectJekyllData). When enabled, the option would ask Markdown to assume that Markdown documents always begin with a YAML metadata block. In practice, the option would make the surrounding --- and ... optional for YAML metadata that appear at the very beginning of a markdown document:

\usepackage[jekyllData]{markdown}
\markdownInput[expectJekyllData]{metadata.yml}
\begin{markdown*}{expectJekyllData}
- this
- is
- YAML
\end{markdown*}
\begin{markdown}
- but
- this
- is
- markdown
\end{markdown}

One alternative would be to overload the current jekyllData option and make it mixed rather than boolean (the valid values would be false or "never", true or "explicit", and "always"). However, this would require a smarter type casting code in the Lua CLI (or perhaps drop the booleans?).

Another alternative would be to add a separate command (for example \yamlInput) for this. However, I plan to keep the surface area of markdown small and such a command sounds like it belongs to a separate package. Additionally, the above approach is more general and allows users to define \yamlInput{#1} as \markdownInput[jekyllData, expectJekyllData]{#1}.

@Witiko Witiko added feature request lua Related to the Lua interface and implementation labels Jan 17, 2022
@Witiko Witiko added this to the 2.14.0 milestone Jan 17, 2022
@Witiko Witiko changed the title Support Add an option for including arbitrary YAML documents Jan 17, 2022
@Witiko Witiko changed the title Add an option for including arbitrary YAML documents Add an option te include arbitrary YAML documents Jan 17, 2022
@Witiko Witiko changed the title Add an option te include arbitrary YAML documents Add an option to include arbitrary YAML documents Jan 17, 2022
@TeXhackse
Copy link

Concerning the \yamInput you are right. It might be better to have the more general solution in this package because users may configure anything themselves anyway. So I now agree with the option being the better Idea.

Concerning the option I'd prefer splitting up into more values. Simply because it's the nowerdays more common way to handle it within LaTeX. This would just require to split up into 2 booleans so expectJekyllDataand the jekyllData boolean internally.

@Witiko Witiko added the yaml Related to the tinyyaml library. label Jan 26, 2022
@Witiko Witiko modified the milestones: 2.14.0, 2.15.0 Feb 27, 2022
@Witiko Witiko closed this as completed in 78dc62b Mar 28, 2022
@Witiko
Copy link
Owner Author

Witiko commented Mar 28, 2022

@TeXhackse I added the expectJekyllData Lua option in commit 78dc62b. For more information, please see the user manual.

Witiko pushed a commit that referenced this issue Jan 13, 2023
Merge upstream branch main into branch commonmark
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request lua Related to the Lua interface and implementation yaml Related to the tinyyaml library.
Projects
None yet
Development

No branches or pull requests

2 participants