Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump rouge to 2.0.x #5230

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jekyll.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency('mercenary', '~> 0.3.3')
s.add_runtime_dependency('safe_yaml', '~> 1.0')
s.add_runtime_dependency('colorator', '~> 1.0')
s.add_runtime_dependency('rouge', '~> 1.7')
s.add_runtime_dependency('rouge', '~> 2.0.5')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure here if we should choose ~> 2.0.5 or ~> 2.0

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s.add_runtime_dependency(">= 1.7", "< 3") == "1.x", "2.x"

s.add_runtime_dependency('jekyll-sass-converter', '~> 1.0')
s.add_runtime_dependency('jekyll-watch', '~> 1.1')
s.add_runtime_dependency("pathutil", "~> 0.9")
Expand Down
1 change: 1 addition & 0 deletions lib/jekyll.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def require_all(path)
require "liquid"
require "kramdown"
require "colorator"
require "rouge"

SafeYAML::OPTIONS[:suppress_warnings] = true

Expand Down
2 changes: 1 addition & 1 deletion lib/jekyll/converters/markdown/redcarpet_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def block_code(code, lang)

protected
def rouge_formatter(_lexer)
Rouge::Formatters::HTML.new(:wrap => false)
Rouge::Formatters::HTMLLegacy.new(:wrap => false)
end
end

Expand Down
7 changes: 5 additions & 2 deletions lib/jekyll/tags/highlight.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,12 @@ def render_pygments(code, is_safe)

def render_rouge(code)
Jekyll::External.require_with_graceful_fail("rouge")
formatter = Rouge::Formatters::HTML.new(
formatter = Rouge::Formatters::HTMLLegacy.new(
:line_numbers => @highlight_options[:linenos],
:wrap => false
:wrap => false,
:css_class => "highlight",
:gutter_class => "gutter",
:code_class => "code"
)
lexer = Rouge::Lexer.find_fancy(@lang, code) || Rouge::Lexers::PlainText
formatter.format(lexer.lex(code))
Expand Down
5 changes: 4 additions & 1 deletion test/test_kramdown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ class TestKramdown < JekyllUnitTest

"syntax_highlighter" => "rouge",
"syntax_highlighter_opts" => {
"bold_every" => 8, "css" => :class
"bold_every" => 8,
"css" => :class,
"css_class" => "highlight",
"formatter" => ::Rouge::Formatters::HTMLLegacy
}
}
}
Expand Down
26 changes: 13 additions & 13 deletions test/test_tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,10 @@ def highlight_block_with_opts(options_string)

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>) +
%(<table class="rouge-table"><tbody>) +
%(<tr><td class="gutter gl">) +
%(<pre class="lineno">1\n</pre></td>) +
%(<td class="code"><pre>test</pre></td></tr>) +
%(</tbody></table>),
@result
)
Expand Down Expand Up @@ -415,15 +415,15 @@ def highlight_block_with_opts(options_string)
end

should "should stop highlighting at boundary" do
expected = <<-EOS
<p>This is not yet highlighted</p>

<figure class="highlight"><pre><code class="language-php" data-lang="php"><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">
</span></pre></td></tr></tbody></table></code></pre></figure>

<p>This should not be highlighted, right?</p>
EOS
assert_match(expected, @result)
assert_match(
%(<p>This is not yet highlighted</p>\n\n<figure class="highlight">) +
%(<pre><code class="language-php" data-lang="php">) +
%(<table class="rouge-table"><tbody><tr><td class="gutter gl">) +
%(<pre class="lineno">1\n</pre></td><td class="code"><pre>test</pre></td>) +
%(</tr></tbody></table></code></pre></figure>\n\n) +
%(<p>This should not be highlighted, right?</p>),
@result
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was much easier to read before. Is there a reason this needed to be changed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only reason here was to be consistent with the test on line 318.

end
end

Expand Down