Code fenced blocks, Pygments and line numbers with jekyll

Update: With the Jekyll v1 release, the old plugin broke, so now you can find in this page the new code. While waiting for an official commit/pull request, you can stick with this fix or, if you are using an older version of Jekyll, you can use the old plugin

When I started this personal blog project, the first feature I wanted was code highlighting. Markdown with Pygments is the right man for the job, and Jekyll has nice support, so I began writing some code.

The first problem I meet was using Pygments with code fenced blocks (did someone say three backticks?). Using something like {% highlight ruby %} is not my style, but switching rendering engine to redcarpet solved the problem at a glance.

Read the rest of this post →