class Rouge::Formatters::HTMLLinewise
Public Class Methods
new(formatter, opts={})
click to toggle source
# File lib/rouge/formatters/html_linewise.rb, line 5 def initialize(formatter, opts={}) @formatter = formatter @class_format = opts.fetch(:class, '%i') end
Public Instance Methods
next_line_class()
click to toggle source
# File lib/rouge/formatters/html_linewise.rb, line 24 def next_line_class @lineno ||= -1 sprintf(@class_format, @lineno += 1).inspect end
stream(tokens) { |"
click to toggle source
# File lib/rouge/formatters/html_linewise.rb, line 10 def stream(tokens, &b) yield "<span class=#{next_line_class}>" tokens.each do |tok, val| val.scan /\n|[^\n]+/ do |s| if s == "\n" yield "</span>\n<span class=#{next_line_class}>" else @formatter.span(tok, s) end end end yield "</span>" end