From 48b8da605a6d167b518b37995a6bbcb35a41f11a Mon Sep 17 00:00:00 2001 From: Florian Thomas Date: Sun, 18 Jun 2017 01:16:02 +0100 Subject: [PATCH 1/3] use `Rouge::Formatters::HTMLLegacy` and fix tests --- lib/jekyll/utils/rouge.rb | 10 +++++----- test/test_kramdown.rb | 5 +++-- test/test_tags.rb | 12 ++++++------ 3 files changed, 14 insertions(+), 13 deletions(-) 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 From 198ef89d8a2bd48c783f1448f9d0a9303b60d995 Mon Sep 17 00:00:00 2001 From: Florian Thomas Date: Sun, 18 Jun 2017 10:00:25 +0100 Subject: [PATCH 2/3] set default rouge version to 2.1.0 --- jekyll.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jekyll.gemspec b/jekyll.gemspec index 8fd62e81828..96bec9de841 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.0"}") s.add_runtime_dependency("safe_yaml", "~> 1.0") end From d3c3ec478db46f72ce38cd560a3d8f252d773eb2 Mon Sep 17 00:00:00 2001 From: Florian Thomas Date: Sun, 18 Jun 2017 17:10:47 +0100 Subject: [PATCH 3/3] allow more than just 2.1.x versions by default --- jekyll.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jekyll.gemspec b/jekyll.gemspec index 96bec9de841..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"] || "2.1.0"}") + s.add_runtime_dependency("rouge", "~> #{ENV["ROUGE_VERSION"] || "2.1"}") s.add_runtime_dependency("safe_yaml", "~> 1.0") end