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?
Many Markdown processors support syntax highlighting for fenced code blocks. This feature allows you to add color highlighting for whatever language your code was written in. To add syntax highlighting, specify a language next to the backticks before the fenced code block.
To format a code block in Markdown, indent every line of the block by at least four spaces. An indented code block cannot interrupt a paragraph, so you must insert at least one blank line between a paragraph the indented code block that follows.
By default, Jekyll uses the kramdown Markdown processor with stock settings, but you can enable other kramdown options or even switch Jekyll to another Markdown processor. See the Jekyll Markdown configuration options documentation for more information.
Embedding Code in Markdown. If you're writing your code in markdown, the easiest way to embed snippets is to use "fenced code blocks", which also allows syntax highlighting. For examples in practice, see this assemble boilerplate for markdown projects, in particular take a look at the code in these templates.
Fenced blocks were introduced with Redcarpet 2. Jekyll now supports Redcarpet 2.
As an aside I am using Redcarpet with Rouge until Kramdown support is available.
In addition some people prefer Nanoc to Jekyll.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With