Skip to content

Commit c701260

Browse files
committed
properly handle () within TXT records
1 parent d2ddb2b commit c701260

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

src/languages/dns.js

+22-12
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ export default function(hljs) {
4646
"TSIG",
4747
"TXT"
4848
];
49+
50+
const PUNCTUATION = {
51+
scope: 'punctuation',
52+
match: /\(|\)/
53+
};
54+
const STRING = {
55+
scope: 'string',
56+
begin: '"', end: '"'
57+
};
58+
4959
return {
5060
name: 'DNS Zone',
5161
aliases: [
@@ -55,24 +65,24 @@ export default function(hljs) {
5565
keywords: KEYWORDS,
5666
contains: [
5767
hljs.COMMENT(';', '$', { relevance: 0 }),
68+
STRING,
5869
{
59-
// Character strings
60-
scope: 'string',
61-
begin: '"', end: '"'
62-
},
63-
{
64-
scope: 'string',
65-
begin: /TXT.+/,
66-
keywords: KEYWORDS
70+
match: /TXT\s+/,
71+
keywords: KEYWORDS,
72+
contains: [
73+
STRING,
74+
PUNCTUATION,
75+
{
76+
match: /\S+/,
77+
scope: "string"
78+
}
79+
]
6780
},
6881
{
6982
className: 'meta',
7083
begin: /^\$(TTL|GENERATE|INCLUDE|ORIGIN)\b/
7184
},
72-
{
73-
scope: 'punctuation',
74-
match: /\(|\)/
75-
},
85+
PUNCTUATION,
7686
{
7787
scope: 'type',
7888
match: /IN|CH/

0 commit comments

Comments
 (0)