import re, sys import pyficache from pygments import highlight, lex from pygments.console import ansiformat from pygments.filter import Filter from pygments.formatter import Formatter from pygments.formatters import TerminalFormatter from pygments.formatters.terminal import TERMINAL_COLORS from pygments.lexers import RstLexer from pygments.token import (Comment, Generic, Keyword, Name, Number, Operator, String, Token) from pygments.util import get_choice_opt # Set up my own color scheme with some addtional definitions color_scheme = TERMINAL_COLORS.copy() color_scheme[Generic.Strong] = ('*black*', '*white*') color_scheme[Name.Variable] = ('_black_', '_white_') color_scheme[Generic.Strong] = ('*black*', '*white*') color_scheme[Name.Variable] = ('_black_', '_white_') color_scheme[Generic.Emph] = color_scheme[Comment.Preproc] # FIXME: change some horrible colors under atom dark # this is a hack until I get general way to do colorstyle setting color_scheme[Token.Comment] = ('darkgray', 'white') color_scheme[Token.Keyword] = ('darkblue', 'turquoise') color_scheme[Token.Number] = ('darkblue', 'turquoise') color_scheme[Keyword] = ('darkblue', 'turquoise') color_scheme[Number] = ('darkblue', 'turquoise')
return token Arrow = Name.Variable Compare = Name.Exception Const = String Filename = Comment.Preproc Function = Name.Function Label = Operator.Word LineNumber = Number Offset = Operator Opcode = Name.Function Return = Operator.Word Var = Keyword Verbatim = String color_scheme = TERMINAL_COLORS.copy() color_scheme[Generic.Strong] = ('*black*', '*white*') color_scheme[Name.Variable] = ('_black_', '_white_') color_scheme[Generic.Emph] = TERMINAL_COLORS[Comment.Preproc] # Should come last since "Name" is used above Name = Comment.Preproc class RstFilter(Filter): def __init__(self, **options): Filter.__init__(self, **options) pass def filter(self, lexer, stream): for ttype, value in stream: