highlight: duplicate tests for pygments for rouge

Ensure that the output we get for pygments will match
that we get for rouge in all cases except line numbers.
This commit is contained in:
Parker Moore 2015-02-09 21:57:43 -08:00
parent bf149a0b97
commit 1f503b24b3
1 changed files with 162 additions and 61 deletions

View File

@ -7,7 +7,7 @@ class TestTags < Test::Unit::TestCase
def create_post(content, override = {}, converter_class = Jekyll::Converters::Markdown) def create_post(content, override = {}, converter_class = Jekyll::Converters::Markdown)
stub(Jekyll).configuration do stub(Jekyll).configuration do
site_configuration({ site_configuration({
"highlighter" => "pygments" "highlighter" => "rouge"
}.merge(override)) }.merge(override))
end end
site = Site.new(Jekyll.configuration) site = Site.new(Jekyll.configuration)
@ -136,9 +136,10 @@ CONTENT
end end
end end
context "with the pygments highlighter" do
context "post content has highlight tag" do context "post content has highlight tag" do
setup do setup do
fill_post("test") fill_post("test", {'highlighter' => 'pygments'})
end end
should "not cause a markdown error" do should "not cause a markdown error" do
@ -154,6 +155,105 @@ CONTENT
end end
end end
context "post content has highlight with file reference" do
setup do
fill_post("./jekyll.gemspec", {'highlighter' => 'pygments'})
end
should "not embed the file" do
assert_match %{<pre><code class="language-text" data-lang="text">./jekyll.gemspec</code></pre>}, @result
end
end
context "post content has highlight tag with UTF character" do
setup do
fill_post("Æ", {'highlighter' => 'pygments'})
end
should "render markdown with pygments line handling" do
assert_match %{<pre><code class="language-text" data-lang="text">Æ</code></pre>}, @result
end
end
context "post content has highlight tag with preceding spaces & lines" do
setup do
code = <<-EOS
[,1] [,2]
[1,] FALSE TRUE
[2,] FALSE TRUE
EOS
fill_post(code, {'highlighter' => 'pygments'})
end
should "only strip the preceding newlines" do
assert_match %{<pre><code class=\"language-text\" data-lang=\"text\"> [,1] [,2]}, @result
end
end
context "post content has highlight tag with preceding spaces & lines in several places" do
setup do
code = <<-EOS
[,1] [,2]
[1,] FALSE TRUE
[2,] FALSE TRUE
EOS
fill_post(code, {'highlighter' => 'pygments'})
end
should "only strip the newlines which precede and succeed the entire block" do
assert_match "<pre><code class=\"language-text\" data-lang=\"text\"> [,1] [,2]\n\n\n[1,] FALSE TRUE\n[2,] FALSE TRUE</code></pre>", @result
end
end
context "post content has highlight tag with preceding spaces & Windows-style newlines" do
setup do
fill_post "\r\n\r\n\r\n [,1] [,2]", {'highlighter' => 'pygments'}
end
should "only strip the preceding newlines" do
assert_match %{<pre><code class=\"language-text\" data-lang=\"text\"> [,1] [,2]}, @result
end
end
context "post content has highlight tag with only preceding spaces" do
setup do
code = <<-EOS
[,1] [,2]
[1,] FALSE TRUE
[2,] FALSE TRUE
EOS
fill_post(code, {'highlighter' => 'pygments'})
end
should "only strip the preceding newlines" do
assert_match %{<pre><code class=\"language-text\" data-lang=\"text\"> [,1] [,2]}, @result
end
end
end
context "with the rouge highlighter" do
context "post content has highlight tag" do
setup do
fill_post("test")
end
should "render markdown with rouge" do
assert_match %{<pre><code class="language-text" data-lang="text">test</code></pre>}, @result
end
should "render markdown with rouge with line numbers" do
assert_match %{<table style="border-spacing: 0"><tbody><tr><td class="gutter gl" style="text-align: right"><pre class="lineno">1</pre></td><td class="code"><pre>test<span class="w">\n</span></pre></td></tr></tbody></table>}, @result
end
end
context "post content has highlight with file reference" do context "post content has highlight with file reference" do
setup do setup do
fill_post("./jekyll.gemspec") fill_post("./jekyll.gemspec")
@ -233,6 +333,7 @@ EOS
assert_match %{<pre><code class=\"language-text\" data-lang=\"text\"> [,1] [,2]}, @result assert_match %{<pre><code class=\"language-text\" data-lang=\"text\"> [,1] [,2]}, @result
end end
end end
end
context "simple post with markdown and pre tags" do context "simple post with markdown and pre tags" do
setup do setup do