diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2021-08-09 00:55:42 -0600 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2021-08-09 00:55:42 -0600 |
| commit | 3e255c09b7e2769eaee64ae8b73bcae8f5ef480d (patch) | |
| tree | 93e117d2d7c4104cabc889f9627a9f17456dacaa | |
| parent | b963240abc0aed20c3e09641445b4efc20f953a2 (diff) | |
use with_index to simplify stream method in RougeExt::HTMLLineHighlighter
| -rw-r--r-- | lib/asciidoctor/rouge_ext.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/asciidoctor/rouge_ext.rb b/lib/asciidoctor/rouge_ext.rb index 09900229..57a65d1b 100644 --- a/lib/asciidoctor/rouge_ext.rb +++ b/lib/asciidoctor/rouge_ext.rb @@ -28,9 +28,9 @@ module RougeExt end 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}) + (token_lines tokens).with_index 1 do |tokens_in_line, lineno| + formatted_line = (@delegate.format tokens_in_line) + LF + yield (@lines.include? lineno) ? %(<span class="hll">#{formatted_line}</span>) : formatted_line end end end |
