class Rouge::Formatters::Terminal256
A formatter for 256-color terminals
def escape_sequence(token)
def escape_sequence(token) @escape_sequences ||= {} @escape_sequences[token.qualname] ||= EscapeSequence.new(get_style(token)) end
def get_style(token)
def get_style(token) return text_style if token.ancestors.include? Token::Tokens::Text theme.get_own_style(token) || text_style end
def initialize(theme=nil)
@argument theme
def initialize(theme=nil) @theme = theme || Themes::ThankfulEyes end
def stream(tokens, &b)
def stream(tokens, &b) tokens.each do |tok, val| escape = escape_sequence(tok) yield escape.style_string yield val.gsub("\n", "\n#{escape.style_string}") yield escape.reset_string end end
def text_style
def text_style style = theme.get_style(Token['Text']) # don't highlight text backgrounds style.delete :bg style end