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

前端 未结 9 1952
灰色年华
灰色年华 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 10:00

    Alternate solution

    Markdown allows HTML, so if you don't mind adding a bit of JS, you could do this:

    ## A section
    
    Here is some Ruby code.
    
    
      
        puts "hello"
      
    

    Then you could use Highlight.js (documentation here) to add highlighting based on that class.

    It's not an ideal solution, but it should work with any Markdown parser.

提交回复
热议问题