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

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components.json

+5
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

+33
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

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/prism-dns-zone-file.html

+14
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

+1
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

+1-1
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

+2
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

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
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.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
; comment
2+
3+
----------------------------------------------------
4+
5+
[
6+
["comment", "; comment"]
7+
]
8+
9+
----------------------------------------------------
10+
11+
Checks for comments.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"foo"
2+
"\""
3+
4+
----------------------------------------------------
5+
6+
[
7+
["string", "\"foo\""],
8+
["string", "\"\\\"\""]
9+
]
10+
11+
----------------------------------------------------
12+
13+
Checks for strings.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
A
2+
A6
3+
AAAA
4+
AFSDB
5+
APL
6+
ATMA
7+
CAA
8+
CDNSKEY
9+
CDS
10+
CERT
11+
CNAME
12+
DHCID
13+
DLV
14+
DNAME
15+
DNSKEY
16+
DS
17+
EID
18+
GID
19+
GPOS
20+
HINFO
21+
HIP
22+
IPSECKEY
23+
ISDN
24+
KEY
25+
KX
26+
LOC
27+
MAILA
28+
MAILB
29+
MB
30+
MD
31+
MF
32+
MG
33+
MINFO
34+
MR
35+
MX
36+
NAPTR
37+
NB
38+
NBSTAT
39+
NIMLOC
40+
NINFO
41+
NS
42+
NSAP
43+
NSAP-PTR
44+
NSEC
45+
NSEC3
46+
NSEC3PARAM
47+
NULL
48+
NXT
49+
OPENPGPKEY
50+
PTR
51+
PX
52+
RKEY
53+
RP
54+
RRSIG
55+
RT
56+
SIG
57+
SINK
58+
SMIMEA
59+
SOA
60+
SPF
61+
SRV
62+
SSHFP
63+
TA
64+
TKEY
65+
TLSA
66+
TSIG
67+
TXT
68+
UID
69+
UINFO
70+
UNSPEC
71+
URI
72+
WKS
73+
X25
74+
75+
----------------------------------------------------
76+
77+
[
78+
["type", "A"],
79+
["type", "A6"],
80+
["type", "AAAA"],
81+
["type", "AFSDB"],
82+
["type", "APL"],
83+
["type", "ATMA"],
84+
["type", "CAA"],
85+
["type", "CDNSKEY"],
86+
["type", "CDS"],
87+
["type", "CERT"],
88+
["type", "CNAME"],
89+
["type", "DHCID"],
90+
["type", "DLV"],
91+
["type", "DNAME"],
92+
["type", "DNSKEY"],
93+
["type", "DS"],
94+
["type", "EID"],
95+
["type", "GID"],
96+
["type", "GPOS"],
97+
["type", "HINFO"],
98+
["type", "HIP"],
99+
["type", "IPSECKEY"],
100+
["type", "ISDN"],
101+
["type", "KEY"],
102+
["type", "KX"],
103+
["type", "LOC"],
104+
["type", "MAILA"],
105+
["type", "MAILB"],
106+
["type", "MB"],
107+
["type", "MD"],
108+
["type", "MF"],
109+
["type", "MG"],
110+
["type", "MINFO"],
111+
["type", "MR"],
112+
["type", "MX"],
113+
["type", "NAPTR"],
114+
["type", "NB"],
115+
["type", "NBSTAT"],
116+
["type", "NIMLOC"],
117+
["type", "NINFO"],
118+
["type", "NS"],
119+
["type", "NSAP"],
120+
["type", "NSAP-PTR"],
121+
["type", "NSEC"],
122+
["type", "NSEC3"],
123+
["type", "NSEC3PARAM"],
124+
["type", "NULL"],
125+
["type", "NXT"],
126+
["type", "OPENPGPKEY"],
127+
["type", "PTR"],
128+
["type", "PX"],
129+
["type", "RKEY"],
130+
["type", "RP"],
131+
["type", "RRSIG"],
132+
["type", "RT"],
133+
["type", "SIG"],
134+
["type", "SINK"],
135+
["type", "SMIMEA"],
136+
["type", "SOA"],
137+
["type", "SPF"],
138+
["type", "SRV"],
139+
["type", "SSHFP"],
140+
["type", "TA"],
141+
["type", "TKEY"],
142+
["type", "TLSA"],
143+
["type", "TSIG"],
144+
["type", "TXT"],
145+
["type", "UID"],
146+
["type", "UINFO"],
147+
["type", "UNSPEC"],
148+
["type", "URI"],
149+
["type", "WKS"],
150+
["type", "X25"]
151+
]
152+
153+
----------------------------------------------------
154+
155+
Checks for all resource record types.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
$ORIGIN foo.bar.com
2+
@
3+
4+
----------------------------------------------------
5+
6+
[
7+
["keyword", "$ORIGIN"],
8+
["variable", "foo.bar.com"],
9+
["variable", "@"]
10+
]
11+
12+
----------------------------------------------------
13+
14+
Checks for variables.

0 commit comments

Comments
 (0)