Jekyll Pygments/Redcarpet Global Configs

1 min read Original article ↗

A Jekyll plugin that enables global configuration options for Pygments.

  • Add pygments_global_config.rb to my-jekyll-project/_plugins/.

  • Add Pygments options to _config.yml

markdown: redcarpet
pygments: true
pygments_options: ['lineanchors', 'linenos=table']
  • Write highlight tags or fenced code blocks and have the pygments_options passed in automatically.
{% highlight ruby %}
puts "Hello, world!"
{% endhighlight %}
'''ruby
puts "Hello, world!"
'''

instead of

{% highlight ruby linenos=table lineanchors %}
puts "Hello, world!"
{% endhighlight %}

or the inability to pass Pygments options into the fenced code block.