class Rouge::Formatters::HTMLLineHighlighter
Public Class Methods
Source
# File lib/rouge/formatters/html_line_highlighter.rb, line 13 def initialize(delegate, opts = {}) @delegate = HTML.assert_html_formatter!(delegate) @highlight_line_class = opts.fetch(:highlight_line_class, 'hll') @highlight_lines = opts[:highlight_lines] || [] end
Public Instance Methods
Source
# File lib/rouge/formatters/html_line_highlighter.rb, line 19 def stream(tokens) token_lines(tokens).with_index(1) do |line_tokens, lineno| should_highlight = @highlight_lines.include?(lineno) yield %(<span class=#{@highlight_line_class.inspect}>) if should_highlight line_tokens.each { |tok, val| yield @delegate.span(tok, val) } yield "\n" yield %(</span>) if should_highlight end end