Choices is to kept the in-chunk special comment as-is, meaning the output will be a bit different than when purling a Rmd file.
I hesitated to had at least the label maybe in ## label -------------, but I figured it would transformed to much from the input and keeping the YAML line intact seems best.
To make this works, knitr need to know when we are in "quarto-like" mode meaning we will have the params$yaml.code available. I adapted from existing code by explicitly checking on Quarto through the extension of input file.
On the bonus side, I added a commit to support knit("doc.qmd") so that it produces a .md file and not a .txt file as of now. markdown mode was already known by detect_pattern() for .qmd file.
Closes #2165
knitr::purl("doc.qmd")
will now works and conserve in-chunk YAML options comment.Example
Choices is to kept the in-chunk special comment as-is, meaning the output will be a bit different than when purling a Rmd file. I hesitated to had at least the label maybe in
## label -------------
, but I figured it would transformed to much from the input and keeping the YAML line intact seems best.To make this works, knitr need to know when we are in "quarto-like" mode meaning we will have the
params$yaml.code
available. I adapted from existing code by explicitly checking on Quarto through the extension of input file.On the bonus side, I added a commit to support
knit("doc.qmd")
so that it produces a.md
file and not a.txt
file as of now.markdown
mode was already known bydetect_pattern()
for.qmd
file.