Skip to content

rs_rich.plugins

Generated from the type stubs by scripts/gen_python_api.py; do not edit.

rs_rich.plugins: the plugin API (rs-rich-plugin-api) from Python (no Rich counterpart).

A plugin subclasses :class:Plugin: metadata() returns a :class:PluginMetadata, and register(registrar) adds capabilities through a :class:PluginRegistrar (highlighters, code highlighters, themes, box styles, renderers, fence renderers and text transforms). :class:ExtensionRegistry hosts plugins, Python and built-in alike, and installs them onto a console.

PLUGIN_API_VERSION module-attribute

PLUGIN_API_VERSION: int

BuiltinPlugin

Bases: Plugin

Capability

KINDS instance-attribute

KINDS: List[str]

kind property

kind: str

name property

name: Optional[str]

CodeHighlighter

Subclass to write a syntax-highlighting engine in Python.

highlight

highlight(code: str, language: Optional[str] = None, theme: Optional[str] = None) -> Union[HighlightedCode, Iterable[Union[HighlightedLine, Iterable[SpanLike]]]]

default_theme

default_theme() -> str

themes

themes() -> List[str]

languages

languages() -> List[str]

language_for_path

language_for_path(path: Any) -> Optional[str]

token_style

token_style(theme: str, token: str) -> Optional[Style]

ExtensionRegistry

with_defaults staticmethod

with_defaults() -> ExtensionRegistry

add_plugin

add_plugin(plugin: Any) -> None

register_highlighter

register_highlighter(highlighter: Any) -> None

register_code_highlighter

register_code_highlighter(name: str, highlighter: Any) -> None

register_transform

register_transform(name: str, transform: Any) -> None

plugins

plugins() -> List[RegisteredPlugin]

provided_by

provided_by(capability: Capability) -> Optional[str]

code_highlighter_names

code_highlighter_names() -> List[str]

code_highlighter

code_highlighter(name: str) -> Optional[CodeHighlighter]

set_default_code_highlighter

set_default_code_highlighter(name: str, theme: Optional[str] = None) -> None

default_code_highlighter

default_code_highlighter() -> Optional[str]

theme

theme(name: str) -> Optional[Theme]

box_style

box_style(name: str) -> Optional[Box]

renderer

renderer(name: str) -> Optional[SourceRenderer]

fence_renderer

fence_renderer(language: str) -> Optional[FenceRenderer]

fences

fences() -> Optional[FenceRenderer]

transform

transform(name: str) -> Optional[TextTransform]

transform_names

transform_names() -> List[str]

text_pipeline

text_pipeline(names: Iterable[str]) -> TextPipeline

install

install(console: Console) -> None

FenceRenderer

render_fence

render_fence(language: str, code: str, console: Console, options: Optional[ConsoleOptions] = None) -> Optional[List[Segment]]

HighlightedCode

lines property

lines: List[HighlightedLine]

background property

background: Optional[str]

default_style property

default_style: Style

HighlightedLine

spans property

spans: List[HighlightSpan]

newline_style property

newline_style: Optional[Style]

HighlighterChoiceError

Bases: ValueError

set_default_code_highlighter named an unknown highlighter or theme.

name instance-attribute

name: str

available instance-attribute

available: Optional[List[str]]

theme instance-attribute

theme: Optional[str]

HighlightError

Bases: Exception

A code highlighter failed.

HighlightSpan

start property

start: int

end property

end: int

style property

style: Style

MermaidPlugin

Bases: Plugin

Plugin

Subclass and implement metadata() and register(registrar).

metadata

metadata() -> PluginMetadata

register

register(registrar: PluginRegistrar) -> None

PluginError

Bases: Exception

A plugin was refused, or a plugin callback failed. kind is one of incompatible_api, duplicate_plugin, conflict, invalid_name, failed, other or pipeline; the other attributes are None where the kind has no such field.

kind instance-attribute

kind: str

plugin instance-attribute

plugin: Optional[str]

name instance-attribute

name: Optional[str]

existing instance-attribute

existing: Optional[str]

capability instance-attribute

capability: Optional[Capability]

built_for instance-attribute

built_for: Optional[int]

host instance-attribute

host: Optional[int]

message instance-attribute

message: Optional[str]

stage instance-attribute

stage: Optional[str]

PluginMetadata

id property

id: str

name property

name: str

version property

version: str

api_version property

api_version: int

description property

description: Optional[str]

PluginRegistrar

highlighter

highlighter(highlighter: Any) -> None

code_highlighter

code_highlighter(name: str, highlighter: Any) -> None

theme

theme(name: str, theme: Theme) -> None

box_style

box_style(name: str, box: Box) -> None

renderer

renderer(name: str, renderer: Union[Callable[[str], Any], Any]) -> None

fence_renderer

fence_renderer(language: str, renderer: Union[Callable[[str, str], Any], Any]) -> None

transform

transform(name: str, transform: Union[Callable[[Text], Optional[Text]], Any]) -> None

RegisteredPlugin

metadata property

metadata: PluginMetadata

capabilities property

capabilities: List[Capability]

Rendered

A renderable a SourceRenderer returned.

SourceRenderer

render

render(source: str) -> Any

TextPipeline

names

names() -> List[str]

apply

apply(text: Text) -> Text

TextTransform

transform

transform(text: Text) -> Text

UnknownThemeError

Bases: HighlightError

A code highlighter has no theme of this name (args[0]).

install_defaults

install_defaults(console: Console) -> None

is_valid_name

is_valid_name(name: str) -> bool