Merge remote-tracking branch 'MattHall/redcarpet'

This commit is contained in:
Tom Preston-Werner 2011-05-29 21:38:34 -07:00
commit 2ad0fbc8ff
8 changed files with 60 additions and 1 deletions

View File

@ -83,6 +83,10 @@ opts = OptionParser.new do |opts|
options['markdown'] = 'rdiscount' options['markdown'] = 'rdiscount'
end end
opts.on("--redcarpet", "Use redcarpet gem for Markdown") do
options['markdown'] = 'redcarpet'
end
opts.on("--kramdown", "Use kramdown gem for Markdown") do opts.on("--kramdown", "Use kramdown gem for Markdown") do
options['markdown'] = 'kramdown' options['markdown'] = 'kramdown'
end end

View File

@ -55,6 +55,13 @@ Feature: Site configuration
Then the _site directory should exist Then the _site directory should exist
And I should see "<a href="http://google.com">Google</a>" in "_site/index.html" And I should see "<a href="http://google.com">Google</a>" 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 "<a href="http://google.com">Google</a>" in "_site/index.html"
Scenario: Use Maruku for markup Scenario: Use Maruku for markup
Given I have an "index.markdown" page that contains "[Google](http://google.com)" Given I have an "index.markdown" page that contains "[Google](http://google.com)"
And I have a configuration file with "markdown" set to "maruku" And I have a configuration file with "markdown" set to "maruku"

View File

@ -35,6 +35,7 @@ Gem::Specification.new do |s|
s.add_development_dependency('cucumber', ">= 0.10.0") s.add_development_dependency('cucumber', ">= 0.10.0")
s.add_development_dependency('RedCloth', ">= 4.2.1") s.add_development_dependency('RedCloth', ">= 4.2.1")
s.add_development_dependency('rdiscount', ">= 1.6.5") s.add_development_dependency('rdiscount', ">= 1.6.5")
s.add_development_dependency('redcarpet', ">= 1.9.0")
# = MANIFEST = # = MANIFEST =
s.files = %w[ s.files = %w[

View File

@ -76,6 +76,9 @@ module Jekyll
'rdiscount' => { 'rdiscount' => {
'extensions' => [] 'extensions' => []
}, },
'redcarpet' => {
'extensions' => []
},
'kramdown' => { 'kramdown' => {
'auto_ids' => true, 'auto_ids' => true,
'footnote_nr' => 1, 'footnote_nr' => 1,

View File

@ -10,6 +10,15 @@ module Jekyll
return if @setup return if @setup
# Set the Markdown interpreter (and Maruku self.config, if necessary) # Set the Markdown interpreter (and Maruku self.config, if necessary)
case @config['markdown'] 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' when 'kramdown'
begin begin
require 'kramdown' require 'kramdown'
@ -77,6 +86,8 @@ module Jekyll
def convert(content) def convert(content)
setup setup
case @config['markdown'] case @config['markdown']
when 'redcarpet'
Redcarpet.new(content, *@redcarpet_extensions).to_html
when 'kramdown' when 'kramdown'
# Check for use of coderay # Check for use of coderay
if @config['kramdown']['use_coderay'] if @config['kramdown']['use_coderay']

View File

@ -6,6 +6,7 @@ require 'jekyll'
require 'RedCloth' require 'RedCloth'
require 'rdiscount' require 'rdiscount'
require 'kramdown' require 'kramdown'
require 'redcarpet'
require 'redgreen' if RUBY_VERSION < '1.9' require 'redgreen' if RUBY_VERSION < '1.9'
require 'shoulda' require 'shoulda'

21
test/test_redcarpet.rb Normal file
View File

@ -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 "<h1>Some Header</h1>", @markdown.convert('# Some Header #').strip
end
should "pass redcarpet extensions" do
assert_equal "<p>&ldquo;smart&rdquo;</p>", @markdown.convert('"smart"').strip
end
end
end

View File

@ -125,5 +125,16 @@ CONTENT
assert_match %r{<em>FINISH HIM</em>}, @result assert_match %r{<em>FINISH HIM</em>}, @result
end end
end end
context "using Redcarpet" do
setup do
create_post(@content, 'markdown' => 'redcarpet')
end
should "parse correctly" do
assert_match %r{<em>FIGHT!</em>}, @result
assert_match %r{<em>FINISH HIM</em>}, @result
end
end
end end
end end