rich.markup

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

A tag in console markup.

property markup

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: str) → str[source]

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

Parameters

markup (str) – Content to be inserted in to markup.

Returns

Markup with square brackets escaped.

Return type

str

rich.markup.render(markup: str, style: Union[str, rich.style.Style] = '', emoji: bool = True)rich.text.Text[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.

Raises

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

Returns

A test instance.

Return type

Text