class Rouge::Formatter

A Formatter takes a token stream and formats it for human viewing.

def self.find(tag)

Find a formatter class given a unique tag.
def self.find(tag)
  REGISTRY[tag]
end

def self.format(tokens, opts={}, &b)

Format a token stream. Delegates to {#format}.
def self.format(tokens, opts={}, &b)
  new(opts).format(tokens, &b)
end

def self.tag(tag=nil)

for specifying a formatter in `rougify`.
Specify or get the unique tag for this formatter. This is used
def self.tag(tag=nil)
  return @tag unless tag
  REGISTRY[tag] = self
  @tag = tag
end

def format(tokens, &b)

Format a token stream.
def format(tokens, &b)
  return stream(tokens, &b) if block_given?
  out = ''
  stream(tokens) { |piece| out << piece }
  out
end

def render(tokens)

Deprecated:
  • Use {#format} instead.
def render(tokens)
  warn 'Formatter#render is deprecated, use #format instead.'
  format(tokens)
end

def stream(tokens, &b)

Other tags:
    Abstract: -
def stream(tokens, &b)
  raise 'abstract'
end