Class: Asciidoctor::RougeExt::Formatters::HTMLLineHighlighter
- Inherits:
-
Rouge::Formatter
- Object
- Rouge::Formatter
- Asciidoctor::RougeExt::Formatters::HTMLLineHighlighter
- Defined in:
- lib/asciidoctor/rouge_ext.rb
Instance Method Summary collapse
-
#initialize(delegate, opts) ⇒ HTMLLineHighlighter
constructor
A new instance of HTMLLineHighlighter.
- #stream(tokens) ⇒ Object
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 |