-
-
Notifications
You must be signed in to change notification settings - Fork 982
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
do not evaluate inline R inside HTML comment tags #1619
Comments
Yes, that is essentially the same issue as #974. Thanks for your vote! |
I vote for this as well. Thank you. |
FWIW there is now a ---
title: "Untitled"
output: html_document
---
Here is some inline R `r 1+1`.
```{comment}
This should not be shown, because it is inside comment block `r 2+2`
This should not be evaluated, because it is inside a comment block `r stop()`
```
or from the community question ---
title: "Untitled"
output: html_document
---
```{r, eval = FALSE}
myoutput <- 2 + 2
```
```{comment}
The result is `r myoutput`
```
Does that answer part of the need that lead to this issue ? |
Does this engine use echo=FALSE as well? |
This engine will just make knitr ignore the content. Nothing will be output, no source chunk no result chunk. |
perfect :) Thank you :) |
Yes! 🙏 I'll then tentatively close this ticket. If users (such as myself in the above) want to comment something, there's a way to do that. I was initially a bit surprised by the above behavior: that R would still be evaluated inside HTML comment tags, which, given the tag hierarchy, seemed surprising (since the comment tag is above whatever is inside). But, now I'm not sure anymore, since (AFAIK), rmarkdown always first runs knitr toresolve all chunks, and only then calls pandoc, or whatever else to evaluate the markup. |
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. |
Possible duplicate of #974, but that's about chunks, not inline R, so I'm not sure.
Reproducible example
Render the below example document:
rmarkdown::render("reprex.Rmd")
Expected Behavior
... because both are inside HTML comment tags.
Observed Behavior
rmarkdown::render("reprex.Rmd")
fails.xfun::session_info()
The text was updated successfully, but these errors were encountered: