rich.highlighter

class rich.highlighter.Highlighter[source]

Abstract base class for highlighters.

__call__(text: Union[str, rich.text.Text])rich.text.Text[source]

Highlight a str or Text instance.

Parameters

text (Union[str, ~Text]) – Text to highlight.

Raises

TypeError – If not called with text or str.

Returns

A test instance with highlighting applied.

Return type

Text

abstract highlight(text: rich.text.Text) → None[source]

Apply highlighting in place to text.

Parameters

text (~Text) – A text object highlight.

class rich.highlighter.NullHighlighter[source]

A highlighter object that doesn’t highlight.

May be used to disable highlighting entirely.

highlight(text: rich.text.Text) → None[source]

Nothing to do

class rich.highlighter.RegexHighlighter[source]

Applies highlighting from a list of regular expressions.

highlight(text: rich.text.Text) → None[source]

Highlight rich.text.Text using regular expressions.

Parameters

text (~Text) – Text to highlighted.

class rich.highlighter.ReprHighlighter[source]

Highlights the text typically produced from __repr__ methods.