Skip to content

Commit

Permalink
TextMate grammar for *.dtd files
Browse files Browse the repository at this point in the history
Fixes redhat-developer#313

Signed-off-by: azerr <azerr@redhat.com>
  • Loading branch information
angelozerr committed May 19, 2022
1 parent ad42b24 commit 4f7da08
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 10 deletions.
30 changes: 21 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,27 @@
"yauzl": "^2.10.0"
},
"contributes": {
"languages": [
{
"id": "dtd",
"extensions": [
".dtd",
".ent",
".mod"
],
"aliases": [
"DTD",
"dtd"
]
}
],
"grammars": [
{
"language": "dtd",
"scopeName": "text.xml.dtd",
"path": "./syntaxes/dtd.tmLanguage.json"
}
],
"configuration": {
"type": "object",
"title": "XML",
Expand Down Expand Up @@ -562,15 +583,6 @@
}
]
},
"languages": [
{
"id": "xml",
"extensions": [
".ent",
".mod"
]
}
],
"jsonValidation": [
{
"fileMatch": "package.json",
Expand Down
4 changes: 3 additions & 1 deletion src/client/xmlClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,10 @@ function getLanguageClientOptions(
documentSelector: [
{ scheme: 'file', language: 'xml' },
{ scheme: 'file', language: 'xsl' },
{ scheme: 'file', language: 'dtd' },
{ scheme: 'untitled', language: 'xml' },
{ scheme: 'untitled', language: 'xsl' }
{ scheme: 'untitled', language: 'xsl' },
{ scheme: 'untitled', language: 'dtd' },
],
revealOutputChannelOn: RevealOutputChannelOn.Never,
//wrap with key 'settings' so it can be handled same a DidChangeConfiguration
Expand Down
47 changes: 47 additions & 0 deletions syntaxes/dtd.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "DTD",
"scopeName": "text.xml.dtd",
"fileTypes": [
"dtd"
],
"patterns": [
{
"begin": "(<!)(ELEMENT|ATTLIST|ENTITY|NOTATION)",
"captures": {
"1": {
"name": "punctuation.definition.tag.dtd"
},
"2": {
"name": "entity.name.tag.dtd"
}
},
"end": "\\s*(>)",
"name": "meta.tag.type.dtd",
"patterns": [
{
"match": "\\s+(CDATA|IDREFS|IDREF|ID|NMTOKENS|NMTOKEN|ENTITY|ENTITIES|NOTATION|SYSTEM|NDATA)",
"name": "keyword.other.data-type.dtd"
},
{
"match": "(#[A-Z]+)|(ANY)|(EMPTY)",
"name": "constant.language.dtd"
},
{
"begin": "'|\"",
"end": "'|\"",
"name": "string.quoted.double.dtd"
},
{
"begin": "(%[a-zA-Z][a-zA-Z0-9_-])",
"end": ";",
"name": "variable.language.dtd"
}
]
},
{
"begin": "(<!--)",
"end": "(-->)",
"name": "comment.block.dtd"
}
]
}

0 comments on commit 4f7da08

Please sign in to comment.