datacamp / rdocumentation-2.0

📚 RDocumentation provides an easy way to search the documentation for every version of every R package on CRAN and Bioconductor.
https://rdocumentation.org
MIT License
283 stars 43 forks source link

Add syntax highlighting for R code? #14

Open ncarchedi opened 3 years ago

ncarchedi commented 3 years ago

The easiest way to do this is probably via react-syntax-highlighter, but I couldn't find an existing theme that I felt matched the style of the rest of the site well enough: https://github.com/remarkjs/react-markdown#use-custom-renderers-syntax-highlight

nx10 commented 3 years ago

Thanks for your work!

Syntax highlighting would be very helpful. Here is a react-syntax-highlighter demo that lets you flip through common themes: https://react-syntax-highlighter.github.io/react-syntax-highlighter/demo/

There is a couple I like with other languages but not with R. It seems like the R grammar for highlight.js is not very expressive.

Nonetheless I find non-highlighted code hard to read quickly, so I think any theme would be helpful.