Class: Prawn::Dev::YardMarkup::CodeFormatter

Inherits:
Rouge::Formatter
  • Object
show all
Defined in:
lib/prawn/dev/yard_markup/document.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ CodeFormatter

Returns a new instance of CodeFormatter.



11
12
13
14
15
16
17
18
19
# File 'lib/prawn/dev/yard_markup/document.rb', line 11

def initialize(opts = {})
  @opts = opts
  @formatter =
    if opts[:inline_theme]
      ::Rouge::Formatters::HTMLInline.new(opts[:inline_theme])
    else
      ::Rouge::Formatters::HTML.new
    end
end

Instance Method Details

#stream(tokens) {|%(<pre><code>)| ... } ⇒ Object

Yields:

  • (%(<pre><code>))


21
22
23
24
25
# File 'lib/prawn/dev/yard_markup/document.rb', line 21

def stream(tokens, &block)
  yield %(<pre><code>) unless @opts[:inline]
  @formatter.stream(tokens, &block)
  yield '</code></pre>' unless @opts[:inline]
end