Class: Asciidoctor::RougeExt::Formatters::HTMLLineHighlighter

Inherits:
Rouge::Formatter
  • Object
show all
Defined in:
lib/asciidoctor/rouge_ext.rb

Instance Method Summary collapse

Constructor Details

#initialize(delegate, opts) ⇒ HTMLLineHighlighter

Returns a new instance of HTMLLineHighlighter.



22
23
24
25
# File 'lib/asciidoctor/rouge_ext.rb', line 22

def initialize delegate, opts
  @delegate = delegate
  @lines = opts[:lines] || []
end

Instance Method Details

#stream(tokens) ⇒ Object



27
28
29
30
31
32
# File 'lib/asciidoctor/rouge_ext.rb', line 27

def stream tokens
  lineno = 0
  token_lines tokens do |tokens_in_line|
    yield (@lines.include? lineno += 1) ? %(<span class="hll">#{@delegate.format tokens_in_line}#{LF}</span>) : %(#{@delegate.format tokens_in_line}#{LF})
  end
end