diff --git a/jekyll.gemspec b/jekyll.gemspec index 8fd62e81828..68516ae94ce 100644 --- a/jekyll.gemspec +++ b/jekyll.gemspec @@ -38,6 +38,6 @@ Gem::Specification.new do |s| s.add_runtime_dependency("liquid", "~> 4.0") s.add_runtime_dependency("mercenary", "~> 0.3.3") s.add_runtime_dependency("pathutil", "~> 0.9") - s.add_runtime_dependency("rouge", "~> #{ENV["ROUGE_VERSION"] || "1.7"}") + s.add_runtime_dependency("rouge", "~> #{ENV["ROUGE_VERSION"] || "2.1"}") s.add_runtime_dependency("safe_yaml", "~> 1.0") end diff --git a/lib/jekyll/utils/rouge.rb b/lib/jekyll/utils/rouge.rb index 8f381d4e419..a00a5f9e743 100644 --- a/lib/jekyll/utils/rouge.rb +++ b/lib/jekyll/utils/rouge.rb @@ -4,16 +4,16 @@ module Rouge def self.html_formatter(*args) Jekyll::External.require_with_graceful_fail("rouge") - html_formatter = ::Rouge::Formatters::HTML.new(*args) - return html_formatter if old_api? - - ::Rouge::Formatters::HTMLPygments.new(html_formatter) + if old_api? + ::Rouge::Formatters::HTML.new(*args) + else + ::Rouge::Formatters::HTMLLegacy.new(*args) + end end def self.old_api? ::Rouge.version.to_s < "2" end - end end end diff --git a/test/test_kramdown.rb b/test/test_kramdown.rb index a75849da4e3..eaf28274543 100644 --- a/test/test_kramdown.rb +++ b/test/test_kramdown.rb @@ -62,8 +62,9 @@ class TestKramdown < JekyllUnitTest puts "Hello World" ~~~ MARKDOWN - - selector = "div.highlighter-rouge>pre.highlight>code" + div_highlight = "" + div_highlight = ">div.highlight" unless Utils::Rouge.old_api? + selector = "div.highlighter-rouge#{div_highlight}>pre.highlight>code" refute result.css(selector).empty? end diff --git a/test/test_tags.rb b/test/test_tags.rb index c6be8412f87..bfcb2e8f4a2 100644 --- a/test/test_tags.rb +++ b/test/test_tags.rb @@ -430,22 +430,22 @@ def highlight_block_with_opts(options_string) EOS end - should "should stop highlighting at boundary with rouge 1" do + should "should stop highlighting at boundary with rouge 2" do skip "Skipped because using an older version of Rouge" if Utils::Rouge.old_api? expected = <<-EOS -

This is not yet highlighted

-
1
test
-
+

This is not yet highlighted

\n +
1
+
test
\n

This should not be highlighted, right?

EOS assert_match(expected, @result) end - should "should stop highlighting at boundary with rouge 2" do + should "should stop highlighting at boundary with rouge 1" do skip "Skipped because using a newer version of Rouge" unless Utils::Rouge.old_api? expected = <<-EOS

This is not yet highlighted

\n -
1
test
+
1
test\n
 
\n

This should not be highlighted, right?

EOS