-
-
Notifications
You must be signed in to change notification settings - Fork 878
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
knitr::purl
does not retrieve comments that starts with #|
in chunks
#2268
Comments
knitr::purl
does not retrieve comments that starts with #|
in chunks
I think the core of the difference is placed in the body of |
Hi ! Thanks for opening an issue. First, let's gets some precision.
This is expected to use such comment for option with Quarto files as this is the recommended way to pass option to code cells there (https://quarto.org/docs/computations/r.html#chunk-options) When you do this
it is not valid chunk option. Are they intended to be regular comment ? If so, you shouldn't use
This is the intended differences: Starting with This leads to my context question: Are you trying to purl in the context of a Quarto document ? Thank you |
Hello. I am trying to extract that kind of comments in order to retrieve the references in the captions of (Quarto) chunks (i.e. those ones that start with |
Where in your process do you need to
We recently brought support for purl-ing a Example with ```{r}
#| fig-cap: Hello world
#| echo: false
#| eval: true
mtcars$cyl
``` run #| fig-cap: Hello world
#| echo: false
#| eval: true
mtcars$cyl The behavior is changing because internally It seems we are not supported both in-chunk options, with in-header option. We are not merging those too in our Why do you have both type of options syntax ? It would be helpful to really understand how you are working, and what you are trying to do. It seems you want to build around Quarto, and maybe using knitr directly to parse the document is not the best move. |
To put it in a nutshell, what I was trying to achieve was a way to extract the captions from chunks whether they came from a Rmd or Qmd (file) text. But now I understand better how Thanks for the help and time. 👍 |
There is a really good package to parse Rmd content called parsermd (https://github.com/rundel/parsermd/) But it is not yet adapted to support the new option format: when it does, I guess it can be useful to your use case |
@yihui I am leaving this open in case you feel we should still improve our purl output. Currently we parse in-header and in-chunk options but we don't merge them before writting the tangled output. I wonder if we should improve... 🤔 |
Thank you. Yes, my interest is to come up with a way to extract all citations made within an Rmd or Qmd document, but with the care NOT to take into account places where a citation might not appear (e.g. within a chunk, only search in the |
|
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. |
R 4.3.1
knitr 1.43
OS: Windows 10 64bits
Hello.
I think there is a bug with
knitr::purl
function. When I was working with some Quarto files, I realize thatknitr::purl
excludes from its outputs those comments that starts inmediatly with#|
. For example:Input:
Clearly, I do expect that both text should produce (almost) the same result (I put almost because maybe the
text1
could have an extra breakline, but not more). However, withtext2
,knitr:purl
omits all the comment lines.By filing an issue to this repo, I promise that
xfun::session_info('knitr')
. I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version:remotes::install_github('yihui/knitr')
.I understand that my issue may be closed if I don't fulfill my promises.
The text was updated successfully, but these errors were encountered: