johnmuhl / radiant-markdown-extension

[DEPRECATED] A clone of the Radiant Markdown extension using RDiscount.

This URL has Read+Write access

radiant-markdown-extension / README.md
100644 51 lines (32 sloc) 3.656 kb

This branch is not really experimental, but be warned that peg-markdown currently leaks memory. This means really big pages will never render and will immediately send your server into meltdown. With smaller pages it takes a while to get to the breaking point.

Requirements

You need to have the RPeg gem installed.

gem install rpeg-markdown

Demonstration

BlueCloth vs. RPeg

More important than the speed gain in RPeg is the level of conversion accuracy, for example compare the very last test, my un-official and admittedly narrow "bold two digit number test". Nowhere in that span of numbers should you see an actual *. If you're never doing any Markdown that confuses BlueCloth and just care about rendering big spans of Markdown you'll have to install it for yourself and see how much faster it really is. One thing is definite, it is faster; which becomes more apparent the larger the span of Markdown you have to convert. Just to give you some idea, I consistently see results of 4 seconds (BlueCloth) vs. 1 second (RPeg) to render the entire demo page.

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 but nothing bad happens if you feel like running them.

If you don't see the (RPeg) label at the end of the extension description in the Extensions tab you're most likely running 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 (RPeg) label in the Extensions tab.

Everything else

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 RPeg 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.

RPeg brings Peg'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. Installing it will automatically override the built-in (BlueCloth) Markdown so you don't need to change the filter on your pages. You can tell the extension is properly installed when you see (RPeg) at the end of the extension description in the Extensions tab of the admin interface.

Known Differences

Refer to the Inconsistencies and Enhancements pages (and feel free to add any you find)