From cab9047de10dbfec0dd322acfb191cf0dfdf38e3 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Sun, 22 Dec 2013 17:24:33 +0100 Subject: [PATCH] Set the wrap option to false when using Rouge Since Rouge yields the pre tag with a class attribute but we don't want it, we should set the wrap parameter to false when instantiating a new formatter object. Also use Rouge::Formatter#format instead of #render which is deprecated and will be removed in the near future. --- lib/jekyll/tags/highlight.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/jekyll/tags/highlight.rb b/lib/jekyll/tags/highlight.rb index eb6bf5a3..8719511f 100644 --- a/lib/jekyll/tags/highlight.rb +++ b/lib/jekyll/tags/highlight.rb @@ -72,11 +72,13 @@ eos linenos = @options.keys.include?('linenos') lexer = Rouge::Lexer.find_fancy(@lang, code) || Rouge::Lexers::PlainText - formatter = Rouge::Formatters::HTML.new(line_numbers: linenos) + formatter = Rouge::Formatters::HTML.new(line_numbers: linenos, wrap: false) + + pre = "
#{formatter.format(lexer.lex(code))}
" output = context["highlighter_prefix"] || "" output << "
" - output << add_code_tags(formatter.render(lexer.lex(code)), @lang) + output << add_code_tags(pre, @lang) output << "
" output << context["highlighter_suffix"] if context["highlighter_suffix"]