diff --git a/lib/asciidoctor-pdf/converter.rb b/lib/asciidoctor-pdf/converter.rb index dc3942ede..88617a004 100644 --- a/lib/asciidoctor-pdf/converter.rb +++ b/lib/asciidoctor-pdf/converter.rb @@ -1202,11 +1202,11 @@ def convert_listing_or_literal node when 'pygments' Helpers.require_library 'pygments', 'pygments.rb' unless defined? ::Pygments lexer = ::Pygments::Lexer.find_by_alias(node.attr 'language', 'text', false) || ::Pygments::Lexer['text'] - pygments_config = { + lexer_opts = { nowrap: true, noclasses: true, stripnl: false, - style: style = (node.document.attr 'pygments-style') || 'pastie' + style: (style = (node.document.attr 'pygments-style') || 'pastie') } # TODO enable once we support background color on spans #if node.attr? 'highlight', nil, false @@ -1227,7 +1227,7 @@ def convert_listing_or_literal node source_string, conum_mapping = extract_conums source_string # NOTE pygments.rb strips trailing whitespace; preserve it in case there are conums on last line num_trailing_spaces = source_string.size - (source_string = source_string.rstrip).size if conum_mapping - result = lexer.highlight source_string, options: pygments_config + result = lexer.highlight source_string, options: lexer_opts fragments = guard_indentation text_formatter.format result conum_mapping ? (restore_conums fragments, conum_mapping, num_trailing_spaces) : fragments when 'rouge'