Radiant Markdown Extension
What’s the point?
I needed an implementation of Markdown that followed the full syntax, and did so consistently. For example, in BlueCloth **1%** yields the HTML <em>*1%*</em> however, in RDiscount it correctly yields <strong>1%</strong>.
Eventually you get tired of explaining to clients that even though they typed it in exactly right the content management system you provided them doesn’t understand it, and instead they need to type out the actual HTML.
And SmartyPants?
RDiscount brings Discount’s C implementation of SmartyPants built in so there is no need to rely on RubyPants. In practical terms that means if you have pages using just the SmaryPants filter you will need to change them to the Markdown filter or install the standalone SmartyPants extension.
Usage
Installing the new Markdown Extension will automatically override the built-in (BlueCloth) Markdown so you won’t need to change the filter on your pages. You can tell the extension is properly installed when you see (RDiscount) at the end of the extension description in the Extensions tab of the admin interface.
Requirements
You must have the RDiscount gem installed on your server.
gem install rdiscount
Installation
You can either git clone from github or download and unpack a taball into your vendor/extensions folder, then restart your server. There are no rake tasks necessary.
If you don’t see the (RDiscount) label at the end of the extension description in the Extensions tab you're most likely running Radiant version 0.6.7 or lower. In those versions of Radiant, the default extensions are loaded before custom ones with the same name; you'll need to make a trivial change to the initializer.rb file in radiant/lib/radiant.
# change line 24 from
paths = [RADIANT_ROOT + '/vendor/extensions', RAILS_ROOT + '/vendor/extensions'].uniq
# to
paths = [RAILS_ROOT + '/vendor/extensions', RADIANT_ROOT + '/vendor/extensions'].uniq
You'll need to restart your server again, but after that you should see the (RDiscount) label in the Extensions tab.
If you have any trouble installing or using the extension feel free to drop me a line.
Demonstration
For me it the conversion accuracy was more important than the speed gain. However, if you're never doing any Markdown that confuses BlueCloth and just care about rendering big spans of Markdown you'll probably have to install it for yourself to see exactly how much faster it really is.
The difference in speed becomes more apparent the larger the span of Markdown you have to convert. For example, the BlueCloth version of the demo page takes around 4 seconds to render while the RDiscount version is consistently rendered in less than 1 second; whatever the exact numbers it’s clear that on large spans of Markdown the RDiscount version is noticeably faster.