Open cscheid opened 12 months ago
I don't know if we should consider it a bug, but this is just not supported. params
needs to be in the YAML block header.
rmarkdown does consider YAML block header only, and not any YAML block inside the document. For example, you need to pass output: html_document
for the format inside the top yaml block.
In document YAML block would work only for what Pandoc does support but not for R Markdown or knitr feature. And params
is something specific to rmarkdown rendering.
What do we expect this to work exactly ? Does Quarto don't care if the YAML block information are top or not ?
Changing this would be a feature request for knitr to parse the whole document for YAML block, and parse it.
Currently, only the top YAML block is considered https://github.com/yihui/knitr/blob/4b47d2a57bd6ac31712d0afafbc4fe968b663c92/R/params.R#L74-L84
And this is the case for R Markdown fields too (only TOP yaml block is parsed).
There were discussion about this limitation of multiple YAML block in R Markdown (https://github.com/rstudio/rmarkdown/issues/1891) but this is considered a breaking change.
Changing it for Quarto only could be possible maybe, or maybe just for params.
Otherwise, this will be fixed probably when we have a language agnostic way to pass parameters to the tooling. Currently this issue you found with Quarto happens because this knitr/rmarkdown that does resolve the parameters directly.
Hope it clarifies to make a decision
What do we expect this to work exactly ? Does Quarto don't care if the YAML block information are top or not ?
No, it doesn't. Quarto (and Pandoc) collect all of the YAML blocks and merge them into a single metadata block before processing. That's why, for example, you don't see a "metadata block" in a Pandoc filter. The Pandoc node has a single metadata field that contains the metadata from all the blocks. I thought that's how knitr operated as well.
Ok thanks.
I thought that's how knitr operated as well.
No Quarto is an evolution of R Markdown on that topic. This is a design limitation on R Markdown that was hard to lift and Quarto solves it from the start. And that is really cool ! 😄
This doesn't work:
title: "test" format: html params: p1: 1.0 p2: "A" p3: TRUE
Test