How can I disable comment printing inside code chunks? #7521
-
DescriptionPlease note that I'm referring to comments inside the code chunk, not in the output. ExampleCode chunk
PDF output (could also be other formats, like HTML):Desired output |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
The solution provided by @yihui, which involves Ideally, the solution should only remove lines that start with |
Beta Was this translation helpful? Give feedback.
-
You're not going to like my answer, but: you don't. Comments are there to be read by people, and that's what the code output is there to support. Code that's not meant to be executed really ought to live inside a separate block with eval: false, or some related tool. I promise you it's a bad habit to use comments for that, and we don't want to incentivize that. |
Beta Was this translation helpful? Give feedback.
You're not going to like my answer, but: you don't. Comments are there to be read by people, and that's what the code output is there to support. Code that's not meant to be executed really ought to live inside a separate block with eval: false, or some related tool. I promise you it's a bad habit to use comments for that, and we don't want to incentivize that.