diff --git a/bin/jekyll b/bin/jekyll index c025a623..b81ba73e 100755 --- a/bin/jekyll +++ b/bin/jekyll @@ -82,6 +82,10 @@ opts = OptionParser.new do |opts| opts.on("--rdiscount", "Use rdiscount gem for Markdown") do options['markdown'] = 'rdiscount' end + + opts.on("--redcarpet", "Use redcarpet gem for Markdown") do + options['markdown'] = 'redcarpet' + end opts.on("--kramdown", "Use kramdown gem for Markdown") do options['markdown'] = 'kramdown' diff --git a/features/site_configuration.feature b/features/site_configuration.feature index 0681c2f5..8d3bee5d 100644 --- a/features/site_configuration.feature +++ b/features/site_configuration.feature @@ -55,6 +55,13 @@ Feature: Site configuration Then the _site directory should exist And I should see "Google" in "_site/index.html" + Scenario: Use Redcarpet for markup + Given I have an "index.markdown" page that contains "[Google](http://google.com)" + And I have a configuration file with "markdown" set to "redcarpet" + When I run jekyll + Then the _site directory should exist + And I should see "Google" in "_site/index.html" + Scenario: Use Maruku for markup Given I have an "index.markdown" page that contains "[Google](http://google.com)" And I have a configuration file with "markdown" set to "maruku" diff --git a/jekyll.gemspec b/jekyll.gemspec index 2bb856f0..66dd8c2f 100644 --- a/jekyll.gemspec +++ b/jekyll.gemspec @@ -36,7 +36,8 @@ Gem::Specification.new do |s| s.add_development_dependency('cucumber', ">= 0.10.0") s.add_development_dependency('RedCloth', ">= 4.2.1") s.add_development_dependency('rdiscount', ">= 1.6.5") - + s.add_development_dependency('redcarpet', ">= 1.9.0") + # = MANIFEST = s.files = %w[ History.txt diff --git a/lib/jekyll.rb b/lib/jekyll.rb index 65bdd7fe..7b1964fb 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -76,6 +76,9 @@ module Jekyll 'rdiscount' => { 'extensions' => [] }, + 'redcarpet' => { + 'extensions' => [] + }, 'kramdown' => { 'auto_ids' => true, 'footnote_nr' => 1, diff --git a/lib/jekyll/converters/markdown.rb b/lib/jekyll/converters/markdown.rb index 00c56d7c..2721f02c 100644 --- a/lib/jekyll/converters/markdown.rb +++ b/lib/jekyll/converters/markdown.rb @@ -10,6 +10,15 @@ module Jekyll 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' @@ -77,6 +86,8 @@ module Jekyll 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'] diff --git a/test/helper.rb b/test/helper.rb index c426b2a0..80825c07 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -6,6 +6,7 @@ require File.join(File.dirname(__FILE__), *%w[.. lib jekyll]) require 'RedCloth' require 'rdiscount' require 'kramdown' +require 'redcarpet' require 'test/unit' require 'redgreen' diff --git a/test/test_redcarpet.rb b/test/test_redcarpet.rb new file mode 100644 index 00000000..1359c449 --- /dev/null +++ b/test/test_redcarpet.rb @@ -0,0 +1,21 @@ +require File.dirname(__FILE__) + '/helper' + +class TestRedcarpet < Test::Unit::TestCase + context "redcarpet" do + setup do + config = { + 'redcarpet' => { 'extensions' => ['smart'] }, + 'markdown' => 'redcarpet' + } + @markdown = MarkdownConverter.new config + end + + should "pass redcarpet options" do + assert_equal "

Some Header

", @markdown.convert('# Some Header #').strip + end + + should "pass redcarpet extensions" do + assert_equal "

“smart”

", @markdown.convert('"smart"').strip + end + end +end diff --git a/test/test_tags.rb b/test/test_tags.rb index 3f25e5c2..c3c19a83 100644 --- a/test/test_tags.rb +++ b/test/test_tags.rb @@ -123,5 +123,16 @@ CONTENT assert_match %r{FINISH HIM}, @result end end + + context "using Redcarpet" do + setup do + create_post(@content, 'markdown' => 'redcarpet') + end + + should "parse correctly" do + assert_match %r{FIGHT!}, @result + assert_match %r{FINISH HIM}, @result + end + end end end