Method: CodeRay::Encoders::Terminal#text_token

Defined in:
lib/coderay/encoders/terminal.rb

#text_token(text, kind) ⇒ Object



141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/coderay/encoders/terminal.rb', line 141

def text_token text, kind
  if color = @color_scopes.last[kind]
    color = color[:self] if color.is_a? Hash
    
    @out << color
    @out << (text.index("\n") ? text.gsub("\n", "\e[0m\n" + color) : text)
    @out << "\e[0m"
    if outer_color = @color_scopes.last[:self]
      @out << outer_color
    end
  else
    @out << text
  end
end