-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
7d05659
commit bb84f98
Showing
14 changed files
with
269 additions
and
3 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
Prism.languages['dns-zone-file'] = { | ||
'comment': /;.*/, | ||
'string': { | ||
pattern: /"(?:\\.|[^"\\\r\n])*"/, | ||
greedy: true | ||
}, | ||
'variable': [ | ||
{ | ||
pattern: /(^\$ORIGIN[ \t]+)\S+/m, | ||
lookbehind: true, | ||
}, | ||
{ | ||
pattern: /(^|\s)@(?=\s|$)/, | ||
lookbehind: true, | ||
} | ||
], | ||
'keyword': /^\$(?:ORIGIN|INCLUDE|TTL)(?=\s|$)/m, | ||
'class': { | ||
// https://tools.ietf.org/html/rfc1035#page-13 | ||
pattern: /(^|\s)(?:IN|CH|CS|HS)(?=\s|$)/, | ||
lookbehind: true, | ||
alias: 'keyword' | ||
}, | ||
'type': { | ||
// https://en.wikipedia.org/wiki/List_of_DNS_record_types | ||
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|$)/, | ||
lookbehind: true, | ||
alias: 'keyword' | ||
}, | ||
'punctuation': /[()]/ | ||
}; | ||
|
||
Prism.languages['dns-zone'] = Prism.languages['dns-zone-file'] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<h2>Full example</h2> | ||
<pre><code>$TTL 3d | ||
@ IN SOA root.localhost. root.sneaky.net. ( | ||
2015050503 ; serial | ||
12h ; refresh | ||
15m ; retry | ||
3w ; expire | ||
3h ; negative response TTL | ||
) | ||
IN NS root.localhost. | ||
IN NS localhost. ; secondary name server is preferably externally maintained | ||
|
||
www IN A 3.141.59.26 | ||
ww1 IN CNAME www</code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
IN | ||
CH | ||
CS | ||
HS | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["class", "IN"], | ||
["class", "CH"], | ||
["class", "CS"], | ||
["class", "HS"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for all resource record classes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
; comment | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["comment", "; comment"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for comments. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"foo" | ||
"\"" | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["string", "\"foo\""], | ||
["string", "\"\\\"\""] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for strings. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
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 | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["type", "A"], | ||
["type", "A6"], | ||
["type", "AAAA"], | ||
["type", "AFSDB"], | ||
["type", "APL"], | ||
["type", "ATMA"], | ||
["type", "CAA"], | ||
["type", "CDNSKEY"], | ||
["type", "CDS"], | ||
["type", "CERT"], | ||
["type", "CNAME"], | ||
["type", "DHCID"], | ||
["type", "DLV"], | ||
["type", "DNAME"], | ||
["type", "DNSKEY"], | ||
["type", "DS"], | ||
["type", "EID"], | ||
["type", "GID"], | ||
["type", "GPOS"], | ||
["type", "HINFO"], | ||
["type", "HIP"], | ||
["type", "IPSECKEY"], | ||
["type", "ISDN"], | ||
["type", "KEY"], | ||
["type", "KX"], | ||
["type", "LOC"], | ||
["type", "MAILA"], | ||
["type", "MAILB"], | ||
["type", "MB"], | ||
["type", "MD"], | ||
["type", "MF"], | ||
["type", "MG"], | ||
["type", "MINFO"], | ||
["type", "MR"], | ||
["type", "MX"], | ||
["type", "NAPTR"], | ||
["type", "NB"], | ||
["type", "NBSTAT"], | ||
["type", "NIMLOC"], | ||
["type", "NINFO"], | ||
["type", "NS"], | ||
["type", "NSAP"], | ||
["type", "NSAP-PTR"], | ||
["type", "NSEC"], | ||
["type", "NSEC3"], | ||
["type", "NSEC3PARAM"], | ||
["type", "NULL"], | ||
["type", "NXT"], | ||
["type", "OPENPGPKEY"], | ||
["type", "PTR"], | ||
["type", "PX"], | ||
["type", "RKEY"], | ||
["type", "RP"], | ||
["type", "RRSIG"], | ||
["type", "RT"], | ||
["type", "SIG"], | ||
["type", "SINK"], | ||
["type", "SMIMEA"], | ||
["type", "SOA"], | ||
["type", "SPF"], | ||
["type", "SRV"], | ||
["type", "SSHFP"], | ||
["type", "TA"], | ||
["type", "TKEY"], | ||
["type", "TLSA"], | ||
["type", "TSIG"], | ||
["type", "TXT"], | ||
["type", "UID"], | ||
["type", "UINFO"], | ||
["type", "UNSPEC"], | ||
["type", "URI"], | ||
["type", "WKS"], | ||
["type", "X25"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for all resource record types. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
$ORIGIN foo.bar.com | ||
@ | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["keyword", "$ORIGIN"], | ||
["variable", "foo.bar.com"], | ||
["variable", "@"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for variables. |