class Asciidoctor::SyntaxHighlighter::PygmentsAdapter

def highlight node, source, lang, opts

def highlight node, source, lang, opts
  lexer = (::Pygments::Lexer.find_by_alias lang) || (::Pygments::Lexer.find_by_mimetype 'text/plain')
  @requires_stylesheet = true unless (noclasses = opts[:css_mode] != :class)
  highlight_opts = {
    classprefix: TOKEN_CLASS_PREFIX,
    cssclass: WRAPPER_CLASS,
    nobackground: true,
    noclasses: noclasses,
    startinline: lexer.name == 'PHP' && !(node.option? 'mixed'),
    stripnl: false,
    style: (@style ||= (style = opts[:style]) && (style_available? style) || DEFAULT_STYLE),
  }
  if (highlight_lines = opts[:highlight_lines])
    highlight_opts[:hl_lines] = highlight_lines.join ' '
  end
  if (linenos = opts[:number_lines]) && (highlight_opts[:linenostart] = opts[:start_line_number]) && (highlight_opts[:linenos] = linenos) == :table
    if (highlighted = lexer.highlight source, options: highlight_opts)
      highlighted = highlighted.sub StyledLinenoColumnStartTagsRx, LinenoColumnStartTagsCs if noclasses
      highlighted = highlighted.sub WrapperTagRx, PreTagCs
      opts[:callouts] ? [highlighted, (idx = highlighted.index CodeCellStartTagCs) ? idx + CodeCellStartTagCs.length : nil] : highlighted
    else
      node.sub_source source, false # handles nil response from ::Pygments::Lexer#highlight
    end
  elsif (highlighted = lexer.highlight source, options: highlight_opts)
    if linenos
      if noclasses
        highlighted = highlighted.gsub StyledLinenoSpanTagRx, LinenoSpanTagCs
      elsif highlighted.include? LegacyLinenoSpanStartTagCs
        highlighted = highlighted.gsub LegacyLinenoSpanTagRx, LinenoSpanTagCs
      end
    end
    highlighted.sub WrapperTagRx, '\1'
  else
    node.sub_source source, false # handles nil response from ::Pygments::Lexer#highlight
  end
end