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

edit DNS grammar #3768

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ Core Grammars:
- fix(nix) handle backslash string escapes [h7x4][]
- fix(nix) don't mix escapes for `"` and `''` strings [h7x4][]
- fix(swift) - Fixed syntax highlighting for class func/var declarations [guuido]

- enh(dns) add support for character strings and modification of DNS registration type recognition [Checconio][]

New Grammars:

- added 3rd party TTCN-3 grammar to SUPPORTED_LANGUAGES [Osmocom][]
Expand Down Expand Up @@ -80,6 +81,7 @@ CONTRIBUTORS
[Lavan]: https://github.com/jvlavan
[Somya]: https://github.com/somya-05
[guuido]: https://github.com/guuido
[Checconio]: https://github.com/Checconio


## Version 11.10.0
Expand Down
40 changes: 39 additions & 1 deletion src/languages/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Website: https://en.wikipedia.org/wiki/Zone_file
/** @type LanguageFn */
export default function(hljs) {
const KEYWORDS = [
"IN",
"A",
"AAAA",
"AFSDB",
Expand Down Expand Up @@ -47,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 @@ -56,10 +65,39 @@ export default function(hljs) {
keywords: KEYWORDS,
contains: [
hljs.COMMENT(';', '$', { relevance: 0 }),
STRING,
// {
// match: /TXT\s+/,
// keywords: KEYWORDS,
// contains: [
// STRING,
// PUNCTUATION,
// {
// match: /\S+/,
// scope: "string"
// }
// ]
// },
{
match: [
/TXT/,
/\s+/,
/(?!")\S+($|(?=;))/
],
scope: {
1: "keyword",
3: "string"
}
},
{
className: 'meta',
begin: /^\$(TTL|GENERATE|INCLUDE|ORIGIN)\b/
},
PUNCTUATION,
{
scope: 'type',
match: /IN|CH/
},
// IPv6
{
className: 'number',
Expand Down
Loading