Using a different Markdown processor

There are a handful of Markdown processing libraries available for Ruby, each with different advantages and features. Since version 0.9.11, Nesta uses Ryan Tomayko's Tilt library to work out which processor to use when rendering a file within your content folder.

At the time of writing, Tilt knows about the following Markdown processors:

Tilt will try to load a Markdown processor in the order defined above. If it can't find Redcarpet, it'll try RDiscount, then Kramdown etc.

RDiscount is used in Nesta by default, as it is the only one that is included automatically as a Nesta dependency (i.e. it is the only one that is likely to be available in your project so Tilt is likely to find it first).

Installing other processors

To change the default (e.g. to Maruku), add your chosen processor's gem to your Gemfile and re-run bundle:

$ cd path/to/project
$ echo 'gem "maruku"' >> Gemfile
$ bundle

The other gems that you might want to install are called redcarpet and kramdown (the rdiscount gem is already installed).

Configuring Tilt

Then tell Tilt that you'd rather it used Maruku by adding the following line of Ruby code to the app.rb file within your project (if you don't have an app.rb file, just create it):

Tilt.register Tilt::MarukuTemplate, 'md'

The full list of class names that you might want to use in place of MarukuTemplate is:

  • Tilt::RedcarpetTemplate
  • Tilt::RDiscountTemplate
  • Tilt::KramdownTemplate
  • Tilt::MarukuTemplate

This post may go out of date as the Markdown processing support in Ruby evolves. You can always check the list of class names at the bottom of tilt.rb to review current options…