From 59080271ed5100ec9b72ce69d72c38bab0ced321 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Mon, 15 Dec 2008 12:16:35 -0800 Subject: [PATCH] allow use of rdiscount if --rdiscount is set and gem is installed --- History.txt | 1 + README.textile | 9 ++++++++- bin/jekyll | 10 ++++++++++ lib/jekyll.rb | 3 ++- lib/jekyll/convertible.rb | 2 +- 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/History.txt b/History.txt index 9d714ec5..2a220e00 100644 --- a/History.txt +++ b/History.txt @@ -1,6 +1,7 @@ == * Major Changes * Use Maruku (pure Ruby) for Markdown by default [github.com/mreid] + * Allow use of RDiscount with --rdiscount flag * Minor Enhancements * Don't load directory_watcher unless it's needed [github.com/pjhyett] diff --git a/README.textile b/README.textile index 75064b93..2352dd88 100644 --- a/README.textile +++ b/README.textile @@ -80,7 +80,7 @@ The best way to install Jekyll is via RubyGems: $ sudo gem install mojombo-jekyll -s http://gems.github.com/ Jekyll requires the gems `directory_watcher`, `liquid`, `open4`, -and `maruku` for markdown support. These are automatically +and `maruku` (for markdown support). These are automatically installed by the gem install command. Maruku comes with optional support for LaTeX to PNG rendering via @@ -123,6 +123,13 @@ during the conversion: $ jekyll --pygments +By default, Jekyll uses "Maruku":http://maruku.rubyforge.org (pure Ruby) for +Markdown support. If you'd like to use RDiscount (faster, but requires +compilation), you must install it (gem install rdiscount) and then you can +have it used instead: + + $ jekyll --rdiscount + h2. Data Jekyll traverses your site looking for files to process. Any files with YAML diff --git a/bin/jekyll b/bin/jekyll index 6b412c4c..acf8d56f 100755 --- a/bin/jekyll +++ b/bin/jekyll @@ -32,6 +32,16 @@ opts = OptionParser.new do |opts| opts.on("--pygments", "Use pygments to highlight code") do Jekyll.pygments = true end + + opts.on("--rdiscount", "Use rdiscount gem for Markdown") do + begin + require 'rdiscount' + Jekyll.markdown_proc = Proc.new { |x| RDiscount.new(x).to_html } + puts 'Using rdiscount for Markdown' + rescue LoadError + puts 'You must have the rdiscount gem installed first' + end + end end opts.parse! diff --git a/lib/jekyll.rb b/lib/jekyll.rb index 5bb23dc6..02e453e3 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -44,11 +44,12 @@ module Jekyll VERSION = '0.2.0' class << self - attr_accessor :source, :dest, :lsi, :pygments + attr_accessor :source, :dest, :lsi, :pygments, :markdown_proc end Jekyll.lsi = false Jekyll.pygments = false + Jekyll.markdown_proc = Proc.new { |x| Maruku.new(x).to_html } def self.process(source, dest) require 'classifier' if Jekyll.lsi diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb index 08bce9a3..2ab4c7ec 100644 --- a/lib/jekyll/convertible.rb +++ b/lib/jekyll/convertible.rb @@ -30,7 +30,7 @@ module Jekyll self.content = RedCloth.new(self.content).to_html when ".markdown": self.ext = ".html" - self.content = Maruku.new(self.content).to_html + self.content = Jekyll.markdown_proc.call(self.content) end end