Class: Qippet::Boxes::CodeBox::BareColorFormatter

Inherits:
Rouge::Formatter
  • Object
show all
Defined in:
lib/qippet/boxes/code_box.rb

Overview

Class to formate code tokens

Instance Method Summary collapse

Instance Method Details

#stream(tokens) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/qippet/boxes/code_box.rb', line 14

def stream(tokens)
  token_lines(tokens).with_index do |line_tokens, lineno|
    line_tokens_with_color = line_tokens.map do |token|
      token_color = Colors.get_color_by_shortname(token[0].shortname)
      [token_color, *token]
    end

    yield line_tokens_with_color, lineno
  end
end