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.
This commit is contained in:
parent
bd442680ea
commit
cab9047de1
|
@ -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 = "<pre>#{formatter.format(lexer.lex(code))}</pre>"
|
||||
|
||||
output = context["highlighter_prefix"] || ""
|
||||
output << "<div class=\"highlight\">"
|
||||
output << add_code_tags(formatter.render(lexer.lex(code)), @lang)
|
||||
output << add_code_tags(pre, @lang)
|
||||
output << "</div>"
|
||||
output << context["highlighter_suffix"] if context["highlighter_suffix"]
|
||||
|
||||
|
|
Loading…
Reference in New Issue