class Rouge::Formatters::Terminal256
def escape_sequence(token)
def escape_sequence(token) @escape_sequences ||= {} @escape_sequences[token.name] ||= begin esc = EscapeSequence.new(theme.get_style(token)) # don't highlight text backgrounds esc.style.delete(:bg) if token.name == 'Text' esc end end
def initialize(opts={})
def initialize(opts={}) @theme = opts[:theme] || Themes::ThankfulEyes @theme = Theme.find(@theme) if @theme.is_a? String end
def stream(tokens, &b)
def stream(tokens, &b) tokens.each do |tok, val| escape = escape_sequence(tok) yield escape.style_string yield val yield escape.reset_string end end