Support in-chunk options syntax for `knitr::purl()`
With the new chunk options syntax in Quarto and multiline we should see how using purl (knitr::purl(), hook_purl() and purl = TRUE) should retrieve the params correctly when documentation = 1L the default
From @andrewpbray in https://github.com/quarto-dev/quarto-cli/discussions/1773#discussioncomment-3514864
Example
---
title: "Untitled"
format: html
keep-md: true
---
# Head
```{r eval = TRUE}
1 + 1
```
# Head 2
```{r}
#| eval = TRUE
2 + 2
```
# Head 3
```{r}
#| eval: true
3 + 3
```
Running knitr::purl("test.qmd") will output this R file
## ----eval = TRUE----------------------------------------------------------------------------------------------------------------------------------------------
1 + 1
## -------------------------------------------------------------------------------------------------------------------------------------------------------------
2 + 2
## -------------------------------------------------------------------------------------------------------------------------------------------------------------
3 + 3
Same with using knitr::hook_purl()
---
title: "Untitled"
format: html
keep-md: true
---
```{r}
knitr::knit_hooks$set(purl = knitr::hook_purl)
knitr::opts_chunk$set(purl = TRUE)
```
# Head
```{r eval = TRUE}
1 + 1
```
# Head 2
```{r}
#| eval = TRUE
2 + 2
```
# Head 3
```{r}
#| eval: true
3 + 3
```
Leading to this script
## ----r------------------------------------------------------------------------
knitr::knit_hooks$set(purl = knitr::hook_purl)
knitr::opts_chunk$set(purl = TRUE)
## ----r eval = TRUE------------------------------------------------------------
1 + 1
## ----r------------------------------------------------------------------------
2 + 2
## ----r------------------------------------------------------------------------
3 + 3
Yes, we should support it. Please feel free to give it a try.
Related Quarto discussion about purl() within quarto (https://github.com/quarto-dev/quarto-cli/issues/389) - just for reference
Note to us: Might be better to preserve the original comments and not translate the YAML values at all.
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.