Test all the things
This commit is contained in:
parent
acb2263f51
commit
ddf640e6bd
|
@ -1,8 +1,8 @@
|
||||||
class Kramdown::Parser::SmartyPants < Kramdown::Parser::Kramdown
|
class Kramdown::Parser::SmartyPants < Kramdown::Parser::Kramdown
|
||||||
def initialize(source, options)
|
def initialize(source, options)
|
||||||
super
|
super
|
||||||
@block_parsers = []
|
@block_parsers = [:block_html]
|
||||||
@span_parsers = [:smart_quotes, :html_entity, :typographic_syms, :escaped_chars]
|
@span_parsers = [:smart_quotes, :html_entity, :typographic_syms, :span_html]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -31,11 +31,34 @@ class TestFilters < JekyllUnitTest
|
||||||
assert_equal "<p>something <strong>really</strong> simple</p>\n", @filter.markdownify("something **really** simple")
|
assert_equal "<p>something <strong>really</strong> simple</p>\n", @filter.markdownify("something **really** simple")
|
||||||
end
|
end
|
||||||
|
|
||||||
should "smartify with simple string" do
|
context "smartify filter" do
|
||||||
|
should "convert quotes and typographic characters" do
|
||||||
assert_equal "SmartyPants is *not* Markdown", @filter.smartify("SmartyPants is *not* Markdown")
|
assert_equal "SmartyPants is *not* Markdown", @filter.smartify("SmartyPants is *not* Markdown")
|
||||||
assert_equal "“This filter’s test…”", @filter.smartify(%q{"This filter's test..."})
|
assert_equal "“This filter’s test…”", @filter.smartify(%q{"This filter's test..."})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "escapes special characters when configured to do so" do
|
||||||
|
kramdown = JekyllFilter.new({:kramdown => {:entity_output => :symbolic}})
|
||||||
|
assert_equal "“This filter’s test…”", kramdown.smartify(%q{"This filter's test..."})
|
||||||
|
end
|
||||||
|
|
||||||
|
should "convert HTML entities to unicode characters" do
|
||||||
|
assert_equal "’", @filter.smartify("’")
|
||||||
|
assert_equal "“", @filter.smartify("“")
|
||||||
|
end
|
||||||
|
|
||||||
|
should "allow raw HTML passthrough" do
|
||||||
|
assert_equal "Span HTML is <em>not</em> escaped", @filter.smartify("Span HTML is <em>not</em> escaped")
|
||||||
|
assert_equal "<div>Block HTML is not escaped</div>", @filter.smartify("<div>Block HTML is not escaped</div>")
|
||||||
|
end
|
||||||
|
|
||||||
|
should "escape special characters" do
|
||||||
|
assert_equal "3 < 4", @filter.smartify("3 < 4")
|
||||||
|
assert_equal "5 > 4", @filter.smartify("5 > 4")
|
||||||
|
assert_equal "This & that", @filter.smartify("This & that")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
should "sassify with simple string" do
|
should "sassify with simple string" do
|
||||||
assert_equal "p {\n color: #123456; }\n", @filter.sassify("$blue:#123456\np\n color: $blue")
|
assert_equal "p {\n color: #123456; }\n", @filter.sassify("$blue:#123456\np\n color: $blue")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue