class Rouge::Formatters::HTMLLineHighlighter
Public Class Methods
new(delegate, opts = {})
click to toggle source
# File lib/rouge/formatters/html_line_highlighter.rb, line 8 def initialize(delegate, opts = {}) @delegate = delegate @highlight_line_class = opts.fetch(:highlight_line_class, 'hll') @highlight_lines = opts[:highlight_lines] || [] end
Public Instance Methods
stream(tokens) { |line| ... }
click to toggle source
# File lib/rouge/formatters/html_line_highlighter.rb, line 14 def stream(tokens) lineno = 0 token_lines(tokens) do |tokens_in_line| lineno += 1 line = %(#{@delegate.format(tokens_in_line)}\n) line = %(<span class="#{@highlight_line_class}">#{line}</span>) if @highlight_lines.include? lineno yield line end end