syntax-highlightingmarkdownjekyllredcarpet

Syntax highlighting markdown code blocks in Jekyll (without using liquid tags)


It seems like syntax highlighting in Jekyll is limited to using liquid tags and pygments like so:

{% highlight bash %}
cd ~
{% endhighlight %}

But I've imported my existing blog from wordpress and it was written in markdown (using markdown code blocks) and I don't want to have to go through each post and fix the code blocks. Also, I want to keep my posts in pure markdown format in case I ever need to switch blogging platforms again.

I switched my Jekyll parser to redcarpet with the hope that I could use this markdown syntax:

```bash
cd ~
```

But it doesn't seem to work. It just wraps it in a normal code block. Any ideas?


Solution

  • I ended up switching to kramdown to parse markdown which comes with coderay for syntax highlighting. This has the benefit of being a pure ruby solution which works on heroku.