a | b/docs/custom_lexers.py | ||
---|---|---|---|
1 | import re |
||
2 | |||
3 | from pygments.lexers.shell import BashSessionLexer |
||
4 | from pygments.token import Number |
||
5 | |||
6 | class TerminalLexer(BashSessionLexer): |
||
7 | name = "terminal" |
||
8 | |||
9 | def get_tokens_unprocessed(self, text): |
||
10 | for index, token, value in BashSessionLexer.get_tokens_unprocessed( |
||
11 | self, text): |
||
12 | if re.match(r"\.\d+", value): |
||
13 | token = Number |
||
14 | yield index, token, value |