Expand description
Rendering & extension protocols.
Port of upstream rich/protocol.py + rich/abc.py + the highlighter
interface. These traits are the sanctioned extension points of the port.
Extensions in rich-ext (and, later, third-party plugins) implement them;
the faithful core only ever ships upstream’s built-in implementations. See
docs/PLUGINS.md.
Structs§
- Code
Highlighting - A console-wide default
CodeHighlighterand the theme to use with it. SeeConsoleCodeHighlighting. - Highlight
Span - One styled byte range of a highlighted line.
- Highlighted
Code - What a
CodeHighlighterreturns: oneHighlightedLineper element ofcode.split('\n'), so a trailing newline yields a final empty line. - Highlighted
Line - The spans of one source line, plus the style of the line break after it.
- Region
Guard - An entered region, exited when dropped, so an early return still exits.
- Region
Id - A region’s identity, chosen by the
RegionSinkthat recorded it. - Region
Info - A region a renderable reports: its role, and an optional label (a panel’s title, a heading’s text) and link target.
- Target
Capabilities - Immutable destination capabilities supplied by an extension. No detection or I/O.
Enums§
- Highlight
Error - Why a
CodeHighlightercould not highlight. An unknown language is not an error: highlighters fall back to plain text. - Region
Role - What a semantic region is: the role a renderable reports for the cells it
drew. See
RegionSink. - Support
- Evidence for an optional output protocol; inference is not confirmation.
Constants§
- REGION_
META_ KEY - The
Metakey under which a region’s id rides on the styles of the segments it drew. It never renders.
Traits§
- Code
Highlighter - A syntax-highlighting engine behind
Syntaxand Markdown code blocks. - Console
Code Highlighting - Attach/query a console’s default code highlighter.
- Console
Environment - Attach/query a per-console immutable extension environment.
- Console
Regions - Attach/query a console’s
RegionSink. - Fence
Renderer - Renders fenced Markdown code blocks of particular languages (for example
```mermaid) in place of the usual highlighted code. - Highlighter
- A transformer that adds style spans to
Text(e.g. syntax/number/URL highlighting). The Rust equivalent of upstream’sHighlighterABC. - Line
Renderable - Optional line-streaming extension point for renderables.
- Owned
Table Rows - Transfer already-owned table rows without cloning every cell string.
- Region
Sink - Observes semantic regions (#226): which cells a panel, table, table cell, rule, Markdown heading or code block drew. Not part of upstream.
- Render
Environment - Optional context shared by nested renderables without changing their protocol.
- Renderable
- Anything that can be rendered to a stream of
Segments within a width.
Functions§
- enter_
region - Enter a region when
consolehas a sink. With none,None, andinfois never called. - region_
of - The region
stylewas tagged with, if any. - report_
region render()as a region. Without a sink, exactlyrender().- tag_
region - Set
REGION_META_KEYtoidon every non-control segment that has no region yet. An unstyled segment gets a style holding only the tag.