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

前端 未结 9 1947
灰色年华
灰色年华 2020-12-04 09:19

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

{% highlight bash %}
cd ~
{% endhighlight %}
9条回答
  •  感情败类
    2020-12-04 09:50

    So I ran into this problem as well and after banging my head around a lot of places finally realised with official redcarpet2 support in Jekyll this is pretty simple. Write this in your _config.yml

    # Conversion
    markdown: redcarpet
    highlighter: pygments
    redcarpet:
      extensions: ["no_intra_emphasis", "fenced_code_blocks", "autolink", "strikethrough", "superscript"]
    

    Make sure that you have pygments css file and it is included. THIS STEP IS IMPORTANT.

    You can read my blog post http://blog.championswimmer.in/2015/10/jekyllsyntax-highlighting-in-github-favoured-markdown-codeblocks/ for details.

提交回复
热议问题