Moved out conversion logic
This commit is contained in:
parent
63cdd21353
commit
3bc497c1c9
|
@ -36,49 +36,7 @@ module Jekyll
|
||||||
|
|
||||||
def convert(content)
|
def convert(content)
|
||||||
setup
|
setup
|
||||||
case @config['markdown']
|
@parser.convert(content)
|
||||||
when 'redcarpet'
|
|
||||||
@redcarpet_extensions[:fenced_code_blocks] = !@redcarpet_extensions[:no_fenced_code_blocks]
|
|
||||||
@renderer.send :include, Redcarpet::Render::SmartyPants if @redcarpet_extensions[:smart]
|
|
||||||
markdown = Redcarpet::Markdown.new(@renderer.new(@redcarpet_extensions), @redcarpet_extensions)
|
|
||||||
markdown.render(content)
|
|
||||||
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'],
|
|
||||||
:smart_quotes => @config['kramdown']['smart_quotes'],
|
|
||||||
|
|
||||||
: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'],
|
|
||||||
:smart_quotes => @config['kramdown']['smart_quotes']
|
|
||||||
}).to_html
|
|
||||||
end
|
|
||||||
when 'rdiscount'
|
|
||||||
rd = RDiscount.new(content, *@rdiscount_extensions)
|
|
||||||
html = rd.to_html
|
|
||||||
if rd.generate_toc and html.include?(@config['rdiscount']['toc_token'])
|
|
||||||
html.gsub!(@config['rdiscount']['toc_token'], rd.toc_content.force_encoding('utf-8'))
|
|
||||||
end
|
|
||||||
html
|
|
||||||
when 'maruku'
|
|
||||||
Maruku.new(content).to_html
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,6 +10,34 @@ module Jekyll
|
||||||
STDERR.puts ' $ [sudo] gem install kramdown'
|
STDERR.puts ' $ [sudo] gem install kramdown'
|
||||||
raise FatalException.new("Missing dependency: kramdown")
|
raise FatalException.new("Missing dependency: kramdown")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def convert(content)
|
||||||
|
# Check for use of coderay
|
||||||
|
kramdown_configs = if @config['kramdown']['use_coderay']
|
||||||
|
base_kramdown_configs.merge({
|
||||||
|
: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']
|
||||||
|
})
|
||||||
|
else
|
||||||
|
# not using coderay
|
||||||
|
base_kramdown_configs
|
||||||
|
end
|
||||||
|
Kramdown::Document.new(content, kramdown_configs).to_html
|
||||||
|
end
|
||||||
|
|
||||||
|
def base_kramdown_configs
|
||||||
|
{
|
||||||
|
:auto_ids => @config['kramdown']['auto_ids'],
|
||||||
|
:footnote_nr => @config['kramdown']['footnote_nr'],
|
||||||
|
:entity_output => @config['kramdown']['entity_output'],
|
||||||
|
:toc_levels => @config['kramdown']['toc_levels'],
|
||||||
|
:smart_quotes => @config['kramdown']['smart_quotes']
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,6 +37,10 @@ module Jekyll
|
||||||
MaRuKu::Globals[:html_png_dir] = @config['maruku']['png_dir']
|
MaRuKu::Globals[:html_png_dir] = @config['maruku']['png_dir']
|
||||||
MaRuKu::Globals[:html_png_url] = @config['maruku']['png_url']
|
MaRuKu::Globals[:html_png_url] = @config['maruku']['png_url']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def convert(content)
|
||||||
|
Maruku.new(content).to_html
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,6 +11,15 @@ module Jekyll
|
||||||
STDERR.puts ' $ [sudo] gem install rdiscount'
|
STDERR.puts ' $ [sudo] gem install rdiscount'
|
||||||
raise FatalException.new("Missing dependency: rdiscount")
|
raise FatalException.new("Missing dependency: rdiscount")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def convert(content)
|
||||||
|
rd = RDiscount.new(content, *@rdiscount_extensions)
|
||||||
|
html = rd.to_html
|
||||||
|
if rd.generate_toc and html.include?(@config['rdiscount']['toc_token'])
|
||||||
|
html.gsub!(@config['rdiscount']['toc_token'], rd.toc_content.force_encoding('utf-8'))
|
||||||
|
end
|
||||||
|
html
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,6 +29,13 @@ module Jekyll
|
||||||
raise FatalException.new("Missing dependency: redcarpet")
|
raise FatalException.new("Missing dependency: redcarpet")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def convert(content)
|
||||||
|
@redcarpet_extensions[:fenced_code_blocks] = !@redcarpet_extensions[:no_fenced_code_blocks]
|
||||||
|
@renderer.send :include, Redcarpet::Render::SmartyPants if @redcarpet_extensions[:smart]
|
||||||
|
markdown = Redcarpet::Markdown.new(@renderer.new(@redcarpet_extensions), @redcarpet_extensions)
|
||||||
|
markdown.render(content)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue