-
Notifications
You must be signed in to change notification settings - Fork 335
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
Chunk code is not highlighted when comment = NA #1296
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@jayhesselberth here are the differences: v1.5.1v1.4.1knitr |
Sorry, I see the issue now, I was focused on the comments themselves. |
Might be related to changes in f49ffa5 |
Here is another minimal example: package.skeleton("x")
dir.create("x/vignettes")
cat("```r\n#\n```", file = "x/vignettes/x.Rmd")
pkgdown::build_article("x", "x")
html <- xml2::read_html("x/docs/articles/x.html")
src <- xml2::xml_find_first(html, ".//div[contains(@class, 'sourceCode')]")
as.character(src) under 1.4.1 this would return [1] "<div class=\"sourceCode\" id=\"cb1\"><pre class=\"sourceCode r\"><code class=\"sourceCode r\"><a class=\"sourceLine\" id=\"cb1-1\" data-line-number=\"1\"><span class=\"co\">#</span></a></code></pre></div>" whereas as of f49ffa5 it returns [1] "<div class=\"sourceCode\" id=\"cb1\"><pre class=\"r\">#</pre></div>" This function Lines 4 to 28 in aea6864
Note that the behaviour is not just triggered if the comments are changed with |
Preserves highlight markup in code consisting entirely of code comments (lines beginning with #'s). Part of #1296
Highlighting of empty expressions is fixed. I don't think we should encourage use of |
Improved version of r-lib#1307 accounting for problems caused by empty expressions consisting of empty strings or whitespace only. Prevents highlight markup from being stripped from code that consists entirely of code comments (only lines beginning with #'s). A partial fix for r-lib#1296, but would still not syntax highlight code chunks that resulted in syntax errors (e.g., when knitr chunk options collapse = TRUE and comment = NA are set)
Improved version of r-lib#1307 accounting for problems caused by empty expressions consisting of empty strings or whitespace only. Prevents highlight markup from being stripped from code that consists entirely of code comments (only lines beginning with #'s). A partial fix for r-lib#1296, but would still not syntax highlight code chunks that resulted in syntax errors (e.g., when knitr chunk options collapse = TRUE and comment = NA are set)
This is technically a change in behaviour, but I don't think it's a bug. We now use R itself to do the syntax highlighting, so we can only syntax highlight valid R code. |
@hadley, Agreed. But code that is just |
@wkmor1 I'd recommend opening a new issue with a minimal reprex |
Changing the default value of the
comment
setting will remove chunk's highlighting.reprex
outputs
comment = "#"
works:The text was updated successfully, but these errors were encountered: