diff --git a/bin/jekyll b/bin/jekyll
index 62d88e1aa8c..2be69ade58c 100755
--- a/bin/jekyll
+++ b/bin/jekyll
@@ -56,6 +56,10 @@ opts = OptionParser.new do |opts|
options['markdown'] = 'rdiscount'
end
+ opts.on("--kramdown", "Use kramdown gem for Markdown") do
+ options['markdown'] = 'kramdown'
+ end
+
opts.on("--time [TIME]", "Time to generate the site for") do |time|
options['time'] = Time.parse(time)
end
diff --git a/features/site_configuration.feature b/features/site_configuration.feature
index 38a315aec2d..0681c2f5907 100644
--- a/features/site_configuration.feature
+++ b/features/site_configuration.feature
@@ -48,6 +48,13 @@ Feature: Site configuration
Then the _site directory should exist
And I should see "Google" in "_site/index.html"
+ Scenario: Use Kramdown 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 "kramdown"
+ 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/lib/jekyll/converters/markdown.rb b/lib/jekyll/converters/markdown.rb
index 317b1487e5b..a0ba3ee1e36 100644
--- a/lib/jekyll/converters/markdown.rb
+++ b/lib/jekyll/converters/markdown.rb
@@ -10,6 +10,15 @@ def setup
return if @setup
# Set the Markdown interpreter (and Maruku self.config, if necessary)
case @config['markdown']
+ when 'kramdown'
+ begin
+ require 'kramdown'
+
+ rescue LoadError
+ STDERR.puts 'You are missing a library required for Markdown. Please run:'
+ STDERR.puts ' $ [sudo] gem install kramdown'
+ raise FatalException.new("Missing dependency: kramdown")
+ end
when 'rdiscount'
begin
require 'rdiscount'
@@ -52,7 +61,7 @@ def setup
end
else
STDERR.puts "Invalid Markdown processor: #{@config['markdown']}"
- STDERR.puts " Valid options are [ maruku | rdiscount ]"
+ STDERR.puts " Valid options are [ maruku | rdiscount | kramdown ]"
raise FatalException.new("Invalid Markdown process: #{@config['markdown']}")
end
@setup = true
@@ -69,6 +78,8 @@ def output_ext(ext)
def convert(content)
setup
case @config['markdown']
+ when 'kramdown'
+ Kramdown::Document.new(content).to_html
when 'rdiscount'
RDiscount.new(content, *@rdiscount_extensions).to_html
when 'maruku'
diff --git a/test/helper.rb b/test/helper.rb
index 61636a4e51f..c426b2a0176 100644
--- a/test/helper.rb
+++ b/test/helper.rb
@@ -5,6 +5,7 @@
require 'RedCloth'
require 'rdiscount'
+require 'kramdown'
require 'test/unit'
require 'redgreen'
diff --git a/test/test_tags.rb b/test/test_tags.rb
index d25aa705fa5..3f25e5c2967 100644
--- a/test/test_tags.rb
+++ b/test/test_tags.rb
@@ -112,5 +112,16 @@ def fill_post(code, override = {})
assert_match %r{FINISH HIM}, @result
end
end
+
+ context "using Kramdown" do
+ setup do
+ create_post(@content, 'markdown' => 'kramdown')
+ end
+
+ should "parse correctly" do
+ assert_match %r{FIGHT!}, @result
+ assert_match %r{FINISH HIM}, @result
+ end
+ end
end
end