| 121 | ] |
| 122 | |
| 123 | def highlight(self, text: Text) -> None: |
| 124 | super().highlight(text) |
| 125 | |
| 126 | # Additional work to handle highlighting JSON keys |
| 127 | plain = text.plain |
| 128 | append = text.spans.append |
| 129 | whitespace = self.JSON_WHITESPACE |
| 130 | for match in re.finditer(self.JSON_STR, plain): |
| 131 | start, end = match.span() |
| 132 | cursor = end |
| 133 | while cursor < len(plain): |
| 134 | char = plain[cursor] |
| 135 | cursor += 1 |
| 136 | if char == ":": |
| 137 | append(Span(start, end, "json.key")) |
| 138 | elif char in whitespace: |
| 139 | continue |
| 140 | break |
| 141 | |
| 142 | |
| 143 | class ISO8601Highlighter(RegexHighlighter): |