Methods

Class/Module Index [+]

Quicksearch

Rouge::Formatters::HTML

Transforms a token stream into HTML output.

Public Class Methods

new(opts={}) click to toggle source

@option opts [String] :css_class (‘highlight’) @option opts [true/false] :line_numbers (false) @option opts [Rouge::CSSTheme] :inline_theme (nil) @option opts [true/false] :wrap (true)

Initialize with options.

If `:inline_theme` is given, then instead of rendering the tokens as <span> tags with CSS classes, the styles according to the given theme will be inlined in “style” attributes. This is useful for formats in which stylesheets are not available.

Content will be wrapped in a tag (`div` if tableized, `pre` if not) with the given `:css_class` unless `:wrap` is set to `false`.

# File lib/rouge/formatters/html.rb, line 24
def initialize(opts={})
  @css_class = opts.fetch(:css_class, 'highlight')
  @css_class = " class=#{@css_class.inspect}" if @css_class

  @line_numbers = opts.fetch(:line_numbers, false)
  @start_line = opts.fetch(:start_line, 1)
  @inline_theme = opts.fetch(:inline_theme, nil)
  @inline_theme = Theme.find(@inline_theme).new if @inline_theme.is_a? String

  @wrap = opts.fetch(:wrap, true)
end

Public Instance Methods

stream(tokens, &b) click to toggle source

@yield the html output.

# File lib/rouge/formatters/html.rb, line 37
def stream(tokens, &b)
  if @line_numbers
    stream_tableized(tokens, &b)
  else
    stream_untableized(tokens, &b)
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.