Skip to content

Commit

Permalink
properly handle () within TXT records
Browse files Browse the repository at this point in the history
  • Loading branch information
joshgoebel committed May 25, 2023
1 parent 9c21f20 commit 4be1346
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions src/languages/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ export default function(hljs) {
"TSIG",
"TXT"
];

const PUNCTUATION = {
scope: 'punctuation',
match: /\(|\)/
};
const STRING = {
scope: 'string',
begin: '"', end: '"'
};

return {
name: 'DNS Zone',
aliases: [
Expand All @@ -55,24 +65,24 @@ export default function(hljs) {
keywords: KEYWORDS,
contains: [
hljs.COMMENT(';', '$', { relevance: 0 }),
STRING,
{
// Character strings
scope: 'string',
begin: '"', end: '"'
},
{
scope: 'string',
begin: /TXT.+/,
keywords: KEYWORDS
match: /TXT\s+/,
keywords: KEYWORDS,
contains: [
STRING,
PUNCTUATION,
{
match: /\S+/,
scope: "string"
}
]
},
{
className: 'meta',
begin: /^\$(TTL|GENERATE|INCLUDE|ORIGIN)\b/
},
{
scope: 'punctuation',
match: /\(|\)/
},
PUNCTUATION,
{
scope: 'type',
match: /IN|CH/
Expand Down

0 comments on commit 4be1346

Please sign in to comment.