Tags:Highlight: Decomposed HTMLLegacy formatter (#8623)

Merge pull request 8623
This commit is contained in:
Sampath Sukesh Ravolaparthi 2021-08-09 18:01:09 +05:30 committed by GitHub
parent ca2f106c8f
commit ddbc8263de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 7 deletions

View File

@ -80,13 +80,17 @@ module Jekyll
def render_rouge(code)
require "rouge"
formatter = ::Rouge::Formatters::HTMLLegacy.new(
:line_numbers => @highlight_options[:linenos],
:wrap => false,
:css_class => "highlight",
:gutter_class => "gutter",
:code_class => "code"
)
formatter = ::Rouge::Formatters::HTML.new
if @highlight_options[:linenos]
formatter = ::Rouge::Formatters::HTMLTable.new(
formatter,
{
:css_class => "highlight",
:gutter_class => "gutter",
:code_class => "code",
}
)
end
lexer = ::Rouge::Lexer.find_fancy(@lang, code) || Rouge::Lexers::PlainText
formatter.format(lexer.lex(code))
end