Pygments Hooks (xonsh.pyghooks
)¶
Hooks for pygments syntax highlighting.
-
class
xonsh.pyghooks.
CompoundColorMap
(styles, *args, **kwargs)[source]¶ Looks up color tokes by name, potentailly generating the value from the lookup.
-
class
xonsh.pyghooks.
XonshConsoleLexer
(**options)[source]¶ Xonsh console lexer for pygments.
-
aliases
= ['xonshcon']¶
-
filenames
= []¶
-
name
= 'Xonsh console lexer'¶
-
tokens
= {'subproc': [('(.+)(\\))', <function bygroups.<locals>.callback at 0x7f4c372ba1e0>, '#pop'), ('(.+)(\\])', <function bygroups.<locals>.callback at 0x7f4c372ba2f0>, '#pop')], 'root': [('^(>>>|\\.\\.\\.) ', Token.Generic.Prompt), ('\\n(>>>|\\.\\.\\.)', Token.Generic.Prompt), ('\\n(?![>.][>.][>.] )([^\\n]*)', Token.Generic.Output), ('\\n(?![>.][>.][>.] )(.*?)$', Token.Generic.Output), ('\\?', Token.Keyword), ('\\$\\w+', Token.Name.Variable), ('\\$\\{', Token.Keyword, ('pymode',)), ('[\\!\\$]\\(', Token.Keyword, ('subproc',)), ('[\\!\\$]\\[', Token.Keyword, ('subproc',)), ('@\\$\\(', Token.Keyword, ('subproc',)), ('@\\(', Token.Keyword, ('pymode',)), inherit], 'pymode': [('(.+)(\\))', <function bygroups.<locals>.callback at 0x7f4c37552488>, '#pop'), ('(.+)(\\})', <function bygroups.<locals>.callback at 0x7f4c375dbe18>, '#pop')]}¶
-
-
class
xonsh.pyghooks.
XonshLexer
(**options)[source]¶ Xonsh console lexer for pygments.
-
aliases
= ['xonsh', 'xsh']¶
-
filenames
= ['*.xsh', '*xonshrc']¶
-
name
= 'Xonsh lexer'¶
-
tokens
= {'subproc': [('(.+)(\\))', <function bygroups.<locals>.callback at 0x7f4c372ba1e0>, '#pop'), ('(.+)(\\])', <function bygroups.<locals>.callback at 0x7f4c372ba2f0>, '#pop')], 'root': [('\\?', Token.Keyword), ('\\$\\w+', Token.Name.Variable), ('\\$\\{', Token.Keyword, ('pymode',)), ('[\\!\\$]\\(', Token.Keyword, ('subproc',)), ('[\\!\\$]\\[', Token.Keyword, ('subproc',)), ('@\\$\\(', Token.Keyword, ('subproc',)), ('@\\(', Token.Keyword, ('pymode',)), ('\\n', Token.Text), ('^(\\s*)([rRuU]{,2}"""(?:.|\\n)*?""")', <function bygroups.<locals>.callback at 0x7f4c378820d0>), ("^(\\s*)([rRuU]{,2}'''(?:.|\\n)*?''')", <function bygroups.<locals>.callback at 0x7f4c37882158>), ('[^\\S\\n]+', Token.Text), ('\\A#!.+$', Token.Comment.Hashbang), ('#.*$', Token.Comment.Single), ('[]{}:(),;[]', Token.Punctuation), ('\\\\\\n', Token.Text), ('\\\\', Token.Text), ('(in|is|and|or|not)\\b', Token.Operator.Word), ('!=|==|<<|>>|[-~+/*%=<>&^|.]', Token.Operator), 'keywords', ('(def)((?:\\s|\\\\\\s)+)', <function bygroups.<locals>.callback at 0x7f4c378821e0>, 'funcname'), ('(class)((?:\\s|\\\\\\s)+)', <function bygroups.<locals>.callback at 0x7f4c37882268>, 'classname'), ('(from)((?:\\s|\\\\\\s)+)', <function bygroups.<locals>.callback at 0x7f4c378822f0>, 'fromimport'), ('(import)((?:\\s|\\\\\\s)+)', <function bygroups.<locals>.callback at 0x7f4c37882378>, 'import'), 'builtins', 'backtick', ('(?:[rR]|[uU][rR]|[rR][uU])"""', Token.Literal.String.Double, 'tdqs'), ("(?:[rR]|[uU][rR]|[rR][uU])'''", Token.Literal.String.Single, 'tsqs'), ('(?:[rR]|[uU][rR]|[rR][uU])"', Token.Literal.String.Double, 'dqs'), ("(?:[rR]|[uU][rR]|[rR][uU])'", Token.Literal.String.Single, 'sqs'), ('[uU]?"""', Token.Literal.String.Double, ('stringescape', 'tdqs')), ("[uU]?'''", Token.Literal.String.Single, ('stringescape', 'tsqs')), ('[uU]?"', Token.Literal.String.Double, ('stringescape', 'dqs')), ("[uU]?'", Token.Literal.String.Single, ('stringescape', 'sqs')), 'name', 'numbers'], 'pymode': [('(.+)(\\))', <function bygroups.<locals>.callback at 0x7f4c37552488>, '#pop'), ('(.+)(\\})', <function bygroups.<locals>.callback at 0x7f4c375dbe18>, '#pop')]}¶
-
-
class
xonsh.pyghooks.
XonshStyle
(style_name='default')[source]¶ A xonsh pygments style that will dispatch to the correct color map by using a ChainMap. The style_name property may be used to reset the current style.
Parameters: style_name : str, optional
The style name to initialize with.
-
enhance_colors_for_cmd_exe
()[source]¶ Enhance colors when using cmd.exe on windows. When using the default style all blue and dark red colors are changed to CYAN and intence red.
-
style_name
¶
-
-
class
xonsh.pyghooks.
XonshSubprocLexer
(**options)[source]¶ Lexer for xonsh subproc mode.
-
name
= 'Xonsh subprocess lexer'¶
-
tokens
= {'root': [('(\\$\\{)(.*)(\\})', <function bygroups.<locals>.callback at 0x7f4c372ba400>), ('(@\\()(.+)(\\))', <function bygroups.<locals>.callback at 0x7f4c372ba510>), ('`[^`]*?`', Token.Literal.String.Backtick), inherit]}¶
-
-
xonsh.pyghooks.
code_by_name
(name, styles)[source]¶ Converts a token name into a pygments-style color code.
Parameters: name : str
Color token name.
styles : Mapping
Mapping for looking up non-hex colors
Returns: code : str
Pygments style color code.
-
xonsh.pyghooks.
color_by_name
(name, fg=None, bg=None)[source]¶ Converts a color name to a color token, foreground name, and background name. Will take into consideration current foreground and background colors, if provided.
Parameters: name : str
Color name.
fg : str, optional
Foreground color name.
bg : str, optional
Background color name.
Returns: tok : Token
Pygments Token.Color subclass
fg : str or None
New computed foreground color name.
bg : str or None
New computed background color name.