The syntax highlighting is provided by pandoc.
$ pandoc --list-highlight-styles
pygments
tango
espresso
zenburn
kate
monochrome
breezedark
haddock
To see which one you'd like to modify, Garrick Aden-Buie has a convenient blog post that displays all the options.
According to the pandoc manual, you can export a JSON config file from one of the available styles for customization:
pandoc --print-highlight-style pygments > my.theme
Note that this requires pandoc 2 (at the very least the above command failed when I tried to run it with pandoc 1.19.2.4).
After customizing the style file, you can pass it to pandoc via the rmarkdown package using the argument pandoc_args, e.g.
---
output:
html_document:
pandoc_args: "--highlight-style=my.theme"
---
And actually unfortunately I can't get that to work. The rmarkdown code by default sets the pandoc flag --no-highlight so that it can instead use highlight.js. Setting the argument highlight to be NULL similarly causes it to set --no-highlight.
I tried tricking rmarkdown by specifying a dummy theme. This prevented the addition of the --no-highlight flag, but unfortunately it adds --highlight-style=tango after --highlight-style=my.theme, which then overrides the custom style.
---
output:
html_document:
highlight: tango
pandoc_args: "--highlight-style=my.theme"
---
The relevant function is pandoc_html_highlight_args.
Thus the two main options I see to use a custom syntax style are:
- Send a Pull Request to update
pandoc_html_highlight_args to allow the use of a custom syntax style file
- Have rmarkdown export a Markdown file, and then run pandoc yourself manually with the exact flags you want (you can copy-paste the pandoc command output by
rmarkdown::render and modify it)