Notes

How to use Redcarpet for syntax highlighting in Jekyll

Edit on GitHub

Jekyll

why?

  • because i don’t wanna use liquid tags. i want to keep my posts in pure markdown in case i need to switch platforms or use the posts elsewhere
  • because Github uses Redcarpet for rendering .md content
  • because it supports fenced code blocks.
  • because it makes working with imported/exported sites easy

install

1sudo gem install redcarpet

configuration

In your _config.yml file, add the entry for redcarpet and update the value for markdown.

 1markdown: redcarpet
 2
 3redcarpet:
 4  extension: [
 5    "no_intra_emphasis",
 6    "tables",
 7    "autolink",
 8    "strikethrough",
 9    "with_toc_data",
10    "fenced_code_blocks", # ```javascript ```
11    "highlight", # ==highlight==
12    "superscript", # 2^(nd)
13    "footnotes", # [^somesamplefootnote]
14
15  ]