From 606087986e6fe01c36e2ce695de367d6e4808139 Mon Sep 17 00:00:00 2001 From: Ryan Tomayko Date: Tue, 9 Mar 2010 08:56:01 -0800 Subject: [PATCH] fall back to BlueCloth if rdiscount isn't available --- bin/rocco | 5 +++++ lib/rocco.rb | 14 +++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/bin/rocco b/bin/rocco index 92bc820..4695b68 100755 --- a/bin/rocco +++ b/bin/rocco @@ -11,6 +11,11 @@ rescue LoadError warn "warn: #$!. trying again with rubygems" require 'rubygems' retry + else + require 'bluecloth' + Markdown = BlueCloth + $LOADED_FEATURES << 'rdiscount.rb' + retry end when /rocco/ if !$:.include?(libdir) diff --git a/lib/rocco.rb b/lib/rocco.rb index 3563735..87394fe 100644 --- a/lib/rocco.rb +++ b/lib/rocco.rb @@ -30,9 +30,17 @@ #### Prerequisites -# The [rdiscount](http://github.com/rtomayko/rdiscount) library is -# required for Markdown processing. -require 'rdiscount' +# We'll need a Markdown library. [RDiscount][rd], if we're lucky. Otherwise, +# issue a warning and fall back on using BlueCloth. +# +# [rd]: http://github.com/rtomayko/rdiscount +begin + require 'rdiscount' +rescue LoadError => boom + warn "warn: #{boom}. trying bluecloth" + require 'bluecloth' + Markdown = BlueCloth +end # We use [{{ mustache }}](http://defunkt.github.com/mustache/) for # templating.