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
Multiple new lines between entries in the frontmatter "breaks" the parser when rendering #6042
Comments
Unfortunately, that's not behavior we can control, it comes directly from Pandoc. You can verify this by running your documents against Pandoc directly with |
We should document this on quarto.org, though. |
Ah okay, thank you for your explanation. I've checked out following command to see if pandoc actually parses the metadata of the file. $ quarto pandoc --template=./metadata.pandoc-tpl -f markdown test.md
{"format":{"pdf":{"pdf-engine":"pdflatex"}},"title":"Untitled"} with It seems to detect the metadata without issue, regardless of the amount of newlines used, except for the newline before the I don't know how pandoc handles all this stuff, since I've never used it before. Do you just provide a list of defaults, when pandoc doesn't receive them? |
@cscheid I believe the only format that Pandoc does not support is when I do not know if we plan to support YAML with empty lines, but currently we don't because of the first regex here IMO Lines 93 to 101 in 912f953
The
This means I see the comment says Line 93 in 912f953
So maybe the intended regex was /^\n\s*\n/ without the modifier
Now, writing empty lines in YAML is really not something that should be considered good practice. So we could disallow that, but maybe this should be a parsing error if 2 consecutive empty lines are found. Instead of silently rendering while ignoring the option like it does now. So I would change the regex to match Pandoc behavior maybe. Is there anywhere else where we are parsing the YAML ? FWIW changing the regex diff --git a/src/core/yaml.ts b/src/core/yaml.ts
index bcf8883f6..2a1a4935c 100644
--- a/src/core/yaml.ts
+++ b/src/core/yaml.ts
@@ -95,7 +95,7 @@ export function readYamlFromMarkdown(
// are entirely empty
// (that's not valid for pandoc yaml blocks)
if (
- !yamlBlock.match(/^\n\s*\n/m) &&
+ !yamlBlock.match(/^\n\s*\n/) &&
!yamlBlock.match(/^\n\s*\n---/m) &&
(yamlBlock.trim().length > 0)
) { will correctly make the YAML block be parsed with Hope it helps |
Oh neat, thank you for looking further into this! This seems to make a lot more sense now. |
Thanks for the proper context, @cderv!
(Yes, they are.) This looks like a great catch and fix, assuming it passes our test suite! |
I'll do a PR and we'll see then. |
Thanks, @cderv!! |
Thanks for the report @joelvonrotz ! |
Bug description
I've noticed, the Frontmatter/YAML parser seems to act funny when multiple new lines are inserted between entries, or well anywhere in the frontmatter.
When only one new line between entries is used, the parser detects the
pdf
format automatically.Steps to reproduce
---
in the frontmatterExpected behavior
Compile the document correctly using the given format (in this case being
pdf
).Actual behavior
Following also breaks the expected behaviour
Your environment
Quarto check output
The text was updated successfully, but these errors were encountered: