Class: Asciidoctor::Rouge::DocinfoProcessor

Inherits:
Extensions::DocinfoProcessor
  • Object
show all
Defined in:
lib/asciidoctor/rouge/docinfo_processor.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#process(document) ⇒ String?

Parameters:

  • document (Asciidoctor::Document)

    the document to process.

Returns:

  • (String, nil)


13
14
15
16
17
18
19
20
21
# 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