feat: highlight ip6.arpa question with separation at upper-half hextet boundaries

This commit is contained in:
s3lph 2023-01-03 09:02:54 +01:00
parent 18ecc98014
commit e521fffed2
Signed by: s3lph
GPG key ID: 8AC98A811E5BEFF5

View file

@ -47,12 +47,23 @@ class CustomLexer(ExtendedRegexLexer):
yield re.start('nadd'), String.Doc, re.group('nadd') yield re.start('nadd'), String.Doc, re.group('nadd')
ctx.pos = re.end() ctx.pos = re.end()
def parse_rdns(lexer, re, ctx):
yield re.start('c1'), Comment.Hashbang, re.group('c1')
yield re.start('pl64'), Name.Class, re.group('pl64')
yield re.start('pl48'), Number.Integer, re.group('pl48')
yield re.start('pl32'), Name.Class, re.group('pl32')
yield re.start('pl16'), Name.Tag, re.group('pl16')
yield re.start('pl0'), String.Doc, re.group('pl0')
yield re.start('end'), Comment.Hashbang, re.group('end')
ctx.pos = re.end()
tokens = { tokens = {
'root': [ 'root': [
(r'(?P<c1>; <<>>)(?P<version>.*)(?P<c2><<>>)(?P<query>.*\n)', parse_dig_header), (r'(?P<c1>; <<>>)(?P<version>.*)(?P<c2><<>>)(?P<query>.*\n)', parse_dig_header),
(r'(?P<c1>;; ->>HEADER<<- opcode: )(?P<opcode>[^\s]+)(?P<c2>, status: )(?P<rcode>[^\s]+)(?P<c3>, id: )(?P<nonce>[^\s]+\n)(?P<c4>;; flags: )(?P<flags>[^;]+)(?P<c5>; QUERY: )(?P<nquery>\d+)(?P<c6>, ANSWER: )(?P<nanswer>\d+)(?P<c7>, AUTHORITY: )(?P<nauth>\d+)(?P<c8>, ADDITIONAL: )(?P<nadd>\d+\n)', parse_response_header), (r'(?P<c1>;; ->>HEADER<<- opcode: )(?P<opcode>[^\s]+)(?P<c2>, status: )(?P<rcode>[^\s]+)(?P<c3>, id: )(?P<nonce>[^\s]+\n)(?P<c4>;; flags: )(?P<flags>[^;]+)(?P<c5>; QUERY: )(?P<nquery>\d+)(?P<c6>, ANSWER: )(?P<nanswer>\d+)(?P<c7>, AUTHORITY: )(?P<nauth>\d+)(?P<c8>, ADDITIONAL: )(?P<nadd>\d+\n)', parse_response_header),
(r'(?P<c1>;)(?P<pl64>([0-9a-fA-F]\.){16})(?P<pl48>([0-9a-fA-F]\.){4})(?P<pl32>([0-9a-fA-F]\.){4})(?P<pl16>([0-9a-fA-F]\.){4})(?P<pl0>([0-9a-fA-F]\.){4})(?P<end>ip6\.arpa\..*$)', parse_rdns),
(r';;.*', Generic.Subheading), # comment section headers (r';;.*', Generic.Subheading), # comment section headers
(r';.*', Comment.Single), # comment section headers (r';.*', Comment.Single),
(r'\n', Generic), (r'\n', Generic),
(r'^', Generic, 'rname') (r'^', Generic, 'rname')
], ],