allow use of rdiscount if --rdiscount is set and gem is installed

This commit is contained in:
Tom Preston-Werner 2008-12-15 12:16:35 -08:00
parent b0004e803a
commit 59080271ed
5 changed files with 22 additions and 3 deletions

View File

@ -1,6 +1,7 @@
== ==
* Major Changes * Major Changes
* Use Maruku (pure Ruby) for Markdown by default [github.com/mreid] * Use Maruku (pure Ruby) for Markdown by default [github.com/mreid]
* Allow use of RDiscount with --rdiscount flag
* Minor Enhancements * Minor Enhancements
* Don't load directory_watcher unless it's needed [github.com/pjhyett] * Don't load directory_watcher unless it's needed [github.com/pjhyett]

View File

@ -80,7 +80,7 @@ The best way to install Jekyll is via RubyGems:
$ sudo gem install mojombo-jekyll -s http://gems.github.com/ $ sudo gem install mojombo-jekyll -s http://gems.github.com/
Jekyll requires the gems `directory_watcher`, `liquid`, `open4`, 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. installed by the gem install command.
Maruku comes with optional support for LaTeX to PNG rendering via Maruku comes with optional support for LaTeX to PNG rendering via
@ -123,6 +123,13 @@ during the conversion:
$ jekyll --pygments $ 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 h2. Data
Jekyll traverses your site looking for files to process. Any files with YAML Jekyll traverses your site looking for files to process. Any files with YAML

View File

@ -32,6 +32,16 @@ opts = OptionParser.new do |opts|
opts.on("--pygments", "Use pygments to highlight code") do opts.on("--pygments", "Use pygments to highlight code") do
Jekyll.pygments = true Jekyll.pygments = true
end 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 end
opts.parse! opts.parse!

View File

@ -44,11 +44,12 @@ module Jekyll
VERSION = '0.2.0' VERSION = '0.2.0'
class << self class << self
attr_accessor :source, :dest, :lsi, :pygments attr_accessor :source, :dest, :lsi, :pygments, :markdown_proc
end end
Jekyll.lsi = false Jekyll.lsi = false
Jekyll.pygments = false Jekyll.pygments = false
Jekyll.markdown_proc = Proc.new { |x| Maruku.new(x).to_html }
def self.process(source, dest) def self.process(source, dest)
require 'classifier' if Jekyll.lsi require 'classifier' if Jekyll.lsi

View File

@ -30,7 +30,7 @@ module Jekyll
self.content = RedCloth.new(self.content).to_html self.content = RedCloth.new(self.content).to_html
when ".markdown": when ".markdown":
self.ext = ".html" self.ext = ".html"
self.content = Maruku.new(self.content).to_html self.content = Jekyll.markdown_proc.call(self.content)
end end
end end