click_extra.pygments module¶
classDiagram
BashSessionLexer <|-- AnsiBashSessionLexer
DylanConsoleLexer <|-- AnsiDylanConsoleLexer
ElixirConsoleLexer <|-- AnsiElixirConsoleLexer
ErlangShellLexer <|-- AnsiErlangShellLexer
Filter <|-- AnsiFilter
GAPConsoleLexer <|-- AnsiGAPConsoleLexer
HtmlFormatter <|-- AnsiHtmlFormatter
JuliaConsoleLexer <|-- AnsiJuliaConsoleLexer
Lexer <|-- AnsiColorLexer
Lexer <|-- _AnsiFilterMixin
MSDOSSessionLexer <|-- AnsiMSDOSSessionLexer
MatlabSessionLexer <|-- AnsiMatlabSessionLexer
OutputLexer <|-- AnsiOutputLexer
PostgresConsoleLexer <|-- AnsiPostgresConsoleLexer
PowerShellSessionLexer <|-- AnsiPowerShellSessionLexer
PsyshConsoleLexer <|-- AnsiPsyshConsoleLexer
PythonConsoleLexer <|-- AnsiPythonConsoleLexer
RConsoleLexer <|-- AnsiRConsoleLexer
RubyConsoleLexer <|-- AnsiRubyConsoleLexer
SqliteConsoleLexer <|-- AnsiSqliteConsoleLexer
TcshSessionLexer <|-- AnsiTcshSessionLexer
_AnsiFilterMixin <|-- AnsiBashSessionLexer
_AnsiFilterMixin <|-- AnsiDylanConsoleLexer
_AnsiFilterMixin <|-- AnsiElixirConsoleLexer
_AnsiFilterMixin <|-- AnsiErlangShellLexer
_AnsiFilterMixin <|-- AnsiGAPConsoleLexer
_AnsiFilterMixin <|-- AnsiJuliaConsoleLexer
_AnsiFilterMixin <|-- AnsiMSDOSSessionLexer
_AnsiFilterMixin <|-- AnsiMatlabSessionLexer
_AnsiFilterMixin <|-- AnsiOutputLexer
_AnsiFilterMixin <|-- AnsiPostgresConsoleLexer
_AnsiFilterMixin <|-- AnsiPowerShellSessionLexer
_AnsiFilterMixin <|-- AnsiPsyshConsoleLexer
_AnsiFilterMixin <|-- AnsiPythonConsoleLexer
_AnsiFilterMixin <|-- AnsiRConsoleLexer
_AnsiFilterMixin <|-- AnsiRubyConsoleLexer
_AnsiFilterMixin <|-- AnsiSqliteConsoleLexer
_AnsiFilterMixin <|-- AnsiTcshSessionLexer
Pygments lexers, filters, and formatters for ANSI escape sequences.
Parses ANSI SGR escape sequences (ECMA-48 / ISO 6429) from terminal output and renders them as colored HTML with CSS classes. Supports the standard 8/16 named colors, the 256-color indexed palette, and 24-bit RGB.
SGR text attributes: bold, faint, italic, underline, blink, reverse video, strikethrough, and overline.
OSC 8 hyperlinks are rendered as HTML <a> tags. Other OSC sequences are silently
stripped.
Note
24-bit RGB colors (SGR 38;2;r;g;b and 48;2;r;g;b) are preserved by default
and rendered by AnsiHtmlFormatter as inline style="color: #rrggbb" /
style="background-color: #rrggbb" spans (CSS classes cannot enumerate 16.7M
colors). Other token components (bold, named colors, palette indices) keep their
CSS-class rendering. Pass true_color=False to AnsiColorLexer, AnsiFilter,
or any session lexer (via get_lexer_by_name(..., true_color=False)) to opt into
quantization to the nearest entry in the 256-color palette instead.
- click_extra.pygments.Ansi = ('Ansi',)¶
Unified token namespace for ANSI styling.
Compound tokens from the lexer (like
Token.Ansi.Bold.Red) and individual style components (likeToken.Ansi.Red) share this single namespace. The formatter decomposes compound tokens into individual CSS classes at render time.
- click_extra.pygments.DEFAULT_TOKEN_TYPE = ('Generic', 'Output')¶
Default Pygments token type to render with ANSI support.
Defaults to
Generic.Outputtokens, as this is the token type used by all REPL-like and terminal session lexers.
- click_extra.pygments.DEFAULT_TRUE_COLOR = True¶
Whether 24-bit RGB colors are kept as such, rather than quantized.
The default of the
true_coloroption every ANSI lexer and filter of this module takes:AnsiColorLexer,AnsiFilter, and the session lexers ofLEXER_MAP, which hand the option down to the lexers they wrap.
- class click_extra.pygments.AnsiColorLexer(**options)[source]¶
Bases:
LexerLexer for text containing ANSI escape sequences.
Parses Select Graphic Rendition (SGR) codes and emits compound
Token.Ansi.*tokens representing the active styling state. OSC 8 hyperlinks emitToken.AnsiLinkStart/Token.AnsiLinkEndstructural tokens. All other escape sequences are silently stripped.Supported SGR codes:
Text attributes: bold (1), faint (2), italic (3), underline (4), blink (5), reverse video (7), strikethrough (9), overline (53), and their resets.
Named colors: standard (30-37, 40-47) and bright (90-97, 100-107).
256-color indexed palette (38;5;n, 48;5;n).
24-bit RGB (38;2;r;g;b, 48;2;r;g;b), kept as is, or quantized to the nearest 256-color entry with
true_color=False.
Supported OSC sequences:
OSC 8 hyperlinks: rendered as
<a>tags byAnsiHtmlFormatter. Only URLs with safe schemes (http, https, mailto, ftp, ftps) are emitted; others are stripped.
Initialize the lexer.
- Parameters:
true_color – Default
DEFAULT_TRUE_COLOR. 24-bit RGB sequences are preserved asToken.Ansi.FG_{rrggbb}/Token.Ansi.BG_{rrggbb}tokens, whichAnsiHtmlFormatterrenders as inlinestyle="color: #rrggbb"/style="background-color: #rrggbb"attributes (CSS classes cannot enumerate 16.7M colors). PassFalseto quantize 24-bit RGB to the nearest entry in the 256-color palette and emitToken.Ansi.C{n}/Token.Ansi.BGC{n}tokens that map to CSS classes via the style dict.
- name = 'ANSI Color'¶
Full name of the lexer, in human-readable form
- aliases = ('ansi-color', 'ansi', 'ansi-terminal')¶
A list of short, unique identifiers that can be used to look up the lexer from a list, e.g., using
get_lexer_by_name().
- get_tokens_unprocessed(text)[source]¶
Parse ANSI escape sequences from
textand yield styled tokens.SGR sequences update the styling state, through the decoder of
click_extra.ansi: an escape reads the same here as insplit_ansi(), so an empty parameter is a0reset and\x1b[;31mis a reset followed by a red foreground. OSC 8 hyperlinks emit structuralToken.AnsiLinkStart/Token.AnsiLinkEndtokens. All other escape sequences are consumed and stripped.
- class click_extra.pygments.AnsiFilter(**options)[source]¶
Bases:
FilterCustom filter transforming a particular kind of token (
Generic.Outputby default) into ANSI tokens.Initialize an
AnsiColorLexerand configure thetoken_typeto be colorized.- Parameters:
true_color – Forwarded to the inner
AnsiColorLexerto control whether 24-bit RGB sequences are preserved asFG_/BG_hex tokens for inline-style rendering (defaultDEFAULT_TRUE_COLOR) or quantized to the 256-color palette. SeeAnsiColorLexerfor details.
Note
Only one
token_typeis supported. All Pygments session lexers (ShellSessionBaseLexerand the manually-maintained list incollect_session_lexers) emit terminal output exclusively asGeneric.Output. No upstream issue or PR proposes splitting output into additional token types (likeGeneric.Errorfor stderr). If that changes, this filter would need to accept a set of token types instead of a single one. See pygments#1148 and pygments#2499 for the closest related discussions.
- click_extra.pygments.collect_session_lexers()[source]¶
Retrieve all lexers producing shell-like sessions in Pygments.
The list is maintained by hand, and imports only the lexer modules it names: discovering it at import time would load every lexer Pygments ships.
Hint
tests/test_pygments.py fails when Pygments adds a shell session lexer, or a REPL or terminal lexer emitting
Generic.Output, missing from this list.
- click_extra.pygments.LEXER_MAP: dict[type[Lexer], type[Lexer]] = {<class 'pygments.lexers.algebra.GAPConsoleLexer'>: <class 'click_extra.pygments.AnsiGAPConsoleLexer'>, <class 'pygments.lexers.dylan.DylanConsoleLexer'>: <class 'click_extra.pygments.AnsiDylanConsoleLexer'>, <class 'pygments.lexers.erlang.ElixirConsoleLexer'>: <class 'click_extra.pygments.AnsiElixirConsoleLexer'>, <class 'pygments.lexers.erlang.ErlangShellLexer'>: <class 'click_extra.pygments.AnsiErlangShellLexer'>, <class 'pygments.lexers.julia.JuliaConsoleLexer'>: <class 'click_extra.pygments.AnsiJuliaConsoleLexer'>, <class 'pygments.lexers.matlab.MatlabSessionLexer'>: <class 'click_extra.pygments.AnsiMatlabSessionLexer'>, <class 'pygments.lexers.php.PsyshConsoleLexer'>: <class 'click_extra.pygments.AnsiPsyshConsoleLexer'>, <class 'pygments.lexers.python.PythonConsoleLexer'>: <class 'click_extra.pygments.AnsiPythonConsoleLexer'>, <class 'pygments.lexers.r.RConsoleLexer'>: <class 'click_extra.pygments.AnsiRConsoleLexer'>, <class 'pygments.lexers.ruby.RubyConsoleLexer'>: <class 'click_extra.pygments.AnsiRubyConsoleLexer'>, <class 'pygments.lexers.shell.BashSessionLexer'>: <class 'click_extra.pygments.AnsiBashSessionLexer'>, <class 'pygments.lexers.shell.MSDOSSessionLexer'>: <class 'click_extra.pygments.AnsiMSDOSSessionLexer'>, <class 'pygments.lexers.shell.PowerShellSessionLexer'>: <class 'click_extra.pygments.AnsiPowerShellSessionLexer'>, <class 'pygments.lexers.shell.TcshSessionLexer'>: <class 'click_extra.pygments.AnsiTcshSessionLexer'>, <class 'pygments.lexers.special.OutputLexer'>: <class 'click_extra.pygments.AnsiOutputLexer'>, <class 'pygments.lexers.sql.PostgresConsoleLexer'>: <class 'click_extra.pygments.AnsiPostgresConsoleLexer'>, <class 'pygments.lexers.sql.SqliteConsoleLexer'>: <class 'click_extra.pygments.AnsiSqliteConsoleLexer'>}¶
Map original session lexers to their ANSI-capable variants.
- click_extra.pygments.EXTRA_ANSI_CSS: dict[str, str] = {'Blink': 'animation: ansi-blink 1s step-end infinite', 'Bold': 'font-weight: bold', 'Faint': 'opacity: 0.6', 'Italic': 'font-style: italic', 'Overline': 'text-decoration: overline', 'Reverse': 'filter: invert(1)', 'Strikethrough': 'text-decoration: line-through', 'Underline': 'text-decoration: underline'}¶
All SGR text attribute CSS declarations.
Maps
Token.Ansicomponent names to CSS declarations, taken fromclick_extra.styling._ATTR_CSSso an attribute renders the same in a documentation code block as in the HTMLto_css()writes.Blinkalone takes_BLINK_CSS. The rules are kept out of the Pygments style dict (_ANSI_STYLES) to prevent Furo’s dark-mode CSS generator from injectingcolor: #D0D0D0fallbacks that conflict with foreground color tokens.Used by
AnsiHtmlFormatter.get_token_style_defsto inject CSS rules that both standalonepygmentizeand Furo’s dark-mode CSS generator pick up.
- class click_extra.pygments.AnsiBashSessionLexer(**options)¶
Bases:
_AnsiFilterMixin,BashSessionLexerANSI-capable variant of
BashSessionLexer.Add
TokenMergeFilterandAnsiFilterto the filter chain.Session lexers parse code blocks line by line to differentiate inputs and outputs. Each output line ends up encapsulated into a
Generic.Outputtoken. TheTokenMergeFilterconsolidates contiguous output lines into a single token, thenAnsiFiltertransforms the merged output into ANSI-styled tokens.- Parameters:
true_color – Forwarded to
AnsiFilter, and to the inner lexer a shell session builds from its options. DefaultDEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. PassFalseto quantize to the 256-color palette.
- aliases = ('ansi-console', 'ansi-shell-session')¶
A list of short, unique identifiers that can be used to look up the lexer from a list, e.g., using
get_lexer_by_name().
- name = 'ANSI Bash Session'¶
Full name of the lexer, in human-readable form
- class click_extra.pygments.AnsiDylanConsoleLexer(**options)¶
Bases:
_AnsiFilterMixin,DylanConsoleLexerANSI-capable variant of
DylanConsoleLexer.Add
TokenMergeFilterandAnsiFilterto the filter chain.Session lexers parse code blocks line by line to differentiate inputs and outputs. Each output line ends up encapsulated into a
Generic.Outputtoken. TheTokenMergeFilterconsolidates contiguous output lines into a single token, thenAnsiFiltertransforms the merged output into ANSI-styled tokens.- Parameters:
true_color – Forwarded to
AnsiFilter, and to the inner lexer a shell session builds from its options. DefaultDEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. PassFalseto quantize to the 256-color palette.
- aliases = ('ansi-dylan-console', 'ansi-dylan-repl')¶
A list of short, unique identifiers that can be used to look up the lexer from a list, e.g., using
get_lexer_by_name().
- name = 'ANSI Dylan session'¶
Full name of the lexer, in human-readable form
- class click_extra.pygments.AnsiElixirConsoleLexer(**options)¶
Bases:
_AnsiFilterMixin,ElixirConsoleLexerANSI-capable variant of
ElixirConsoleLexer.Add
TokenMergeFilterandAnsiFilterto the filter chain.Session lexers parse code blocks line by line to differentiate inputs and outputs. Each output line ends up encapsulated into a
Generic.Outputtoken. TheTokenMergeFilterconsolidates contiguous output lines into a single token, thenAnsiFiltertransforms the merged output into ANSI-styled tokens.- Parameters:
true_color – Forwarded to
AnsiFilter, and to the inner lexer a shell session builds from its options. DefaultDEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. PassFalseto quantize to the 256-color palette.
- aliases = ('ansi-iex',)¶
A list of short, unique identifiers that can be used to look up the lexer from a list, e.g., using
get_lexer_by_name().
- name = 'ANSI Elixir iex session'¶
Full name of the lexer, in human-readable form
- class click_extra.pygments.AnsiErlangShellLexer(**options)¶
Bases:
_AnsiFilterMixin,ErlangShellLexerANSI-capable variant of
ErlangShellLexer.Add
TokenMergeFilterandAnsiFilterto the filter chain.Session lexers parse code blocks line by line to differentiate inputs and outputs. Each output line ends up encapsulated into a
Generic.Outputtoken. TheTokenMergeFilterconsolidates contiguous output lines into a single token, thenAnsiFiltertransforms the merged output into ANSI-styled tokens.- Parameters:
true_color – Forwarded to
AnsiFilter, and to the inner lexer a shell session builds from its options. DefaultDEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. PassFalseto quantize to the 256-color palette.
- aliases = ('ansi-erl',)¶
A list of short, unique identifiers that can be used to look up the lexer from a list, e.g., using
get_lexer_by_name().
- name = 'ANSI Erlang erl session'¶
Full name of the lexer, in human-readable form
- class click_extra.pygments.AnsiGAPConsoleLexer(**options)¶
Bases:
_AnsiFilterMixin,GAPConsoleLexerANSI-capable variant of
GAPConsoleLexer.Add
TokenMergeFilterandAnsiFilterto the filter chain.Session lexers parse code blocks line by line to differentiate inputs and outputs. Each output line ends up encapsulated into a
Generic.Outputtoken. TheTokenMergeFilterconsolidates contiguous output lines into a single token, thenAnsiFiltertransforms the merged output into ANSI-styled tokens.- Parameters:
true_color – Forwarded to
AnsiFilter, and to the inner lexer a shell session builds from its options. DefaultDEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. PassFalseto quantize to the 256-color palette.
- aliases = ('ansi-gap-console', 'ansi-gap-repl')¶
A list of short, unique identifiers that can be used to look up the lexer from a list, e.g., using
get_lexer_by_name().
- name = 'ANSI GAP session'¶
Full name of the lexer, in human-readable form
- class click_extra.pygments.AnsiJuliaConsoleLexer(**options)¶
Bases:
_AnsiFilterMixin,JuliaConsoleLexerANSI-capable variant of
JuliaConsoleLexer.Add
TokenMergeFilterandAnsiFilterto the filter chain.Session lexers parse code blocks line by line to differentiate inputs and outputs. Each output line ends up encapsulated into a
Generic.Outputtoken. TheTokenMergeFilterconsolidates contiguous output lines into a single token, thenAnsiFiltertransforms the merged output into ANSI-styled tokens.- Parameters:
true_color – Forwarded to
AnsiFilter, and to the inner lexer a shell session builds from its options. DefaultDEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. PassFalseto quantize to the 256-color palette.
- aliases = ('ansi-jlcon', 'ansi-julia-repl')¶
A list of short, unique identifiers that can be used to look up the lexer from a list, e.g., using
get_lexer_by_name().
- name = 'ANSI Julia console'¶
Full name of the lexer, in human-readable form
- class click_extra.pygments.AnsiMSDOSSessionLexer(**options)¶
Bases:
_AnsiFilterMixin,MSDOSSessionLexerANSI-capable variant of
MSDOSSessionLexer.Add
TokenMergeFilterandAnsiFilterto the filter chain.Session lexers parse code blocks line by line to differentiate inputs and outputs. Each output line ends up encapsulated into a
Generic.Outputtoken. TheTokenMergeFilterconsolidates contiguous output lines into a single token, thenAnsiFiltertransforms the merged output into ANSI-styled tokens.- Parameters:
true_color – Forwarded to
AnsiFilter, and to the inner lexer a shell session builds from its options. DefaultDEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. PassFalseto quantize to the 256-color palette.
- aliases = ('ansi-doscon',)¶
A list of short, unique identifiers that can be used to look up the lexer from a list, e.g., using
get_lexer_by_name().
- name = 'ANSI MSDOS Session'¶
Full name of the lexer, in human-readable form
- class click_extra.pygments.AnsiMatlabSessionLexer(**options)¶
Bases:
_AnsiFilterMixin,MatlabSessionLexerANSI-capable variant of
MatlabSessionLexer.Add
TokenMergeFilterandAnsiFilterto the filter chain.Session lexers parse code blocks line by line to differentiate inputs and outputs. Each output line ends up encapsulated into a
Generic.Outputtoken. TheTokenMergeFilterconsolidates contiguous output lines into a single token, thenAnsiFiltertransforms the merged output into ANSI-styled tokens.- Parameters:
true_color – Forwarded to
AnsiFilter, and to the inner lexer a shell session builds from its options. DefaultDEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. PassFalseto quantize to the 256-color palette.
- aliases = ('ansi-matlabsession',)¶
A list of short, unique identifiers that can be used to look up the lexer from a list, e.g., using
get_lexer_by_name().
- name = 'ANSI Matlab session'¶
Full name of the lexer, in human-readable form
- class click_extra.pygments.AnsiOutputLexer(**options)¶
Bases:
_AnsiFilterMixin,OutputLexerANSI-capable variant of
OutputLexer.Add
TokenMergeFilterandAnsiFilterto the filter chain.Session lexers parse code blocks line by line to differentiate inputs and outputs. Each output line ends up encapsulated into a
Generic.Outputtoken. TheTokenMergeFilterconsolidates contiguous output lines into a single token, thenAnsiFiltertransforms the merged output into ANSI-styled tokens.- Parameters:
true_color – Forwarded to
AnsiFilter, and to the inner lexer a shell session builds from its options. DefaultDEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. PassFalseto quantize to the 256-color palette.
- aliases = ('ansi-output',)¶
A list of short, unique identifiers that can be used to look up the lexer from a list, e.g., using
get_lexer_by_name().
- name = 'ANSI Text output'¶
Full name of the lexer, in human-readable form
- class click_extra.pygments.AnsiPostgresConsoleLexer(**options)¶
Bases:
_AnsiFilterMixin,PostgresConsoleLexerANSI-capable variant of
PostgresConsoleLexer.Add
TokenMergeFilterandAnsiFilterto the filter chain.Session lexers parse code blocks line by line to differentiate inputs and outputs. Each output line ends up encapsulated into a
Generic.Outputtoken. TheTokenMergeFilterconsolidates contiguous output lines into a single token, thenAnsiFiltertransforms the merged output into ANSI-styled tokens.- Parameters:
true_color – Forwarded to
AnsiFilter, and to the inner lexer a shell session builds from its options. DefaultDEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. PassFalseto quantize to the 256-color palette.
- aliases = ('ansi-psql', 'ansi-postgresql-console', 'ansi-postgres-console')¶
A list of short, unique identifiers that can be used to look up the lexer from a list, e.g., using
get_lexer_by_name().
- name = 'ANSI PostgreSQL console (psql)'¶
Full name of the lexer, in human-readable form
- class click_extra.pygments.AnsiPowerShellSessionLexer(**options)¶
Bases:
_AnsiFilterMixin,PowerShellSessionLexerANSI-capable variant of
PowerShellSessionLexer.Add
TokenMergeFilterandAnsiFilterto the filter chain.Session lexers parse code blocks line by line to differentiate inputs and outputs. Each output line ends up encapsulated into a
Generic.Outputtoken. TheTokenMergeFilterconsolidates contiguous output lines into a single token, thenAnsiFiltertransforms the merged output into ANSI-styled tokens.- Parameters:
true_color – Forwarded to
AnsiFilter, and to the inner lexer a shell session builds from its options. DefaultDEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. PassFalseto quantize to the 256-color palette.
- aliases = ('ansi-pwsh-session', 'ansi-ps1con')¶
A list of short, unique identifiers that can be used to look up the lexer from a list, e.g., using
get_lexer_by_name().
- name = 'ANSI PowerShell Session'¶
Full name of the lexer, in human-readable form
- class click_extra.pygments.AnsiPsyshConsoleLexer(**options)¶
Bases:
_AnsiFilterMixin,PsyshConsoleLexerANSI-capable variant of
PsyshConsoleLexer.Add
TokenMergeFilterandAnsiFilterto the filter chain.Session lexers parse code blocks line by line to differentiate inputs and outputs. Each output line ends up encapsulated into a
Generic.Outputtoken. TheTokenMergeFilterconsolidates contiguous output lines into a single token, thenAnsiFiltertransforms the merged output into ANSI-styled tokens.- Parameters:
true_color – Forwarded to
AnsiFilter, and to the inner lexer a shell session builds from its options. DefaultDEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. PassFalseto quantize to the 256-color palette.
- aliases = ('ansi-psysh',)¶
A list of short, unique identifiers that can be used to look up the lexer from a list, e.g., using
get_lexer_by_name().
- name = 'ANSI PsySH console session for PHP'¶
Full name of the lexer, in human-readable form
- class click_extra.pygments.AnsiPythonConsoleLexer(**options)¶
Bases:
_AnsiFilterMixin,PythonConsoleLexerANSI-capable variant of
PythonConsoleLexer.Add
TokenMergeFilterandAnsiFilterto the filter chain.Session lexers parse code blocks line by line to differentiate inputs and outputs. Each output line ends up encapsulated into a
Generic.Outputtoken. TheTokenMergeFilterconsolidates contiguous output lines into a single token, thenAnsiFiltertransforms the merged output into ANSI-styled tokens.- Parameters:
true_color – Forwarded to
AnsiFilter, and to the inner lexer a shell session builds from its options. DefaultDEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. PassFalseto quantize to the 256-color palette.
- aliases = ('ansi-pycon', 'ansi-python-console')¶
A list of short, unique identifiers that can be used to look up the lexer from a list, e.g., using
get_lexer_by_name().
- name = 'ANSI Python console session'¶
Full name of the lexer, in human-readable form
- class click_extra.pygments.AnsiRConsoleLexer(**options)¶
Bases:
_AnsiFilterMixin,RConsoleLexerANSI-capable variant of
RConsoleLexer.Add
TokenMergeFilterandAnsiFilterto the filter chain.Session lexers parse code blocks line by line to differentiate inputs and outputs. Each output line ends up encapsulated into a
Generic.Outputtoken. TheTokenMergeFilterconsolidates contiguous output lines into a single token, thenAnsiFiltertransforms the merged output into ANSI-styled tokens.- Parameters:
true_color – Forwarded to
AnsiFilter, and to the inner lexer a shell session builds from its options. DefaultDEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. PassFalseto quantize to the 256-color palette.
- aliases = ('ansi-rconsole', 'ansi-rout')¶
A list of short, unique identifiers that can be used to look up the lexer from a list, e.g., using
get_lexer_by_name().
- name = 'ANSI RConsole'¶
Full name of the lexer, in human-readable form
- class click_extra.pygments.AnsiRubyConsoleLexer(**options)¶
Bases:
_AnsiFilterMixin,RubyConsoleLexerANSI-capable variant of
RubyConsoleLexer.Add
TokenMergeFilterandAnsiFilterto the filter chain.Session lexers parse code blocks line by line to differentiate inputs and outputs. Each output line ends up encapsulated into a
Generic.Outputtoken. TheTokenMergeFilterconsolidates contiguous output lines into a single token, thenAnsiFiltertransforms the merged output into ANSI-styled tokens.- Parameters:
true_color – Forwarded to
AnsiFilter, and to the inner lexer a shell session builds from its options. DefaultDEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. PassFalseto quantize to the 256-color palette.
- aliases = ('ansi-rbcon', 'ansi-irb')¶
A list of short, unique identifiers that can be used to look up the lexer from a list, e.g., using
get_lexer_by_name().
- name = 'ANSI Ruby irb session'¶
Full name of the lexer, in human-readable form
- class click_extra.pygments.AnsiSqliteConsoleLexer(**options)¶
Bases:
_AnsiFilterMixin,SqliteConsoleLexerANSI-capable variant of
SqliteConsoleLexer.Add
TokenMergeFilterandAnsiFilterto the filter chain.Session lexers parse code blocks line by line to differentiate inputs and outputs. Each output line ends up encapsulated into a
Generic.Outputtoken. TheTokenMergeFilterconsolidates contiguous output lines into a single token, thenAnsiFiltertransforms the merged output into ANSI-styled tokens.- Parameters:
true_color – Forwarded to
AnsiFilter, and to the inner lexer a shell session builds from its options. DefaultDEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. PassFalseto quantize to the 256-color palette.
- aliases = ('ansi-sqlite3',)¶
A list of short, unique identifiers that can be used to look up the lexer from a list, e.g., using
get_lexer_by_name().
- name = 'ANSI sqlite3con'¶
Full name of the lexer, in human-readable form
- class click_extra.pygments.AnsiTcshSessionLexer(**options)¶
Bases:
_AnsiFilterMixin,TcshSessionLexerANSI-capable variant of
TcshSessionLexer.Add
TokenMergeFilterandAnsiFilterto the filter chain.Session lexers parse code blocks line by line to differentiate inputs and outputs. Each output line ends up encapsulated into a
Generic.Outputtoken. TheTokenMergeFilterconsolidates contiguous output lines into a single token, thenAnsiFiltertransforms the merged output into ANSI-styled tokens.- Parameters:
true_color – Forwarded to
AnsiFilter, and to the inner lexer a shell session builds from its options. DefaultDEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. PassFalseto quantize to the 256-color palette.
- aliases = ('ansi-tcshcon',)¶
A list of short, unique identifiers that can be used to look up the lexer from a list, e.g., using
get_lexer_by_name().
- name = 'ANSI Tcsh Session'¶
Full name of the lexer, in human-readable form
- class click_extra.pygments.AnsiHtmlFormatter(**kwargs)[source]¶
Bases:
HtmlFormatterHTML formatter with ANSI color and hyperlink support.
Extends Pygments’
HtmlFormatterto handle compoundToken.Ansi.*tokens by decomposing them into individual CSS classes, augments the base style with ANSI color definitions for the 256-color indexed palette, and renders OSC 8 hyperlinks as HTML<a>tags.Intercept the
styleargument to augment it with ANSI color support.The formatter runs on a subclass of the style provided by the user, whose
stylesattribute is extended with the ANSI token definitions of_ANSI_STYLES, see_ansi_style.- name = 'ANSI HTML'¶
Full name for the formatter, in human-readable form.
- aliases: ClassVar[list[str]] = ['ansi-html']¶
A list of short, unique identifiers that can be used to lookup the formatter from a list, e.g. using
get_formatter_by_name().
- format_unencoded(tokensource, outfile)[source]¶
Render tokens to HTML, converting OSC 8 link and 24-bit RGB markers to tags.
Replaces
Token.AnsiLinkStart/Token.AnsiLinkEndwith Unicode Private Use Area markers, stripsFG_/BG_24-bit RGB components from compound tokens and replaces them with PUA markers carrying the hex value, delegates to Pygments’ HTML rendering, then post-processes the output to swap markers for<a>and inline-styled<span>tags.- Return type:
- get_token_style_defs(arg=None)[source]¶
Extend Pygments’ token CSS with rules for SGR attributes it cannot express.
Overriding
get_token_style_defs(rather thanget_style_defs) ensures that Furo’s dark-mode CSS generator, which calls this method directly, also picks up the extra rules built by_extra_ansi_css_lines.
- get_ansi_style_defs(arg=None)[source]¶
Return only this formatter’s ANSI CSS, dropping Pygments’ base syntax-token rules.
The MkDocs plugin layers these over a theme’s own syntax highlighting, so it must not pull in the standard token rules (those would override the theme). Keeps the
-Ansi-*token rules plus everything_extra_ansi_css_linesadds. Owning this selection here, next to the rules it returns, keeps the MkDocs plugin from hard-coding this formatter’s class names and CSS internals.- Return type: