Hi all,
When producing a PDF from an RMarkdown document, it is possible to change the underlying .tex based tokens such as KeywordTok, AttributeTok, FunctionTok etc.
I would like to do the same for a package vignette. I searched everywhere (over the internet, inside package rmarkdown .css files etc.) but I am still unable to get this done. For instance, changing the colors from the bottom of rmarkdown/templates/html_vignette/resources/vignette.css (e.g. span.kw, span.co ) doesn't seem to have any effect when re-knitting the .Rmd document.
I also tried to change that file and supply it as a custom .css inside the yaml header, and still no good result.
I would be grateful for any hint,
Adrian
EDIT: this seems to be related [FR] improve default syntax highlighting for vignettes · Issue #2360 · rstudio/rmarkdown · GitHub
To answer my own question, the problem was an older Pandoc version. Updating Pandoc suddently solved everything, as described here:
opened 09:12PM - 16 Aug 22 UTC
next
The Vignette syntax highlighting does not seem to follow the general structure o… f the html classes.
Something like `aa <- c(1, 2)` is rendered in the html version as
```html
aa <-<span class="st"> </span><span class="kw">c</span>(<span class="dv">1</span>, <span class="dv">2</span>)
```
I believe the function `c()` should in fact have a class "fu" (not keyword "kw"). Similarly, something like `runif(n = 3)` is rendered as:
```html
<span class="kw">runif</span>(<span class="dt">n =</span> <span class="dv">3</span>)
```
where the argument `n` should have a different class from DataType ("dt"), perhaps "at" if I am not mistaken. Is there a special reason why these classes are mixed up?
Below is the output from:
```
> xfun::session_info('rmarkdown')
R version 4.2.0 RC (2022-04-15 r82193)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.4
Locale: en_US.UTF-8 / en_US.UTF-8 / en_US.UTF-8 / C / en_US.UTF-8 / en_US.UTF-8
Package version:
base64enc_0.1.3 bslib_0.4.0 cachem_1.0.6 digest_0.6.29 evaluate_0.16 fastmap_1.1.0
fs_1.5.2 glue_1.6.2 graphics_4.2.0 grDevices_4.2.0 highr_0.9 htmltools_0.5.3
jquerylib_0.1.4 jsonlite_1.8.0 knitr_1.39.7 magrittr_2.0.3 memoise_2.0.1 methods_4.2.0
R6_2.5.1 rappdirs_0.3.3 rlang_1.0.4 rmarkdown_2.15.1 sass_0.4.2 stats_4.2.0
stringi_1.7.8 stringr_1.4.0 tinytex_0.41 tools_4.2.0 utils_4.2.0 xfun_0.32
yaml_2.3.5
Pandoc version: 2.9.2
```
## Checklist
When filing a _bug report_, please check the boxes below to confirm that you have provided us with the information we need. Have you:
- [x] [formatted your issue](https://yihui.org/issue/#please-format-your-issue-correctly) so it is easier for us to read?
- [x] included a minimal, self-contained, and reproducible example?
- [x] pasted the output from `xfun::session_info('rmarkdown')` in your issue?
- [x] upgraded all your packages to their latest versions (including your versions of R, the RStudio IDE, and relevant R packages)?
- [x] installed and tested your bug with the development version of the rmarkdown package using `remotes::install_github("rstudio/rmarkdown")`?
system
Closed
August 24, 2022, 7:23pm
3
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.