rstudio / rmarkdown

Dynamic Documents for R
https://rmarkdown.rstudio.com
GNU General Public License v3.0
2.83k stars 971 forks source link

Default highlighting color change (no specific highlighting pandoc statement in yaml) #2044

Open garberadamc opened 3 years ago

garberadamc commented 3 years ago

After updating Rstudio (Version 1.4.1103) & re-knitting my RMD file the default syntax highlighting changed. I did not specify any statements in the YAML (i.e., default/automatic highlighting). I would like to reproduce the original style (highlighting color was orange rather than yellow). I tried all the yaml options found in Garrick's blog but could not reproduce this style. To see the change in highlighting style see the before and after screenshots here.

By filing an issue to this repo, I promise that

I understand that my issue may be closed if I don't fulfill my promises.

cderv commented 3 years ago

Hi @garberadamc Thanks for opening the issue. It is very clear and the link to your repo helped a lot.

I believe the change you see is due to a change in Pandoc version. RStudio 1.3 came by default with Pandoc 2.7.3 and RStudio 1.4 comes with Pandoc 2.11.2.

As you are using PDF, the default highlighting style is tango from Pandoc Syntax Highlighting. This means that is Pandoc doing the code parsing for syntax highlighting, and set the style to tango in this case. It seems they have changed the parsing and maybe also the style.

See this question in the community where I also explain this for HTML : https://community.rstudio.com/t/was-pygments-highlight-style-in-html-output-changed-in-rstudio-1-4/89925/2

One quick way of keeping the old style for your document is to use the old pandoc. See https://bookdown.org/yihui/rmarkdown-cookbook/install-pandoc.html

This is also a way to pin a specific Pandoc version within a document. You won't have access to bug fix and new Pandoc features, but this is the same as when you are pinning some R packages.

There would be another solution which is to export old style from Pandoc 2.7.3 and apply on the new Pandoc, but currently this is not easy with rmarkdown or other tool - we'll work on that. (Related to https://github.com/rstudio/rmarkdown/issues/2035)

Is it helping understanding the why ?

Thank you for your patience while we try to find the proper solution to avoid such thing in the future.

ycl6 commented 3 years ago

@garberadamc I also found out about this bug today. It happens to me when the pandoc version is 2.11.2 and 2.11.4 (latest). I remember it was fine sometime last year, so I tried the 2.10.1 (updated ~7 months ago) and the syntax highlight is now back to as before. I use conda, so it is quite easy to switch between different pandoc versions, you can give it a go.

edit: I set this gallery up to show the differences in the syntax highlightings before and after v2.11 for all supported styles.