Skip to content

Commit bb84f98

Browse files
Added support for DNS zone files (#1961)
This adds support for DNS zone files. The highlighting is quite simple as every type and class is highlighted as `keyword`. This is intentional as other token names (e.g. `class-name`, `function`, `builtin`, ...) are not highlighted by every theme resulting in large portions of unstyled text for some themes.
1 parent 7d05659 commit bb84f98

14 files changed

+269
-3
lines changed

components.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@
240240
"alias": "jinja2",
241241
"owner": "romanvm"
242242
},
243+
"dns-zone-file": {
244+
"title": "DNS zone file",
245+
"owner": "RunDevelopment",
246+
"alias": "dns-zone"
247+
},
243248
"docker": {
244249
"title": "Docker",
245250
"alias": "dockerfile",

components/prism-dns-zone-file.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Prism.languages['dns-zone-file'] = {
2+
'comment': /;.*/,
3+
'string': {
4+
pattern: /"(?:\\.|[^"\\\r\n])*"/,
5+
greedy: true
6+
},
7+
'variable': [
8+
{
9+
pattern: /(^\$ORIGIN[ \t]+)\S+/m,
10+
lookbehind: true,
11+
},
12+
{
13+
pattern: /(^|\s)@(?=\s|$)/,
14+
lookbehind: true,
15+
}
16+
],
17+
'keyword': /^\$(?:ORIGIN|INCLUDE|TTL)(?=\s|$)/m,
18+
'class': {
19+
// https://tools.ietf.org/html/rfc1035#page-13
20+
pattern: /(^|\s)(?:IN|CH|CS|HS)(?=\s|$)/,
21+
lookbehind: true,
22+
alias: 'keyword'
23+
},
24+
'type': {
25+
// https://en.wikipedia.org/wiki/List_of_DNS_record_types
26+
pattern: /(^|\s)(?:A|A6|AAAA|AFSDB|APL|ATMA|CAA|CDNSKEY|CDS|CERT|CNAME|DHCID|DLV|DNAME|DNSKEY|DS|EID|GID|GPOS|HINFO|HIP|IPSECKEY|ISDN|KEY|KX|LOC|MAILA|MAILB|MB|MD|MF|MG|MINFO|MR|MX|NAPTR|NB|NBSTAT|NIMLOC|NINFO|NS|NSAP|NSAP-PTR|NSEC|NSEC3|NSEC3PARAM|NULL|NXT|OPENPGPKEY|PTR|PX|RKEY|RP|RRSIG|RT|SIG|SINK|SMIMEA|SOA|SPF|SRV|SSHFP|TA|TKEY|TLSA|TSIG|TXT|UID|UINFO|UNSPEC|URI|WKS|X25)(?=\s|$)/,
27+
lookbehind: true,
28+
alias: 'keyword'
29+
},
30+
'punctuation': /[()]/
31+
};
32+
33+
Prism.languages['dns-zone'] = Prism.languages['dns-zone-file']

components/prism-dns-zone-file.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/prism-dns-zone-file.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<h2>Full example</h2>
2+
<pre><code>$TTL 3d
3+
@ IN SOA root.localhost. root.sneaky.net. (
4+
2015050503 ; serial
5+
12h ; refresh
6+
15m ; retry
7+
3w ; expire
8+
3h ; negative response TTL
9+
)
10+
IN NS root.localhost.
11+
IN NS localhost. ; secondary name server is preferably externally maintained
12+
13+
www IN A 3.141.59.26
14+
ww1 IN CNAME www</code></pre>

plugins/autoloader/prism-autoloader.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@
133133
"dotnet": "csharp",
134134
"coffee": "coffeescript",
135135
"jinja2": "django",
136+
"dns-zone": "dns-zone-file",
136137
"dockerfile": "docker",
137138
"gamemakerlanguage": "gml",
138139
"hs": "haskell",

plugins/autoloader/prism-autoloader.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/show-language/prism-show-language.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
"css-extras": "CSS Extras",
4646
"django": "Django/Jinja2",
4747
"jinja2": "Django/Jinja2",
48+
"dns-zone-file": "DNS zone file",
49+
"dns-zone": "DNS zone file",
4850
"dockerfile": "Docker",
4951
"ebnf": "Extended Backus–Naur form",
5052
"ejs": "EJS",

plugins/show-language/prism-show-language.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
IN
2+
CH
3+
CS
4+
HS
5+
6+
----------------------------------------------------
7+
8+
[
9+
["class", "IN"],
10+
["class", "CH"],
11+
["class", "CS"],
12+
["class", "HS"]
13+
]
14+
15+
----------------------------------------------------
16+
17+
Checks for all resource record classes.

0 commit comments

Comments
 (0)