rich.markup

class rich.markup.Tag(name, parameters)[source]

A tag in console markup.

Parameters
property markup: str

Get the string representation of this tag.

property name

The tag name. e.g. ‘bold’.

property parameters

Any additional parameters after the name.

rich.markup.escape(markup, _escape=<built-in method sub of re.Pattern object>)[source]

Escapes text so that it won’t be interpreted as markup.

Parameters
Returns

Markup with square brackets escaped.

Return type

str

rich.markup.render(markup, style='', emoji=True, emoji_variant=None)[source]

Render console markup in to a Text instance.

Parameters
  • markup (str) – A string containing console markup.

  • emoji (bool, optional) – Also render emoji code. Defaults to True.

  • style (Union[str, rich.style.Style]) –

  • emoji_variant (Optional[typing_extensions.Literal[emoji, text]]) –

Raises

MarkupError – If there is a syntax error in the markup.

Returns

A test instance.

Return type

Text