Update converter classes moving into a module

This commit is contained in:
Tom Bell 2013-01-19 23:07:38 +00:00
parent 6514fe2d22
commit 663a1321d2
11 changed files with 212 additions and 215 deletions

View File

@ -1,5 +1,4 @@
module Jekyll
class Converter < Plugin
# 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
@ -46,5 +45,4 @@ module Jekyll
self.class.pygments_suffix
end
end
end

View File

@ -1,6 +1,6 @@
module Jekyll
class IdentityConverter < Converter
module Converters
class Identity < Converter
safe true
priority :lowest
@ -16,7 +16,6 @@ module Jekyll
def convert(content)
content
end
end
end
end

View File

@ -1,6 +1,6 @@
module Jekyll
class MarkdownConverter < Converter
module Converters
class Markdown < Converter
safe true
pygments_prefix "\n"
@ -145,5 +145,5 @@ module Jekyll
end
end
end
end
end

View File

@ -1,6 +1,6 @@
module Jekyll
class TextileConverter < Converter
module Converters
class Textile < Converter
safe true
pygments_prefix '<notextile>'
@ -46,5 +46,5 @@ module Jekyll
r.to_html
end
end
end
end

View File

@ -10,7 +10,7 @@ module Jekyll
# Returns the HTML formatted String.
def textilize(input)
site = @context.registers[:site]
converter = site.getConverterImpl(Jekyll::TextileConverter)
converter = site.getConverterImpl(Jekyll::Converters::Textile)
converter.convert(input)
end
@ -21,7 +21,7 @@ module Jekyll
# Returns the HTML formatted String.
def markdownify(input)
site = @context.registers[:site]
converter = site.getConverterImpl(Jekyll::MarkdownConverter)
converter = site.getConverterImpl(Jekyll::Converters::Markdown)
converter.convert(input)
end

View File

@ -17,16 +17,16 @@ class TestKramdown < Test::Unit::TestCase
# http://kramdown.rubyforge.org/converter/html.html#options
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
end
should "convert quotes to smart quotes" do
markdown = MarkdownConverter.new(@config)
markdown = Converters::Markdown.new(@config)
assert_equal "<p>&ldquo;Pit&rsquo;hy&rdquo;</p>", markdown.convert(%{"Pit'hy"}).strip
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>&laquo;Pit&rsaquo;hy&raquo;</p>", markdown.convert(%{"Pit'hy"}).strip
end
end

View File

@ -445,34 +445,34 @@ class TestPost < Test::Unit::TestCase
should "process .md as markdown under default configuration" do
post = setup_post '2011-04-12-md-extension.md'
conv = post.converter
assert conv.kind_of? Jekyll::MarkdownConverter
assert conv.kind_of? Jekyll::Converters::Markdown
end
should "process .text as indentity under default configuration" do
post = setup_post '2011-04-12-text-extension.text'
conv = post.converter
assert conv.kind_of? Jekyll::IdentityConverter
assert conv.kind_of? Jekyll::Converters::Identity
end
should "process .text as markdown under alternate configuration" do
@site.config['markdown_ext'] = 'markdown,mdw,mdwn,md,text'
post = setup_post '2011-04-12-text-extension.text'
conv = post.converter
assert conv.kind_of? Jekyll::MarkdownConverter
assert conv.kind_of? Jekyll::Converters::Markdown
end
should "process .md as markdown under alternate configuration" do
@site.config['markdown_ext'] = 'markdown,mkd,mkdn,md,text'
post = setup_post '2011-04-12-text-extension.text'
conv = post.converter
assert conv.kind_of? Jekyll::MarkdownConverter
assert conv.kind_of? Jekyll::Converters::Markdown
end
should "process .text as textile under alternate configuration" do
@site.config['textile_ext'] = 'textile,text'
post = setup_post '2011-04-12-text-extension.text'
conv = post.converter
assert conv.kind_of? Jekyll::TextileConverter
assert conv.kind_of? Jekyll::Converters::Textile
end
end

View File

@ -8,7 +8,7 @@ class TestRdiscount < Test::Unit::TestCase
'markdown' => 'rdiscount',
'rdiscount' => { 'extensions' => ['smart', 'generate_toc'], 'toc_token' => '{:toc}' }
}
@markdown = MarkdownConverter.new config
@markdown = Converters::Markdown.new config
end
should "pass rdiscount extensions" do

View File

@ -7,7 +7,7 @@ class TestRedcarpet < Test::Unit::TestCase
'redcarpet' => { 'extensions' => ['smart', 'strikethrough', 'filter_html'] },
'markdown' => 'redcarpet'
}
@markdown = MarkdownConverter.new config
@markdown = Converters::Markdown.new config
end
should "pass redcarpet options" do

View File

@ -4,7 +4,7 @@ class TestRedCloth < Test::Unit::TestCase
context "RedCloth default (no explicit config) hard_breaks enabled" do
setup do
@textile = TextileConverter.new
@textile = Converters::Textile.new
end
should "preserve single line breaks in HTML output" do
@ -17,7 +17,7 @@ class TestRedCloth < Test::Unit::TestCase
config = {
'redcloth' => {}
}
@textile = TextileConverter.new config
@textile = Converters::Textile.new config
end
should "preserve single line breaks in HTML output" do
@ -32,7 +32,7 @@ class TestRedCloth < Test::Unit::TestCase
'hard_breaks' => true # default
}
}
@textile = TextileConverter.new config
@textile = Converters::Textile.new config
end
should "preserve single line breaks in HTML output" do
@ -47,7 +47,7 @@ class TestRedCloth < Test::Unit::TestCase
'hard_breaks' => false
}
}
@textile = TextileConverter.new config
@textile = Converters::Textile.new config
end
should "not generate break tags in HTML output" do
@ -62,7 +62,7 @@ class TestRedCloth < Test::Unit::TestCase
'no_span_caps' => false
}
}
@textile = TextileConverter.new config
@textile = Converters::Textile.new config
end
should "generate span tags around capitalized words" do
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
}
}
@textile = TextileConverter.new config
@textile = Converters::Textile.new config
end
should "not generate span tags around capitalized words" do

View File

@ -4,7 +4,7 @@ require 'helper'
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
Jekyll::DEFAULTS.deep_merge({'pygments' => true}).deep_merge(override)
end
@ -129,7 +129,7 @@ CONTENT
context "using Textile" do
setup do
create_post(@content, {}, Jekyll::TextileConverter)
create_post(@content, {}, Jekyll::Converters::Textile)
end
# Broken in RedCloth 4.1.9