Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for DNS zone files #1961

Merged
merged 3 commits into from
Jul 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@
"alias": "jinja2",
"owner": "romanvm"
},
"dns-zone-file": {
"title": "DNS zone file",
"owner": "RunDevelopment",
"alias": "dns-zone"
},
"docker": {
"title": "Docker",
"alias": "dockerfile",
Expand Down
33 changes: 33 additions & 0 deletions components/prism-dns-zone-file.js
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']
1 change: 1 addition & 0 deletions components/prism-dns-zone-file.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions examples/prism-dns-zone-file.html
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>
1 change: 1 addition & 0 deletions plugins/autoloader/prism-autoloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
"dotnet": "csharp",
"coffee": "coffeescript",
"jinja2": "django",
"dns-zone": "dns-zone-file",
"dockerfile": "docker",
"gamemakerlanguage": "gml",
"hs": "haskell",
Expand Down
2 changes: 1 addition & 1 deletion plugins/autoloader/prism-autoloader.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions plugins/show-language/prism-show-language.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
"css-extras": "CSS Extras",
"django": "Django/Jinja2",
"jinja2": "Django/Jinja2",
"dns-zone-file": "DNS zone file",
"dns-zone": "DNS zone file",
"dockerfile": "Docker",
"ebnf": "Extended Backus–Naur form",
"ejs": "EJS",
Expand Down
2 changes: 1 addition & 1 deletion plugins/show-language/prism-show-language.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions tests/languages/dns-zone-file/class_feature.test
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.
11 changes: 11 additions & 0 deletions tests/languages/dns-zone-file/comment_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
; comment

----------------------------------------------------

[
["comment", "; comment"]
]

----------------------------------------------------

Checks for comments.
13 changes: 13 additions & 0 deletions tests/languages/dns-zone-file/string_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"foo"
"\""

----------------------------------------------------

[
["string", "\"foo\""],
["string", "\"\\\"\""]
]

----------------------------------------------------

Checks for strings.
155 changes: 155 additions & 0 deletions tests/languages/dns-zone-file/type_featrue.test
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.
14 changes: 14 additions & 0 deletions tests/languages/dns-zone-file/variable_feature.test
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.