Merge remote branch 'jasongraham/kramdown-support'
This commit is contained in:
commit
61acd47ed2
|
@ -5,6 +5,7 @@
|
||||||
* Add uri_escape filter (#234)
|
* Add uri_escape filter (#234)
|
||||||
* Add --base-url cli option (#235)
|
* Add --base-url cli option (#235)
|
||||||
* Improve MT migrator (#238)
|
* Improve MT migrator (#238)
|
||||||
|
* Add kramdown support (#239)
|
||||||
* Bug Fixes
|
* Bug Fixes
|
||||||
* Fixed filename basename generation (#208)
|
* Fixed filename basename generation (#208)
|
||||||
* Set mode to UTF8 on Sequel connections (#237)
|
* Set mode to UTF8 on Sequel connections (#237)
|
||||||
|
|
|
@ -56,6 +56,10 @@ opts = OptionParser.new do |opts|
|
||||||
options['markdown'] = 'rdiscount'
|
options['markdown'] = 'rdiscount'
|
||||||
end
|
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|
|
opts.on("--time [TIME]", "Time to generate the site for") do |time|
|
||||||
options['time'] = Time.parse(time)
|
options['time'] = Time.parse(time)
|
||||||
end
|
end
|
||||||
|
|
|
@ -48,6 +48,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 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
|
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"
|
||||||
|
|
|
@ -33,6 +33,7 @@ Gem::Specification.new do |s|
|
||||||
s.add_development_dependency('rr', [">= 4.2.1"])
|
s.add_development_dependency('rr', [">= 4.2.1"])
|
||||||
s.add_development_dependency('cucumber', [">= 4.2.1"])
|
s.add_development_dependency('cucumber', [">= 4.2.1"])
|
||||||
s.add_development_dependency('RedCloth', [">= 4.2.1"])
|
s.add_development_dependency('RedCloth', [">= 4.2.1"])
|
||||||
|
s.add_development_dependency('kramdown', [">= 0.12.0"])
|
||||||
|
|
||||||
# = MANIFEST =
|
# = MANIFEST =
|
||||||
s.files = %w[
|
s.files = %w[
|
||||||
|
|
|
@ -74,6 +74,22 @@ module Jekyll
|
||||||
},
|
},
|
||||||
'rdiscount' => {
|
'rdiscount' => {
|
||||||
'extensions' => []
|
'extensions' => []
|
||||||
|
},
|
||||||
|
'kramdown' => {
|
||||||
|
'auto_ids' => true,
|
||||||
|
'footnote_nr' => 1,
|
||||||
|
'entity_output' => 'as_char',
|
||||||
|
'toc_levels' => '1..6',
|
||||||
|
'use_coderay' => false,
|
||||||
|
|
||||||
|
'coderay' => {
|
||||||
|
'coderay_wrap' => 'div',
|
||||||
|
'coderay_line_numbers' => 'inline',
|
||||||
|
'coderay_line_number_start' => 1,
|
||||||
|
'coderay_tab_width' => 4,
|
||||||
|
'coderay_bold_every' => 10,
|
||||||
|
'coderay_css' => 'style'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,14 @@ 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 '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'
|
when 'rdiscount'
|
||||||
begin
|
begin
|
||||||
require 'rdiscount'
|
require 'rdiscount'
|
||||||
|
@ -52,7 +60,7 @@ module Jekyll
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
STDERR.puts "Invalid Markdown processor: #{@config['markdown']}"
|
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']}")
|
raise FatalException.new("Invalid Markdown process: #{@config['markdown']}")
|
||||||
end
|
end
|
||||||
@setup = true
|
@setup = true
|
||||||
|
@ -69,6 +77,31 @@ module Jekyll
|
||||||
def convert(content)
|
def convert(content)
|
||||||
setup
|
setup
|
||||||
case @config['markdown']
|
case @config['markdown']
|
||||||
|
when 'kramdown'
|
||||||
|
# Check for use of coderay
|
||||||
|
if @config['kramdown']['use_coderay']
|
||||||
|
Kramdown::Document.new(content, {
|
||||||
|
:auto_ids => @config['kramdown']['auto_ids'],
|
||||||
|
:footnote_nr => @config['kramdown']['footnote_nr'],
|
||||||
|
:entity_output => @config['kramdown']['entity_output'],
|
||||||
|
:toc_levels => @config['kramdown']['toc_levels'],
|
||||||
|
|
||||||
|
:coderay_wrap => @config['kramdown']['coderay']['coderay_wrap'],
|
||||||
|
:coderay_line_numbers => @config['kramdown']['coderay']['coderay_line_numbers'],
|
||||||
|
:coderay_line_number_start => @config['kramdown']['coderay']['coderay_line_number_start'],
|
||||||
|
:coderay_tab_width => @config['kramdown']['coderay']['coderay_tab_width'],
|
||||||
|
:coderay_bold_every => @config['kramdown']['coderay']['coderay_bold_every'],
|
||||||
|
:coderay_css => @config['kramdown']['coderay']['coderay_css']
|
||||||
|
}).to_html
|
||||||
|
else
|
||||||
|
# not using coderay
|
||||||
|
Kramdown::Document.new(content, {
|
||||||
|
:auto_ids => @config['kramdown']['auto_ids'],
|
||||||
|
:footnote_nr => @config['kramdown']['footnote_nr'],
|
||||||
|
:entity_output => @config['kramdown']['entity_output'],
|
||||||
|
:toc_levels => @config['kramdown']['toc_levels']
|
||||||
|
}).to_html
|
||||||
|
end
|
||||||
when 'rdiscount'
|
when 'rdiscount'
|
||||||
RDiscount.new(content, *@rdiscount_extensions).to_html
|
RDiscount.new(content, *@rdiscount_extensions).to_html
|
||||||
when 'maruku'
|
when 'maruku'
|
||||||
|
|
|
@ -5,6 +5,7 @@ require File.join(File.dirname(__FILE__), *%w[.. lib jekyll])
|
||||||
|
|
||||||
require 'RedCloth'
|
require 'RedCloth'
|
||||||
require 'rdiscount'
|
require 'rdiscount'
|
||||||
|
require 'kramdown'
|
||||||
|
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
require 'redgreen'
|
require 'redgreen'
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
require File.dirname(__FILE__) + '/helper'
|
||||||
|
|
||||||
|
class TestKramdown < Test::Unit::TestCase
|
||||||
|
context "kramdown" do
|
||||||
|
setup do
|
||||||
|
config = {
|
||||||
|
'markdown' => 'kramdown',
|
||||||
|
'kramdown' => {
|
||||||
|
'auto_ids' => false,
|
||||||
|
'footnote_nr' => 1,
|
||||||
|
'entity_output' => 'as_char',
|
||||||
|
'toc_levels' => '1..6'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@markdown = MarkdownConverter.new config
|
||||||
|
end
|
||||||
|
|
||||||
|
# http://kramdown.rubyforge.org/converter/html.html#options
|
||||||
|
should "pass kramdown options" do
|
||||||
|
assert_equal "<h1>Some Header</h1>", @markdown.convert('# Some Header #').strip
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -112,5 +112,16 @@ CONTENT
|
||||||
assert_match %r{<em>FINISH HIM</em>}, @result
|
assert_match %r{<em>FINISH HIM</em>}, @result
|
||||||
end
|
end
|
||||||
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue