2020-05-15 12:03:39 +00:00
|
|
|
from rich.console import Console
|
2020-05-08 12:36:12 +00:00
|
|
|
from rich.highlighter import RegexHighlighter
|
2020-05-15 12:03:39 +00:00
|
|
|
from rich.theme import Theme
|
2020-05-08 12:36:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
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")
|