Server : nginx/1.24.0 System : Linux ip-172-31-33-48 6.14.0-1011-aws #11~24.04.1-Ubuntu SMP Fri Aug 1 02:07:25 UTC 2025 x86_64 User : www-data ( 33) PHP Version : 8.3.6 Disable Function : NONE Directory : /usr/share/doc/python3-rich/examples/ |
Upload File : |
""" This example demonstrates a simple text highlighter. """ from rich.console import Console from rich.highlighter import RegexHighlighter from rich.theme import Theme class EmailHighlighter(RegexHighlighter): """Apply style to anything that looks like an email.""" base_style = "example." highlights = [r"(?P<email>[\w-]+@([\w-]+\.)+[\w-]+)"] theme = Theme({"example.email": "bold magenta"}) console = Console(highlighter=EmailHighlighter(), theme=theme) console.print("Send funds to money@example.org")