Update converter classes moving into a module
This commit is contained in:
parent
6514fe2d22
commit
663a1321d2
|
@ -1,5 +1,4 @@
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
|
||||||
class Converter < Plugin
|
class Converter < Plugin
|
||||||
# Public: Get or set the pygments prefix. When an argument is specified,
|
# Public: Get or set the pygments prefix. When an argument is specified,
|
||||||
# the prefix will be set. If no argument is specified, the current prefix
|
# the prefix will be set. If no argument is specified, the current prefix
|
||||||
|
@ -46,5 +45,4 @@ module Jekyll
|
||||||
self.class.pygments_suffix
|
self.class.pygments_suffix
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -1,22 +1,21 @@
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
module Converters
|
||||||
|
class Identity < Converter
|
||||||
|
safe true
|
||||||
|
|
||||||
class IdentityConverter < Converter
|
priority :lowest
|
||||||
safe true
|
|
||||||
|
|
||||||
priority :lowest
|
def matches(ext)
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
def matches(ext)
|
def output_ext(ext)
|
||||||
true
|
ext
|
||||||
|
end
|
||||||
|
|
||||||
|
def convert(content)
|
||||||
|
content
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def output_ext(ext)
|
|
||||||
ext
|
|
||||||
end
|
|
||||||
|
|
||||||
def convert(content)
|
|
||||||
content
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,149 +1,149 @@
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
module Converters
|
||||||
|
class Markdown < Converter
|
||||||
|
safe true
|
||||||
|
|
||||||
class MarkdownConverter < Converter
|
pygments_prefix "\n"
|
||||||
safe true
|
pygments_suffix "\n"
|
||||||
|
|
||||||
pygments_prefix "\n"
|
def setup
|
||||||
pygments_suffix "\n"
|
return if @setup
|
||||||
|
case @config['markdown']
|
||||||
|
when 'redcarpet'
|
||||||
|
begin
|
||||||
|
require 'redcarpet'
|
||||||
|
|
||||||
def setup
|
@renderer ||= Class.new(Redcarpet::Render::HTML) do
|
||||||
return if @setup
|
def block_code(code, lang)
|
||||||
case @config['markdown']
|
lang = lang && lang.split.first || "text"
|
||||||
when 'redcarpet'
|
output = add_code_tags(
|
||||||
begin
|
Pygments.highlight(code, :lexer => lang, :options => { :encoding => 'utf-8' }),
|
||||||
require 'redcarpet'
|
lang
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
@renderer ||= Class.new(Redcarpet::Render::HTML) do
|
def add_code_tags(code, lang)
|
||||||
def block_code(code, lang)
|
code = code.sub(/<pre>/,'<pre><code class="' + lang + '">')
|
||||||
lang = lang && lang.split.first || "text"
|
code = code.sub(/<\/pre>/,"</code></pre>")
|
||||||
output = add_code_tags(
|
end
|
||||||
Pygments.highlight(code, :lexer => lang, :options => { :encoding => 'utf-8' }),
|
|
||||||
lang
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_code_tags(code, lang)
|
@redcarpet_extensions = {}
|
||||||
code = code.sub(/<pre>/,'<pre><code class="' + lang + '">')
|
@config['redcarpet']['extensions'].each { |e| @redcarpet_extensions[e.to_sym] = true }
|
||||||
code = code.sub(/<\/pre>/,"</code></pre>")
|
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'
|
||||||
|
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'
|
||||||
|
@rdiscount_extensions = @config['rdiscount']['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 rdiscount'
|
||||||
|
raise FatalException.new("Missing dependency: rdiscount")
|
||||||
|
end
|
||||||
|
when 'maruku'
|
||||||
|
begin
|
||||||
|
require 'maruku'
|
||||||
|
|
||||||
|
if @config['maruku']['use_divs']
|
||||||
|
require 'maruku/ext/div'
|
||||||
|
STDERR.puts 'Maruku: Using extended syntax for div elements.'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if @config['maruku']['use_tex']
|
||||||
|
require 'maruku/ext/math'
|
||||||
|
STDERR.puts "Maruku: Using LaTeX extension. Images in `#{@config['maruku']['png_dir']}`."
|
||||||
|
|
||||||
|
# Switch off MathML output
|
||||||
|
MaRuKu::Globals[:html_math_output_mathml] = false
|
||||||
|
MaRuKu::Globals[:html_math_engine] = 'none'
|
||||||
|
|
||||||
|
# Turn on math to PNG support with blahtex
|
||||||
|
# Resulting PNGs stored in `images/latex`
|
||||||
|
MaRuKu::Globals[:html_math_output_png] = true
|
||||||
|
MaRuKu::Globals[:html_png_engine] = @config['maruku']['png_engine']
|
||||||
|
MaRuKu::Globals[:html_png_dir] = @config['maruku']['png_dir']
|
||||||
|
MaRuKu::Globals[:html_png_url] = @config['maruku']['png_url']
|
||||||
|
end
|
||||||
|
rescue LoadError
|
||||||
|
STDERR.puts 'You are missing a library required for Markdown. Please run:'
|
||||||
|
STDERR.puts ' $ [sudo] gem install maruku'
|
||||||
|
raise FatalException.new("Missing dependency: maruku")
|
||||||
end
|
end
|
||||||
|
|
||||||
@redcarpet_extensions = {}
|
|
||||||
@config['redcarpet']['extensions'].each { |e| @redcarpet_extensions[e.to_sym] = true }
|
|
||||||
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'
|
|
||||||
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'
|
|
||||||
@rdiscount_extensions = @config['rdiscount']['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 rdiscount'
|
|
||||||
raise FatalException.new("Missing dependency: rdiscount")
|
|
||||||
end
|
|
||||||
when 'maruku'
|
|
||||||
begin
|
|
||||||
require 'maruku'
|
|
||||||
|
|
||||||
if @config['maruku']['use_divs']
|
|
||||||
require 'maruku/ext/div'
|
|
||||||
STDERR.puts 'Maruku: Using extended syntax for div elements.'
|
|
||||||
end
|
|
||||||
|
|
||||||
if @config['maruku']['use_tex']
|
|
||||||
require 'maruku/ext/math'
|
|
||||||
STDERR.puts "Maruku: Using LaTeX extension. Images in `#{@config['maruku']['png_dir']}`."
|
|
||||||
|
|
||||||
# Switch off MathML output
|
|
||||||
MaRuKu::Globals[:html_math_output_mathml] = false
|
|
||||||
MaRuKu::Globals[:html_math_engine] = 'none'
|
|
||||||
|
|
||||||
# Turn on math to PNG support with blahtex
|
|
||||||
# Resulting PNGs stored in `images/latex`
|
|
||||||
MaRuKu::Globals[:html_math_output_png] = true
|
|
||||||
MaRuKu::Globals[:html_png_engine] = @config['maruku']['png_engine']
|
|
||||||
MaRuKu::Globals[:html_png_dir] = @config['maruku']['png_dir']
|
|
||||||
MaRuKu::Globals[:html_png_url] = @config['maruku']['png_url']
|
|
||||||
end
|
|
||||||
rescue LoadError
|
|
||||||
STDERR.puts 'You are missing a library required for Markdown. Please run:'
|
|
||||||
STDERR.puts ' $ [sudo] gem install maruku'
|
|
||||||
raise FatalException.new("Missing dependency: maruku")
|
|
||||||
end
|
|
||||||
else
|
|
||||||
STDERR.puts "Invalid Markdown processor: #{@config['markdown']}"
|
|
||||||
STDERR.puts " Valid options are [ maruku | rdiscount | kramdown ]"
|
|
||||||
raise FatalException.new("Invalid Markdown process: #{@config['markdown']}")
|
|
||||||
end
|
|
||||||
@setup = true
|
|
||||||
end
|
|
||||||
|
|
||||||
def matches(ext)
|
|
||||||
rgx = '(' + @config['markdown_ext'].gsub(',','|') +')'
|
|
||||||
ext =~ Regexp.new(rgx, Regexp::IGNORECASE)
|
|
||||||
end
|
|
||||||
|
|
||||||
def output_ext(ext)
|
|
||||||
".html"
|
|
||||||
end
|
|
||||||
|
|
||||||
def convert(content)
|
|
||||||
setup
|
|
||||||
case @config['markdown']
|
|
||||||
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
|
else
|
||||||
# not using coderay
|
STDERR.puts "Invalid Markdown processor: #{@config['markdown']}"
|
||||||
Kramdown::Document.new(content, {
|
STDERR.puts " Valid options are [ maruku | rdiscount | kramdown ]"
|
||||||
:auto_ids => @config['kramdown']['auto_ids'],
|
raise FatalException.new("Invalid Markdown process: #{@config['markdown']}")
|
||||||
:footnote_nr => @config['kramdown']['footnote_nr'],
|
end
|
||||||
:entity_output => @config['kramdown']['entity_output'],
|
@setup = true
|
||||||
:toc_levels => @config['kramdown']['toc_levels'],
|
end
|
||||||
:smart_quotes => @config['kramdown']['smart_quotes']
|
|
||||||
}).to_html
|
def matches(ext)
|
||||||
end
|
rgx = '(' + @config['markdown_ext'].gsub(',','|') +')'
|
||||||
when 'rdiscount'
|
ext =~ Regexp.new(rgx, Regexp::IGNORECASE)
|
||||||
rd = RDiscount.new(content, *@rdiscount_extensions)
|
end
|
||||||
html = rd.to_html
|
|
||||||
if rd.generate_toc and html.include?(@config['rdiscount']['toc_token'])
|
def output_ext(ext)
|
||||||
html.gsub!(@config['rdiscount']['toc_token'], rd.toc_content)
|
".html"
|
||||||
end
|
end
|
||||||
html
|
|
||||||
when 'maruku'
|
def convert(content)
|
||||||
Maruku.new(content).to_html
|
setup
|
||||||
|
case @config['markdown']
|
||||||
|
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)
|
||||||
|
end
|
||||||
|
html
|
||||||
|
when 'maruku'
|
||||||
|
Maruku.new(content).to_html
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,50 +1,50 @@
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
module Converters
|
||||||
|
class Textile < Converter
|
||||||
|
safe true
|
||||||
|
|
||||||
class TextileConverter < Converter
|
pygments_prefix '<notextile>'
|
||||||
safe true
|
pygments_suffix '</notextile>'
|
||||||
|
|
||||||
pygments_prefix '<notextile>'
|
def setup
|
||||||
pygments_suffix '</notextile>'
|
return if @setup
|
||||||
|
require 'redcloth'
|
||||||
def setup
|
@setup = true
|
||||||
return if @setup
|
rescue LoadError
|
||||||
require 'redcloth'
|
STDERR.puts 'You are missing a library required for Textile. Please run:'
|
||||||
@setup = true
|
STDERR.puts ' $ [sudo] gem install RedCloth'
|
||||||
rescue LoadError
|
raise FatalException.new("Missing dependency: RedCloth")
|
||||||
STDERR.puts 'You are missing a library required for Textile. Please run:'
|
|
||||||
STDERR.puts ' $ [sudo] gem install RedCloth'
|
|
||||||
raise FatalException.new("Missing dependency: RedCloth")
|
|
||||||
end
|
|
||||||
|
|
||||||
def matches(ext)
|
|
||||||
rgx = '(' + @config['textile_ext'].gsub(',','|') +')'
|
|
||||||
ext =~ Regexp.new(rgx, Regexp::IGNORECASE)
|
|
||||||
end
|
|
||||||
|
|
||||||
def output_ext(ext)
|
|
||||||
".html"
|
|
||||||
end
|
|
||||||
|
|
||||||
def convert(content)
|
|
||||||
setup
|
|
||||||
|
|
||||||
# Shortcut if config doesn't contain RedCloth section
|
|
||||||
return RedCloth.new(content).to_html if @config['redcloth'].nil?
|
|
||||||
|
|
||||||
# List of attributes defined on RedCloth
|
|
||||||
# (from http://redcloth.rubyforge.org/classes/RedCloth/TextileDoc.html)
|
|
||||||
attrs = ['filter_classes', 'filter_html', 'filter_ids', 'filter_styles',
|
|
||||||
'hard_breaks', 'lite_mode', 'no_span_caps', 'sanitize_html']
|
|
||||||
|
|
||||||
r = RedCloth.new(content)
|
|
||||||
|
|
||||||
# Set attributes in r if they are NOT nil in the config
|
|
||||||
attrs.each do |attr|
|
|
||||||
r.instance_variable_set("@#{attr}".to_sym, @config['redcloth'][attr]) unless @config['redcloth'][attr].nil?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
r.to_html
|
def matches(ext)
|
||||||
|
rgx = '(' + @config['textile_ext'].gsub(',','|') +')'
|
||||||
|
ext =~ Regexp.new(rgx, Regexp::IGNORECASE)
|
||||||
|
end
|
||||||
|
|
||||||
|
def output_ext(ext)
|
||||||
|
".html"
|
||||||
|
end
|
||||||
|
|
||||||
|
def convert(content)
|
||||||
|
setup
|
||||||
|
|
||||||
|
# Shortcut if config doesn't contain RedCloth section
|
||||||
|
return RedCloth.new(content).to_html if @config['redcloth'].nil?
|
||||||
|
|
||||||
|
# List of attributes defined on RedCloth
|
||||||
|
# (from http://redcloth.rubyforge.org/classes/RedCloth/TextileDoc.html)
|
||||||
|
attrs = ['filter_classes', 'filter_html', 'filter_ids', 'filter_styles',
|
||||||
|
'hard_breaks', 'lite_mode', 'no_span_caps', 'sanitize_html']
|
||||||
|
|
||||||
|
r = RedCloth.new(content)
|
||||||
|
|
||||||
|
# Set attributes in r if they are NOT nil in the config
|
||||||
|
attrs.each do |attr|
|
||||||
|
r.instance_variable_set("@#{attr}".to_sym, @config['redcloth'][attr]) unless @config['redcloth'][attr].nil?
|
||||||
|
end
|
||||||
|
|
||||||
|
r.to_html
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,7 +10,7 @@ module Jekyll
|
||||||
# Returns the HTML formatted String.
|
# Returns the HTML formatted String.
|
||||||
def textilize(input)
|
def textilize(input)
|
||||||
site = @context.registers[:site]
|
site = @context.registers[:site]
|
||||||
converter = site.getConverterImpl(Jekyll::TextileConverter)
|
converter = site.getConverterImpl(Jekyll::Converters::Textile)
|
||||||
converter.convert(input)
|
converter.convert(input)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ module Jekyll
|
||||||
# Returns the HTML formatted String.
|
# Returns the HTML formatted String.
|
||||||
def markdownify(input)
|
def markdownify(input)
|
||||||
site = @context.registers[:site]
|
site = @context.registers[:site]
|
||||||
converter = site.getConverterImpl(Jekyll::MarkdownConverter)
|
converter = site.getConverterImpl(Jekyll::Converters::Markdown)
|
||||||
converter.convert(input)
|
converter.convert(input)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -17,16 +17,16 @@ class TestKramdown < Test::Unit::TestCase
|
||||||
|
|
||||||
# http://kramdown.rubyforge.org/converter/html.html#options
|
# http://kramdown.rubyforge.org/converter/html.html#options
|
||||||
should "pass kramdown options" do
|
should "pass kramdown options" do
|
||||||
markdown = MarkdownConverter.new(@config)
|
markdown = Converters::Markdown.new(@config)
|
||||||
assert_equal "<h1>Some Header</h1>", markdown.convert('# Some Header #').strip
|
assert_equal "<h1>Some Header</h1>", markdown.convert('# Some Header #').strip
|
||||||
end
|
end
|
||||||
|
|
||||||
should "convert quotes to smart quotes" do
|
should "convert quotes to smart quotes" do
|
||||||
markdown = MarkdownConverter.new(@config)
|
markdown = Converters::Markdown.new(@config)
|
||||||
assert_equal "<p>“Pit’hy”</p>", markdown.convert(%{"Pit'hy"}).strip
|
assert_equal "<p>“Pit’hy”</p>", markdown.convert(%{"Pit'hy"}).strip
|
||||||
|
|
||||||
override = { 'kramdown' => { 'smart_quotes' => 'lsaquo,rsaquo,laquo,raquo' } }
|
override = { 'kramdown' => { 'smart_quotes' => 'lsaquo,rsaquo,laquo,raquo' } }
|
||||||
markdown = MarkdownConverter.new(@config.deep_merge(override))
|
markdown = Converters::Markdown.new(@config.deep_merge(override))
|
||||||
assert_equal "<p>«Pit›hy»</p>", markdown.convert(%{"Pit'hy"}).strip
|
assert_equal "<p>«Pit›hy»</p>", markdown.convert(%{"Pit'hy"}).strip
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -445,34 +445,34 @@ class TestPost < Test::Unit::TestCase
|
||||||
should "process .md as markdown under default configuration" do
|
should "process .md as markdown under default configuration" do
|
||||||
post = setup_post '2011-04-12-md-extension.md'
|
post = setup_post '2011-04-12-md-extension.md'
|
||||||
conv = post.converter
|
conv = post.converter
|
||||||
assert conv.kind_of? Jekyll::MarkdownConverter
|
assert conv.kind_of? Jekyll::Converters::Markdown
|
||||||
end
|
end
|
||||||
|
|
||||||
should "process .text as indentity under default configuration" do
|
should "process .text as indentity under default configuration" do
|
||||||
post = setup_post '2011-04-12-text-extension.text'
|
post = setup_post '2011-04-12-text-extension.text'
|
||||||
conv = post.converter
|
conv = post.converter
|
||||||
assert conv.kind_of? Jekyll::IdentityConverter
|
assert conv.kind_of? Jekyll::Converters::Identity
|
||||||
end
|
end
|
||||||
|
|
||||||
should "process .text as markdown under alternate configuration" do
|
should "process .text as markdown under alternate configuration" do
|
||||||
@site.config['markdown_ext'] = 'markdown,mdw,mdwn,md,text'
|
@site.config['markdown_ext'] = 'markdown,mdw,mdwn,md,text'
|
||||||
post = setup_post '2011-04-12-text-extension.text'
|
post = setup_post '2011-04-12-text-extension.text'
|
||||||
conv = post.converter
|
conv = post.converter
|
||||||
assert conv.kind_of? Jekyll::MarkdownConverter
|
assert conv.kind_of? Jekyll::Converters::Markdown
|
||||||
end
|
end
|
||||||
|
|
||||||
should "process .md as markdown under alternate configuration" do
|
should "process .md as markdown under alternate configuration" do
|
||||||
@site.config['markdown_ext'] = 'markdown,mkd,mkdn,md,text'
|
@site.config['markdown_ext'] = 'markdown,mkd,mkdn,md,text'
|
||||||
post = setup_post '2011-04-12-text-extension.text'
|
post = setup_post '2011-04-12-text-extension.text'
|
||||||
conv = post.converter
|
conv = post.converter
|
||||||
assert conv.kind_of? Jekyll::MarkdownConverter
|
assert conv.kind_of? Jekyll::Converters::Markdown
|
||||||
end
|
end
|
||||||
|
|
||||||
should "process .text as textile under alternate configuration" do
|
should "process .text as textile under alternate configuration" do
|
||||||
@site.config['textile_ext'] = 'textile,text'
|
@site.config['textile_ext'] = 'textile,text'
|
||||||
post = setup_post '2011-04-12-text-extension.text'
|
post = setup_post '2011-04-12-text-extension.text'
|
||||||
conv = post.converter
|
conv = post.converter
|
||||||
assert conv.kind_of? Jekyll::TextileConverter
|
assert conv.kind_of? Jekyll::Converters::Textile
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ class TestRdiscount < Test::Unit::TestCase
|
||||||
'markdown' => 'rdiscount',
|
'markdown' => 'rdiscount',
|
||||||
'rdiscount' => { 'extensions' => ['smart', 'generate_toc'], 'toc_token' => '{:toc}' }
|
'rdiscount' => { 'extensions' => ['smart', 'generate_toc'], 'toc_token' => '{:toc}' }
|
||||||
}
|
}
|
||||||
@markdown = MarkdownConverter.new config
|
@markdown = Converters::Markdown.new config
|
||||||
end
|
end
|
||||||
|
|
||||||
should "pass rdiscount extensions" do
|
should "pass rdiscount extensions" do
|
||||||
|
|
|
@ -7,7 +7,7 @@ class TestRedcarpet < Test::Unit::TestCase
|
||||||
'redcarpet' => { 'extensions' => ['smart', 'strikethrough', 'filter_html'] },
|
'redcarpet' => { 'extensions' => ['smart', 'strikethrough', 'filter_html'] },
|
||||||
'markdown' => 'redcarpet'
|
'markdown' => 'redcarpet'
|
||||||
}
|
}
|
||||||
@markdown = MarkdownConverter.new config
|
@markdown = Converters::Markdown.new config
|
||||||
end
|
end
|
||||||
|
|
||||||
should "pass redcarpet options" do
|
should "pass redcarpet options" do
|
||||||
|
|
|
@ -4,7 +4,7 @@ class TestRedCloth < Test::Unit::TestCase
|
||||||
|
|
||||||
context "RedCloth default (no explicit config) hard_breaks enabled" do
|
context "RedCloth default (no explicit config) hard_breaks enabled" do
|
||||||
setup do
|
setup do
|
||||||
@textile = TextileConverter.new
|
@textile = Converters::Textile.new
|
||||||
end
|
end
|
||||||
|
|
||||||
should "preserve single line breaks in HTML output" do
|
should "preserve single line breaks in HTML output" do
|
||||||
|
@ -17,7 +17,7 @@ class TestRedCloth < Test::Unit::TestCase
|
||||||
config = {
|
config = {
|
||||||
'redcloth' => {}
|
'redcloth' => {}
|
||||||
}
|
}
|
||||||
@textile = TextileConverter.new config
|
@textile = Converters::Textile.new config
|
||||||
end
|
end
|
||||||
|
|
||||||
should "preserve single line breaks in HTML output" do
|
should "preserve single line breaks in HTML output" do
|
||||||
|
@ -32,7 +32,7 @@ class TestRedCloth < Test::Unit::TestCase
|
||||||
'hard_breaks' => true # default
|
'hard_breaks' => true # default
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@textile = TextileConverter.new config
|
@textile = Converters::Textile.new config
|
||||||
end
|
end
|
||||||
|
|
||||||
should "preserve single line breaks in HTML output" do
|
should "preserve single line breaks in HTML output" do
|
||||||
|
@ -47,7 +47,7 @@ class TestRedCloth < Test::Unit::TestCase
|
||||||
'hard_breaks' => false
|
'hard_breaks' => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@textile = TextileConverter.new config
|
@textile = Converters::Textile.new config
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not generate break tags in HTML output" do
|
should "not generate break tags in HTML output" do
|
||||||
|
@ -62,7 +62,7 @@ class TestRedCloth < Test::Unit::TestCase
|
||||||
'no_span_caps' => false
|
'no_span_caps' => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@textile = TextileConverter.new config
|
@textile = Converters::Textile.new config
|
||||||
end
|
end
|
||||||
should "generate span tags around capitalized words" do
|
should "generate span tags around capitalized words" do
|
||||||
assert_equal "<p><span class=\"caps\">NSC</span></p>", @textile.convert("NSC").strip
|
assert_equal "<p><span class=\"caps\">NSC</span></p>", @textile.convert("NSC").strip
|
||||||
|
@ -76,7 +76,7 @@ class TestRedCloth < Test::Unit::TestCase
|
||||||
'no_span_caps' => true
|
'no_span_caps' => true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@textile = TextileConverter.new config
|
@textile = Converters::Textile.new config
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not generate span tags around capitalized words" do
|
should "not generate span tags around capitalized words" do
|
||||||
|
|
|
@ -4,7 +4,7 @@ require 'helper'
|
||||||
|
|
||||||
class TestTags < Test::Unit::TestCase
|
class TestTags < Test::Unit::TestCase
|
||||||
|
|
||||||
def create_post(content, override = {}, converter_class = Jekyll::MarkdownConverter)
|
def create_post(content, override = {}, converter_class = Jekyll::Converters::Markdown)
|
||||||
stub(Jekyll).configuration do
|
stub(Jekyll).configuration do
|
||||||
Jekyll::DEFAULTS.deep_merge({'pygments' => true}).deep_merge(override)
|
Jekyll::DEFAULTS.deep_merge({'pygments' => true}).deep_merge(override)
|
||||||
end
|
end
|
||||||
|
@ -129,7 +129,7 @@ CONTENT
|
||||||
|
|
||||||
context "using Textile" do
|
context "using Textile" do
|
||||||
setup do
|
setup do
|
||||||
create_post(@content, {}, Jekyll::TextileConverter)
|
create_post(@content, {}, Jekyll::Converters::Textile)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Broken in RedCloth 4.1.9
|
# Broken in RedCloth 4.1.9
|
||||||
|
|
Loading…
Reference in New Issue