Skip to content

Commit

Permalink
docs on highlighters
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Jan 13, 2023
1 parent 0c1aeda commit 50d7df7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions docs/source/highlighting.rst
Expand Up @@ -3,8 +3,7 @@
Highlighting
============

Rich can apply styles to patterns in text which you :meth:`~rich.console.Console.print` or :meth:`~rich.console.Console.log`. With the default settings, Rich will highlight things such as numbers, strings, collections, booleans, None, and a few more exotic patterns such as file paths, URLs and UUIDs.
Additional non-default highlighter are available, such as :class:`~rich.highlighter.ISO8601Highlighter` to highlight date and time.
Rich will automatically highlight patterns in text, such as numbers, strings, collections, booleans, None, and a few more exotic patterns such as file paths, URLs and UUIDs.

You can disable highlighting either by setting ``highlight=False`` on :meth:`~rich.console.Console.print` or :meth:`~rich.console.Console.log`, or by setting ``highlight=False`` on the :class:`~rich.console.Console` constructor which disables it everywhere. If you disable highlighting on the constructor, you can still selectively *enable* highlighting with ``highlight=True`` on print/log.

Expand Down Expand Up @@ -59,3 +58,11 @@ Here's a silly example that highlights every character with a different color::

rainbow = RainbowHighlighter()
print(rainbow("I must not fear. Fear is the mind-killer."))

Builtin Highlighters
--------------------

The following builtin highlighters are available.

* :class:`~rich.highlighter.ISO8601Highlighter` Highlights ISO8601 date time strings.
* :class:`~rich.highlighter.JSONHighlighter` Highlights JSON formatted strings.

0 comments on commit 50d7df7

Please sign in to comment.