class Rouge::Formatters::Terminal256
A formatter for 256-color terminals
def escape_sequence(token)
def escape_sequence(token) return Unescape.new if escape?(token) @escape_sequences ||= {} @escape_sequences[token.qualname] ||= make_escape_sequence(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 = Themes::ThankfulEyes.new)
-
theme
(Hash, Rouge::Theme
) --
def initialize(theme = Themes::ThankfulEyes.new) if theme.is_a?(Rouge::Theme) @theme = theme elsif theme.is_a?(Hash) @theme = theme[:theme] || Themes::ThankfulEyes.new else raise ArgumentError, "invalid theme: #{theme.inspect}" end end
def make_escape_sequence(style)
def make_escape_sequence(style) EscapeSequence.new(style) end
def stream(tokens, &b)
def stream(tokens, &b) tokens.each do |tok, val| escape_sequence(tok).stream_value(val, &b) end end
def text_style
def text_style style = theme.get_style(Token['Text']) # don't highlight text backgrounds style.delete :bg style end