xonsh.pygments_cache¶
A fast, drop-in replacement for pygments get_*() and guess_*() funtions.
The following pygments API functions are currently supplied here:
from pygments_cache import get_lexer_for_filename, guess_lexer_for_filename
from pygments_cache import get_formatter_for_filename, get_formatter_by_name
from pygments_cache import get_style_by_name, get_all_styles
from pygments_cache import get_filter_by_name
The cache itself is stored at the location given by the $PYGMENTS_CACHE_FILE
environment variable, or by default at ~/.local/share/pygments-cache/cache.py.
The cache file is created on first use, if it does not already exist.
- xonsh.pygments_cache.add_custom_style(name: str, style: Style)[source]¶
Register custom style to be able to retrieve it by
get_style_by_name.- Parameters:
- name
Style name.
- style
Custom style to add.
- xonsh.pygments_cache.get_all_styles()[source]¶
Iterable through all known style names. This mimics the behavior of
pygments.styles.get_all_styles.
- xonsh.pygments_cache.get_filter_by_name(filtername, **options)[source]¶
Gets a filter instance from its name. This mimics the behavior of
pygments.filters.get_filtere_by_name().
- xonsh.pygments_cache.get_formatter_by_name(alias, **options)[source]¶
Gets a formatter instance from its name or alias. This mimics the behavior of
pygments.formatters.get_formatter_by_name().
- xonsh.pygments_cache.get_formatter_for_filename(fn, **options)[source]¶
Gets a formatter instance from a filename (usually via the filename extension). This mimics the behavior of
pygments.formatters.get_formatter_for_filename().
- xonsh.pygments_cache.get_lexer_for_filename(filename, text='', **options)[source]¶
Gets a lexer from a filename (usually via the filename extension). This mimics the behavior of
pygments.lexers.get_lexer_for_filename()andpygments.lexers.guess_lexer_for_filename().
- xonsh.pygments_cache.get_style_by_name(name)[source]¶
Gets a style class from its name or alias. This mimics the behavior of
pygments.styles.get_style_by_name().
- xonsh.pygments_cache.guess_lexer_for_filename(filename, text='', **options)¶
Gets a lexer from a filename (usually via the filename extension). This mimics the behavior of
pygments.lexers.get_lexer_for_filename()andpygments.lexers.guess_lexer_for_filename().