markup syntax

This commit is contained in:
Will McGugan 2020-08-01 21:23:51 +01:00
parent 1f09278776
commit 7da3ee6299
4 changed files with 43 additions and 19 deletions

View file

@ -38,17 +38,14 @@ If your terminal software supports hyperlinks, you will be able to click the wor
Escaping
~~~~~~~~
Occasionally you may want to print something that Rich would interpret as markup. You can *escape* square brackets by doubling them up. Here's an example::
Occasionally you may want to print something that Rich would interpret as markup. You can *escape* a tab by preceding it with backslash. Here's an example::
>>> from rich import print
>>> print("foo[[bar]]")
>>> print("foo\[bar]")
foo[bar]
The function :func:`~rich.markup.escape` will handle escape of text for you.
.. warning::
Be careful when using f-strings with console markup. You will need to escape any variables if they could contain square brackets.
Rendering Markup
----------------