# -*- coding: utf-8 -*- #
module Rouge
module Formatters
class HTMLLinewise < Formatter
def initialize(formatter, opts={})
@formatter = formatter
@class_format = opts.fetch(:class, '%i')
end
def stream(tokens, &b)
yield ""
tokens.each do |tok, val|
val.scan /\n|[^\n]+/ do |s|
if s == "\n"
yield "\n"
else
@formatter.span(tok, s)
end
end
end
yield ""
end
def next_line_class
@lineno ||= -1
sprintf(@class_format, @lineno += 1).inspect
end
end
end
end