Skip to content

Commit

Permalink
Add Kramdown support and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Graham committed Nov 21, 2010
1 parent 53b9994 commit ac7a0cc
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 1 deletion.
4 changes: 4 additions & 0 deletions bin/jekyll
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions features/site_configuration.feature
Expand Up @@ -48,6 +48,13 @@ Feature: Site configuration
Then the _site directory should exist
And I should see "<a href="http://google.com">Google</a>" 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 "<a href="http://google.com">Google</a>" 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"
Expand Down
13 changes: 12 additions & 1 deletion lib/jekyll/converters/markdown.rb
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand All @@ -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'
Expand Down
1 change: 1 addition & 0 deletions test/helper.rb
Expand Up @@ -5,6 +5,7 @@

require 'RedCloth'
require 'rdiscount'
require 'kramdown'

require 'test/unit'
require 'redgreen'
Expand Down
11 changes: 11 additions & 0 deletions test/test_tags.rb
Expand Up @@ -112,5 +112,16 @@ def fill_post(code, override = {})
assert_match %r{<em>FINISH HIM</em>}, @result
end
end

context "using Kramdown" do
setup do
create_post(@content, 'markdown' => 'kramdown')
end

should "parse correctly" do
assert_match %r{<em>FIGHT!</em>}, @result
assert_match %r{<em>FINISH HIM</em>}, @result
end
end
end
end

0 comments on commit ac7a0cc

Please sign in to comment.