class Rouge::Formatters::HTMLLinewise

Public Class Methods

new(formatter, opts={}) click to toggle source
# File lib/rouge/formatters/html_linewise.rb, line 6
def initialize(formatter, opts={})
  @formatter = formatter
  @class_format = opts.fetch(:class, 'line-%i')
end

Public Instance Methods

next_line_class() click to toggle source
# File lib/rouge/formatters/html_linewise.rb, line 21
def next_line_class
  @lineno ||= 0
  sprintf(@class_format, @lineno += 1).inspect
end
stream(tokens) { |"<div class=#{next_line_class}>"| ... } click to toggle source
# File lib/rouge/formatters/html_linewise.rb, line 11
def stream(tokens, &b)
  token_lines(tokens) do |line|
    yield "<div class=#{next_line_class}>"
    line.each do |tok, val|
      yield @formatter.span(tok, val)
    end
    yield '</div>'
  end
end