-
Notifications
You must be signed in to change notification settings - Fork 235
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
Code blocks with no language specified have class="NA"
in generated HTML
#1251
Comments
Would you prefer dropping the NA or using R instead? |
I'm conflicted -- I think in most cases, people would want |
FWIW pkgdown will assume code blocks with no language specified are R blocks. (or maybe it shouldn't, then 🙂 ) r-lib/pkgdown#1724 |
I think we should drop the pkgdown can continue guessing that all unmarked code blocks are R because it will try to parse them, and if they're not valid R code they don't get R syntax highlighting. |
Ok, this problem was more subtle than I thought. It only appears if the first character in the code is "r": library(roxygen2)
out <- roc_proc_text(rd_roclet(), "
#' Title
#'
#' ```
#' r <- 1:10
#' ```
#' @md
foo <- function() {}")[[1]]
out$get_section("description")
#> \description{
#> \if{html}{\out{<div class="sourceCode NA">}}\preformatted{r <- 1:10
#> }\if{html}{\out{</div>}}
#> } Created on 2022-07-10 by the reprex package (v2.0.1) library(roxygen2)
out <- roc_proc_text(rd_roclet(), "
#' Title
#'
#' ```
#' x <- 1:10
#' ```
#' @md
foo <- function() {}")[[1]]
out$get_section("description")
#> \description{
#> \if{html}{\out{<div class="sourceCode">}}\preformatted{x <- 1:10
#> }\if{html}{\out{</div>}}
#> } Created on 2022-07-10 by the reprex package (v2.0.1) |
For example:
https://github.com/rstudio/shiny/blob/6f46b847e2efb74a0cb82edee4d1c60658d8c9e1/R/bind-cache.R#L60-L63
turns into:
https://github.com/rstudio/shiny/blob/6f46b847e2efb74a0cb82edee4d1c60658d8c9e1/man/bindCache.Rd#L66-L68
(Note that in the linked code above, it was generated with roxygen2 7.1.1 and does not have the
sourceCode
class, but theNA
issue is still present.)If
```R
is used to open the code block, then it (correctly) turns intoclass="sourceCode R"
.Update: Are curly braces (like
```{r, eval=FALSE}
) needed for syntax highlighting?The text was updated successfully, but these errors were encountered: