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 (like Token.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.Output tokens, 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_color option every ANSI lexer and filter of this module takes: AnsiColorLexer, AnsiFilter, and the session lexers of LEXER_MAP, which hand the option down to the lexers they wrap.

class click_extra.pygments.AnsiColorLexer(**options)[source]¶

Bases: Lexer

Lexer 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 emit Token.AnsiLinkStart / Token.AnsiLinkEnd structural 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 by AnsiHtmlFormatter. 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 as Token.Ansi.FG_{rrggbb} / Token.Ansi.BG_{rrggbb} tokens, which AnsiHtmlFormatter renders as inline style="color: #rrggbb" / style="background-color: #rrggbb" attributes (CSS classes cannot enumerate 16.7M colors). Pass False to quantize 24-bit RGB to the nearest entry in the 256-color palette and emit Token.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 text and yield styled tokens.

SGR sequences update the styling state, through the decoder of click_extra.ansi: an escape reads the same here as in split_ansi(), so an empty parameter is a 0 reset and \x1b[;31m is a reset followed by a red foreground. OSC 8 hyperlinks emit structural Token.AnsiLinkStart / Token.AnsiLinkEnd tokens. All other escape sequences are consumed and stripped.

Return type:

Iterator[tuple[int, _TokenType, str]]

class click_extra.pygments.AnsiFilter(**options)[source]¶

Bases: Filter

Custom filter transforming a particular kind of token (Generic.Output by default) into ANSI tokens.

Initialize an AnsiColorLexer and configure the token_type to be colorized.

Parameters:

true_color – Forwarded to the inner AnsiColorLexer to control whether 24-bit RGB sequences are preserved as FG_/BG_ hex tokens for inline-style rendering (default DEFAULT_TRUE_COLOR) or quantized to the 256-color palette. See AnsiColorLexer for details.

Note

Only one token_type is supported. All Pygments session lexers (ShellSessionBaseLexer and the manually-maintained list in collect_session_lexers) emit terminal output exclusively as Generic.Output. No upstream issue or PR proposes splitting output into additional token types (like Generic.Error for 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.

filter(lexer, stream)[source]¶

Transform each token of token_type type into a stream of ANSI tokens.

The token value is lexed as is: the lexer emitting it already normalized the text, and a second pass would strip the blank lines opening or closing each output block.

Return type:

Iterator[tuple[_TokenType, str]]

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.

Return type:

Iterator[type[Lexer]]

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.Ansi component names to CSS declarations, taken from click_extra.styling._ATTR_CSS so an attribute renders the same in a documentation code block as in the HTML to_css() writes. Blink alone takes _BLINK_CSS. The rules are kept out of the Pygments style dict (_ANSI_STYLES) to prevent Furo’s dark-mode CSS generator from injecting color: #D0D0D0 fallbacks that conflict with foreground color tokens.

Used by AnsiHtmlFormatter.get_token_style_defs to inject CSS rules that both standalone pygmentize and Furo’s dark-mode CSS generator pick up.

class click_extra.pygments.AnsiBashSessionLexer(**options)¶

Bases: _AnsiFilterMixin, BashSessionLexer

ANSI-capable variant of BashSessionLexer.

Add TokenMergeFilter and AnsiFilter to 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.Output token. The TokenMergeFilter consolidates contiguous output lines into a single token, then AnsiFilter transforms 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. Default DEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. Pass False to 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, DylanConsoleLexer

ANSI-capable variant of DylanConsoleLexer.

Add TokenMergeFilter and AnsiFilter to 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.Output token. The TokenMergeFilter consolidates contiguous output lines into a single token, then AnsiFilter transforms 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. Default DEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. Pass False to 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, ElixirConsoleLexer

ANSI-capable variant of ElixirConsoleLexer.

Add TokenMergeFilter and AnsiFilter to 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.Output token. The TokenMergeFilter consolidates contiguous output lines into a single token, then AnsiFilter transforms 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. Default DEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. Pass False to 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, ErlangShellLexer

ANSI-capable variant of ErlangShellLexer.

Add TokenMergeFilter and AnsiFilter to 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.Output token. The TokenMergeFilter consolidates contiguous output lines into a single token, then AnsiFilter transforms 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. Default DEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. Pass False to 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, GAPConsoleLexer

ANSI-capable variant of GAPConsoleLexer.

Add TokenMergeFilter and AnsiFilter to 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.Output token. The TokenMergeFilter consolidates contiguous output lines into a single token, then AnsiFilter transforms 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. Default DEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. Pass False to 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, JuliaConsoleLexer

ANSI-capable variant of JuliaConsoleLexer.

Add TokenMergeFilter and AnsiFilter to 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.Output token. The TokenMergeFilter consolidates contiguous output lines into a single token, then AnsiFilter transforms 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. Default DEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. Pass False to 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, MSDOSSessionLexer

ANSI-capable variant of MSDOSSessionLexer.

Add TokenMergeFilter and AnsiFilter to 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.Output token. The TokenMergeFilter consolidates contiguous output lines into a single token, then AnsiFilter transforms 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. Default DEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. Pass False to 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, MatlabSessionLexer

ANSI-capable variant of MatlabSessionLexer.

Add TokenMergeFilter and AnsiFilter to 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.Output token. The TokenMergeFilter consolidates contiguous output lines into a single token, then AnsiFilter transforms 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. Default DEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. Pass False to 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, OutputLexer

ANSI-capable variant of OutputLexer.

Add TokenMergeFilter and AnsiFilter to 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.Output token. The TokenMergeFilter consolidates contiguous output lines into a single token, then AnsiFilter transforms 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. Default DEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. Pass False to 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, PostgresConsoleLexer

ANSI-capable variant of PostgresConsoleLexer.

Add TokenMergeFilter and AnsiFilter to 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.Output token. The TokenMergeFilter consolidates contiguous output lines into a single token, then AnsiFilter transforms 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. Default DEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. Pass False to 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, PowerShellSessionLexer

ANSI-capable variant of PowerShellSessionLexer.

Add TokenMergeFilter and AnsiFilter to 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.Output token. The TokenMergeFilter consolidates contiguous output lines into a single token, then AnsiFilter transforms 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. Default DEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. Pass False to 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, PsyshConsoleLexer

ANSI-capable variant of PsyshConsoleLexer.

Add TokenMergeFilter and AnsiFilter to 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.Output token. The TokenMergeFilter consolidates contiguous output lines into a single token, then AnsiFilter transforms 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. Default DEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. Pass False to 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, PythonConsoleLexer

ANSI-capable variant of PythonConsoleLexer.

Add TokenMergeFilter and AnsiFilter to 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.Output token. The TokenMergeFilter consolidates contiguous output lines into a single token, then AnsiFilter transforms 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. Default DEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. Pass False to 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, RConsoleLexer

ANSI-capable variant of RConsoleLexer.

Add TokenMergeFilter and AnsiFilter to 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.Output token. The TokenMergeFilter consolidates contiguous output lines into a single token, then AnsiFilter transforms 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. Default DEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. Pass False to 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, RubyConsoleLexer

ANSI-capable variant of RubyConsoleLexer.

Add TokenMergeFilter and AnsiFilter to 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.Output token. The TokenMergeFilter consolidates contiguous output lines into a single token, then AnsiFilter transforms 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. Default DEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. Pass False to 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, SqliteConsoleLexer

ANSI-capable variant of SqliteConsoleLexer.

Add TokenMergeFilter and AnsiFilter to 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.Output token. The TokenMergeFilter consolidates contiguous output lines into a single token, then AnsiFilter transforms 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. Default DEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. Pass False to 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, TcshSessionLexer

ANSI-capable variant of TcshSessionLexer.

Add TokenMergeFilter and AnsiFilter to 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.Output token. The TokenMergeFilter consolidates contiguous output lines into a single token, then AnsiFilter transforms 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. Default DEFAULT_TRUE_COLOR: 24-bit RGB renders via inline styles. Pass False to 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: HtmlFormatter

HTML formatter with ANSI color and hyperlink support.

Extends Pygments’ HtmlFormatter to handle compound Token.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 style argument to augment it with ANSI color support.

The formatter runs on a subclass of the style provided by the user, whose styles attribute 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.AnsiLinkEnd with Unicode Private Use Area markers, strips FG_/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:

None

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 than get_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_lines adds. 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:

str