Test all the things

This commit is contained in:
Pat Hawks 2016-01-08 17:10:36 -08:00
parent acb2263f51
commit ddf640e6bd
No known key found for this signature in database
GPG Key ID: F1746FF5F18B3D1B
2 changed files with 28 additions and 5 deletions

View File

@ -1,8 +1,8 @@
class Kramdown::Parser::SmartyPants < Kramdown::Parser::Kramdown
def initialize(source, options)
super
@block_parsers = []
@span_parsers = [:smart_quotes, :html_entity, :typographic_syms, :escaped_chars]
@block_parsers = [:block_html]
@span_parsers = [:smart_quotes, :html_entity, :typographic_syms, :span_html]
end
end

View File

@ -31,9 +31,32 @@ class TestFilters < JekyllUnitTest
assert_equal "<p>something <strong>really</strong> simple</p>\n", @filter.markdownify("something **really** simple")
end
should "smartify with simple string" do
assert_equal "SmartyPants is *not* Markdown", @filter.smartify("SmartyPants is *not* Markdown")
assert_equal "“This filters test…”", @filter.smartify(%q{"This filter's test..."})
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 "“This filters test…”", @filter.smartify(%q{"This filter's test..."})
end
should "escapes special characters when configured to do so" do
kramdown = JekyllFilter.new({:kramdown => {:entity_output => :symbolic}})
assert_equal "&ldquo;This filter&rsquo;s test&hellip;&rdquo;", kramdown.smartify(%q{"This filter's test..."})
end
should "convert HTML entities to unicode characters" do
assert_equal "", @filter.smartify("&rsquo;")
assert_equal "", @filter.smartify("&ldquo;")
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 &lt; 4", @filter.smartify("3 < 4")
assert_equal "5 &gt; 4", @filter.smartify("5 > 4")
assert_equal "This &amp; that", @filter.smartify("This & that")
end
end
should "sassify with simple string" do