class Rouge::Formatters::Terminal256
A formatter for 256-color terminals
Attributes
theme[R]
@private
Public Class Methods
new(theme=nil)
click to toggle source
@argument theme
the theme to render with.
# File lib/rouge/formatters/terminal256.rb, line 11 def initialize(theme=nil) @theme = theme || Themes::ThankfulEyes end
Public Instance Methods
escape_sequence(token)
click to toggle source
private
# File lib/rouge/formatters/terminal256.rb, line 151 def escape_sequence(token) @escape_sequences ||= {} @escape_sequences[token.qualname] ||= EscapeSequence.new(get_style(token)) end
get_style(token)
click to toggle source
# File lib/rouge/formatters/terminal256.rb, line 157 def get_style(token) return text_style if token.ancestors.include? Token::Tokens::Text theme.get_own_style(token) || text_style end
stream(tokens) { |style_string| ... }
click to toggle source
# File lib/rouge/formatters/terminal256.rb, line 15 def stream(tokens, &b) tokens.each do |tok, val| escape = escape_sequence(tok) yield escape.style_string yield val.gsub("\n", "#{escape.reset_string}\n#{escape.style_string}") yield escape.reset_string end end
text_style()
click to toggle source
# File lib/rouge/formatters/terminal256.rb, line 163 def text_style style = theme.get_style(Token['Text']) # don't highlight text backgrounds style.delete :bg style end