richprutt/highlighters/communication.py
2025-10-26 19:48:02 +01:00

16 lines
544 B
Python

from rich.console import Console
from rich.highlighter import RegexHighlighter
from rich.theme import Theme
class Email_Highlighter(RegexHighlighter):
"""Apply style to anything that looks like an email."""
base_style = "communication."
highlights = [r"(?P<email>[\w-]+@([\w-]+\.)+[\w-]+)"]
class Swedish_Phone_Number_Highlighter(RegexHighlighter):
"""Apply style to anything that looks like a swedish mobile number."""
base_style = "communication."
highlights = [r"(\+46|0)(7[02369])(| )(\d{7}|\d{3} \d{2} \d{2})"]