Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax highlighting for Python chunks does not work

I'm trying to create notebooks in which I present the same algorithm written in R and Python. I can easily integrate the R and Python code in a Rmd file and then create a HTML output using the 'Knit HTML' button in RStudio. However the Python code is always displayed without syntax highlighting (not like in the example at https://github.com/yihui/knitr-examples/blob/master/023-engine-python.md). I have Andre Simon's highlight software installed and functioning on my computer (MacBook Pro Retina, MacOS X 10.9).

Currently, I have the following libraries installed in R: markdown 0.6.4, knitr 1.5.15, highr 0.3.1.

Any idea what could be the problem? Thanks for your help!.

like image 269
Simon Garnier Avatar asked Jan 05 '14 04:01

Simon Garnier


1 Answers

That is specific to the RStudio Markdown render, which did not enable syntax highlighting for code blocks that are not R or C++. RStudio uses highlight.js, and you can use your own version of highlight.js to highlight Python code. Or use other Markdown converters such as Pandoc.

like image 117
Yihui Xie Avatar answered Sep 23 '22 22:09

Yihui Xie