Tal Galili requested in the R-help mailing list for a SyntaxHighlighter brush for the R language, so that Wordpress users can highlight their R code easily. I promised to contribute a few minutes on this task, and here is the result:
Hopefully Tal can persuade the Wordpress.com manager to add support for R syntax highlighting, so these users do not need to worry much about the installation and configuration. For Wordpress users, there are a couple of choices to make use of SyntaxHighlighter, e.g. the SyntaxHighlighter Evolved plugin, but I find this plugin somehow out-dated because it is still using an old version of SyntaxHighlighter, and it looks not easy to add support for new languages. Therefore I decided not to use any Wordpress plugins, but to manually add the necessary HTML code in my header and footer; this approach works for any HTML pages.
You need to upload the latest version (3.0.83) of SyntaxHighlighter somewhere first (of course, with the R brush shBrushR.js added in the scripts directory), change the following paths accordingly and insert them before the <body> tag in your HTML page:
Then add these lines in the footer area (right before the </body> tag):
Above is only my configuration; you may refer to the manual of SyntaxHighlighter for more information. To add those HTML code in your pages, you may modify the theme files (typically the header.php and footer.php). To make use of highlighting, you need to assign a special CSS class to your <pre> tag, e.g.
You may double-click on the code to select all of them, and copy them with normally (e.g. with Ctrl + C). The old version of SyntaxHighlighter uses a Flash file to copy the code to the clipboard and you have to select the line numbers as well when you only want to select the code; I do not like these features.
Finally, the JS brush file can be improved in a few aspects but in fact I’m not quite good at JS RegExp, so I leave these possible improvements to the readers:
- highlight the function arguments – loosely speaking, the pattern is: they are in parentheses
()followed by=; the first argument follows(and others follow,. - highlight the variables – those strings followed by
<-or=when=is not in paretheses.
Donate
As a freelancer (currently working as a contractor) and a dad of three kids, I truly appreciate your donation to support my writing and open-source software development! Your contribution helps me cope with financial uncertainty better, so I can spend more time on producing high-quality content and software. You can make a donation through methods below.
-
Venmo:
@yihui_xie, or Zelle:[email protected] -
Paypal
-
If you have a Paypal account, you can follow the link https://paypal.me/YihuiXie or find me on Paypal via my email
[email protected]. Please choose the payment type as “Family and Friends” (instead of “Goods and Services”) to avoid extra fees. -
If you don’t have Paypal, you may donate through this link via your debit or credit card. Paypal will charge a fee on my side.
-
-
Other ways:
WeChat Pay (微信支付:谢益辉) Alipay (支付宝:谢益辉) 

When sending money, please be sure to add a note “gift” or “donation” if possible, so it won’t be treated as my taxable income but a genuine gift. Needless to say, donation is completely voluntary and I appreciate any amount you can give.
Please feel free to email me if you prefer a different way to give. Thank you very much!
I’ll give back a significant portion of the donations to the open-source community and charities. For the record, I received about $30,000 in total (before tax) in 2024-25, and gave back about $15,000 (after tax).