Welcome to my Open Notebook

This is an Open Notebook with Selected Content - Delayed. All content is licenced with CC-BY. Find out more Here.

ONS-SCD.png

r-syntax-highlights-for-my-jekyll-powered-blog.md

Syntax Highlights

Until today I had no idea how to make code pretty in my blog posts which go to github after being first rendered locally so I can get the categories and tags.

Because github disables any plugins when it processes your blog I took Charlie Park’s advice. http://charliepark.org/jekyll-with-plugins/

This blog post solved it for me http://tuxette.nathalievilla.org/?p=1574

The trick is to write highlighter: pygments into the _config.yml and then:

% highlight r % # with curly braces
data("iris")
plot(iris$Sepal.Length ~ iris$Sepal.Width)
dat <- rnorm(1000,1,2)
% endhighlight % # with curly braces

Will render as:

data("iris")
plot(iris$Sepal.Length ~ iris$Sepal.Width)
dat <- rnorm(1000,1,2)

But I also pushed this to another site that I do use gh-pages to build and it sent me an email complaining:

You are attempting to use the 'pygments' highlighter, 
which is currently unsupported on GitHub Pages. 
Your site will use 'rouge' for highlighting instead. 
To suppress this warning, change the 'highlighter' value to 
'rouge' in your '_config.yml'. 

So there.

Posted in 


blog comments powered by Disqus