Markdown and syntax highlighting

2018-03-26

Jekyll and escape sequences can be strange.

With Github Flavored Markdown, it is possible to set syntax highlighting in fenced code blocks like so:

{% raw %} haskell putStrln "Hello World!" {% endraw %}

But what about code blocks that are made up using four initial spaces on each line? Like so:

 print "bar" 
. The only option is to add {% raw %}{% highlight haskell %}{% endraw %}and{% raw %}{% endhighlight %}{% endraw %}` after:

{% highlight python %} print "bar {% endhighlight %}

Blocks of code are either fenced by lines with three back-ticks `, or are indented with four spaces. I recommend only using the fenced code blocks -- they're easier and only they support syntax highlighting. -- Markdown Cheatsheet

You can check out the source code of this blog post also.

Sidenote: Make sure to keep your post in UTF-8 format or Jekyll might spaz out.

References