class Asciidoctor::Rouge::DocinfoProcessor

A docinfo processor that embeds CSS for Rouge into the document's header.

Public Instance Methods

process(document) click to toggle source

@param document [Asciidoctor::Document] the document to process. @return [String, nil]

# File lib/asciidoctor/rouge/docinfo_processor.rb, line 13
def process(document)
  return unless document.attr?('source-highlighter', 'rouge')
  return unless document.attr('rouge-css', 'class') == 'class'

  if (theme = ::Rouge::Theme.find(document.attr('rouge-theme', DEFAULT_THEME)))
    css = theme.render(scope: '.highlight')
    ['<style>', css, '</style>'].join("\n")
  end
end