Highlights the text typically produced from ``__repr__`` methods.
| 78 | |
| 79 | |
| 80 | class ReprHighlighter(RegexHighlighter): |
| 81 | """Highlights the text typically produced from ``__repr__`` methods.""" |
| 82 | |
| 83 | base_style = "repr." |
| 84 | highlights: ClassVar[Sequence[str]] = [ |
| 85 | r"(?P<tag_start><)(?P<tag_name>[-\w.:|]*)(?P<tag_contents>[\w\W]*)(?P<tag_end>>)", |
| 86 | r'(?P<attrib_name>[\w_]{1,50})=(?P<attrib_value>"?[\w_]+"?)?', |
| 87 | r"(?P<brace>[][{}()])", |
| 88 | _combine_regex( |
| 89 | r"(?P<ipv4>[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", |
| 90 | r"(?P<ipv6>([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4})", |
| 91 | r"(?P<eui64>(?:[0-9A-Fa-f]{1,2}-){7}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{1,2}:){7}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{4}\.){3}[0-9A-Fa-f]{4})", |
| 92 | r"(?P<eui48>(?:[0-9A-Fa-f]{1,2}-){5}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{1,2}:){5}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{4}\.){2}[0-9A-Fa-f]{4})", |
| 93 | r"(?P<uuid>[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12})", |
| 94 | r"(?P<call>[\w.]*?)\(", |
| 95 | r"\b(?P<bool_true>True)\b|\b(?P<bool_false>False)\b|\b(?P<none>None)\b", |
| 96 | r"(?P<ellipsis>\.\.\.)", |
| 97 | r"(?P<number_complex>(?<!\w)(?:\-?[0-9]+\.?[0-9]*(?:e[-+]?\d+?)?)(?:[-+](?:[0-9]+\.?[0-9]*(?:e[-+]?\d+)?))?j)", |
| 98 | r"(?P<number>(?<!\w)\-?[0-9]+\.?[0-9]*(e[-+]?\d+?)?\b|0x[0-9a-fA-F]*)", |
| 99 | r"(?P<path>\B(/[-\w._+]+)*\/)(?P<filename>[-\w._+]*)?", |
| 100 | r"(?<![\\\w])(?P<str>b?'''.*?(?<!\\)'''|b?'.*?(?<!\\)'|b?\"\"\".*?(?<!\\)\"\"\"|b?\".*?(?<!\\)\")", |
| 101 | r"(?P<url>(file|https|http|ws|wss)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#~@]*)", |
| 102 | ), |
| 103 | ] |
| 104 | |
| 105 | |
| 106 | class JSONHighlighter(RegexHighlighter): |