Search code examples
markdownjekyll

Jekyll: Fenced code blocks with line numbers


I'm trying to add line numbers to fenced code blocks in markdown with Jekyll.

I have tried using both kramdown and redcarpet and adding line_numbers: true to the _config.yml file (under the proper renderer config-block) but I can't seem to get line numbers on code blocks.

Solution: It turned out all I had to do was to switch back to kramdown (default markdown renderer) and start the code blocks with {% highlight <language> linenos %} and the code blocks gets line numbers.


Solution

  • I used this great post. It worked for me. As for the line numbers use,

    {% highlight <language> linenos %}
         <code>
     {% endhighlight %}
    

    Check an example on my blog and see if this is what you want.