Search code examples
jekyllgithub-flavored-markdownredcarpet

Jekyll + redcarpet line numbers


I set up a Jekyll blog and I have the following config for syntax highlighting.

markdown: redcarpet
highlighter: pygments

This allows me to add syntax highlighting like this:

```javascript
function blah(){

}
```

Is there any way to keep this format but add line numbers?


Solution

  • Out of the box Jekyll code highlight :

    {% highlight ruby linenos %}
    def foo
      puts 'foo'
    end
    {% endhighlight %}
    

    And no need to highlight with javascript. Just add pygments css.