-
-
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
Bug (or at least unexpected behavior) for code chunks commented out w/ HTML comments #720
Comments
That's correct. knitr treats your document as a set of text with chunks in On Wed, Jun 8, 2016 at 3:33 PM, jgellar notifications@github.com wrote:
|
Yeah, I imagined this would be the case. I just think it would be more appropriate for the knitr parser to recognize that a code chunk is contained within an HTML comment, so the programmer probably does not intend for it to be executed. At least I would hope it would be consistent with what happens when you execute "Run all previous chunks in the source file", which recognizes that the chunk is commented out. |
Interesting, that's not an intended inconsistency! @yihui, what do you think about respecting HTML comments in knitr? On Wed, Jun 8, 2016 at 5:30 PM, jgellar notifications@github.com wrote:
|
As mentioned above, knitr does not know anything about HTML comments. There are two complications if I have to recognize HTML comments in knitr: 1) it is hard/impossible to do it well only by using regular expressions (on which knitr's parser is based); 2) I will also have to consider other document formats such as Rnw, Rhtml, and so on. So the only solution for now is |
Perhaps it could be done within rmarkdown? e.g., in
Even if regular expressions are difficult for finding |
A simple example illustrating why it is difficult:
To reliably parse the HTML comment, I will have to use a real Markdown parser instead of regular expressions. |
Closing this one and let's focus on #974 instead. |
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. |
I'm not sure if this is a bug in rmarkdown, knitr, or RStudio, but i'm posting it here. I'm using rmarkdown version 0.9.6, knitr version 1.12.3, and Rstudio version 0.99.893. Also, I'm running MRO version 3.2.5, if that matters at all.
It appears that if you comment out a section of an R markdown document using HTML comments, and that section contains an R code chunk, then that code chunk is still executed when you knit the document. The execution is silent, so any print statements/figures do not appear in the output. However, if you modify variables in the chunk, they do get modified.
Note that if you "run all previous chunks in the source file" from a chunk after the commented-out section, so that the code is executed in the console, the commented-out chunk does not get executed. This is the behavior I would expect to happen when you knit the document. Here's a reproducible example:
The text was updated successfully, but these errors were encountered: