dropped markdown style syntax in console markup

This commit is contained in:
Will McGugan 2020-03-10 21:39:12 +00:00
parent d4388412ef
commit 1f207d97d6
4 changed files with 6 additions and 51 deletions

View file

@ -6,29 +6,14 @@ Console Markup
Rich supports a simple markup which you can use to insert color and styles virtually everywhere Rich would accept a string (e.g. :meth:`~rich.console.Console.print` and :meth:`~rich.console.Console.log`).
Formatting
----------
Syntax
------
for bold, italic, and strikethrough, Rich uses the same convention as Markdown::
For italics, wrap text in asterisks or underscores, e.g. ``*this is italics*`` or ``_this is also italics_``.
For bold, wrap the text in *two* asterisks or underscores. e.g. ``**this is bold**`` or ``__this is also bold__``.
For strikethrough, wrap the text in tildes. e.g. ``~this has a line through it~``.
For code, wrap the text in backticks. e.g. ```import this```
Styling
-------
For other styles and color, you can use a syntax similar to bbcode. If you write the style (see :ref:`styles`) in square brackets, i.e. ``[bold red]``, that style will apply until it is *closed* with a corresponding ``[/bold red]``.
Console markup uses a syntax inspired by [bbcode](https://en.wikipedia.org/wiki/BBCode). If you write the style (see :ref:`styles`) in square brackets, i.e. ``[bold red]``, that style will apply until it is *closed* with a corresponding ``[/bold red]``.
Here's a simple example::
from rich import print
print("Hello, **World**!")
print("[bold red]alert![/bold red] *Something happened*")
If you don't close a style, it will apply until the end of the string. Which is sometimes convenient if you want to style a single line. For example::