lib/jekyll/converters/markdown.rb in jekyll-0.10.0 vs lib/jekyll/converters/markdown.rb in jekyll-0.11.0

- old
+ new

@@ -8,10 +8,19 @@ def setup return if @setup # Set the Markdown interpreter (and Maruku self.config, if necessary) case @config['markdown'] + when 'redcarpet' + begin + require 'redcarpet' + @redcarpet_extensions = @config['redcarpet']['extensions'].map { |e| e.to_sym } + rescue LoadError + STDERR.puts 'You are missing a library required for Markdown. Please run:' + STDERR.puts ' $ [sudo] gem install redcarpet' + raise FatalException.new("Missing dependency: redcarpet") + end when 'kramdown' begin require 'kramdown' rescue LoadError STDERR.puts 'You are missing a library required for Markdown. Please run:' @@ -63,21 +72,24 @@ STDERR.puts " Valid options are [ maruku | rdiscount | kramdown ]" raise FatalException.new("Invalid Markdown process: #{@config['markdown']}") end @setup = true end - + def matches(ext) - ext =~ /(markdown|mkdn?|md)/i + rgx = '(' + @config['markdown_ext'].gsub(',','|') +')' + ext =~ Regexp.new(rgx, Regexp::IGNORECASE) end def output_ext(ext) ".html" end def convert(content) setup case @config['markdown'] + when 'redcarpet' + Redcarpet.new(content, *@redcarpet_extensions).to_html when 'kramdown' # Check for use of coderay if @config['kramdown']['use_coderay'] Kramdown::Document.new(content, { :auto_ids => @config['kramdown']['auto_ids'],