class RougeLines::Formatters::HTMLLineanchors
Public Class Methods
new(formatter, opts={})
click to toggle source
# File lib/rouge-lines/formatters/html_lineanchors.rb, line 5 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-lines/formatters/html_lineanchors.rb, line 20 def next_line_class @lineno ||= 0 sprintf(@class_format, @lineno += 1).inspect end
stream(tokens) { |"<a name=#{next_line_class}></a>"| ... }
click to toggle source
# File lib/rouge-lines/formatters/html_lineanchors.rb, line 10 def stream(tokens, &b) token_lines(tokens) do |line| yield "<a name=#{next_line_class}></a>" line.each do |tok, val| yield @formatter.span(tok, val) end yield "\n" end end