From 6c858b7004475c271b2310f6f3de4b301d2c7b9e Mon Sep 17 00:00:00 2001 From: azerr Date: Tue, 24 Nov 2026 21:08:47 +0100 Subject: [PATCH 1/2] Improve DTD textmate Signed-off-by: azerr --- .../grammars/dtd/dtd.tmLanguage.json | 229 +++- org.eclipse.wildwebdeveloper.xml/plugin.xml | 7 +- .../snippets/dtd/sample.dtd | 1022 +++++++++++++++++ 3 files changed, 1231 insertions(+), 27 deletions(-) create mode 100644 org.eclipse.wildwebdeveloper.xml/snippets/dtd/sample.dtd diff --git a/org.eclipse.wildwebdeveloper.xml/grammars/dtd/dtd.tmLanguage.json b/org.eclipse.wildwebdeveloper.xml/grammars/dtd/dtd.tmLanguage.json index f6df471ead..554eeeacf7 100644 --- a/org.eclipse.wildwebdeveloper.xml/grammars/dtd/dtd.tmLanguage.json +++ b/org.eclipse.wildwebdeveloper.xml/grammars/dtd/dtd.tmLanguage.json @@ -5,43 +5,220 @@ "dtd" ], "patterns": [ - { - "begin": "(", + "endCaptures": { + "0": { "name": "punctuation.definition.comment.end.dtd" } }, - "end": "\\s*(>)", - "name": "meta.tag.type.dtd", + "name": "comment.block.dtd" + }, + "processing-instruction": { + "begin": "<\\?", + "beginCaptures": { + "0": { "name": "punctuation.definition.processing-instruction.begin.dtd" } + }, + "end": "\\?>", + "endCaptures": { + "0": { "name": "punctuation.definition.processing-instruction.end.dtd" } + }, + "name": "meta.processing-instruction.dtd", "patterns": [ { - "match": "\\s+(CDATA|IDREFS|IDREF|ID|NMTOKENS|NMTOKEN|ENTITY|ENTITIES|NOTATION|SYSTEM|NDATA)", - "name": "keyword.other.data-type.dtd" + "match": "\\G[a-zA-Z_][a-zA-Z0-9._-]*", + "name": "entity.name.processing-instruction.dtd" + } + ] + }, + "conditional-section": { + "patterns": [ + { + "begin": "", + "name": "meta.conditional.include.dtd", + "patterns": [{ "include": "$self" }] }, { - "match": "(#[A-Z]+)|(ANY)|(EMPTY)", + "begin": "", + "name": "meta.conditional.ignore.dtd", + "contentName": "comment.block.ignored.dtd" + } + ] + }, + "parameter-entity-ref": { + "match": "%[a-zA-Z_][a-zA-Z0-9._-]*;", + "name": "variable.other.parameter-entity.dtd" + }, + "entity-ref": { + "patterns": [ + { + "match": "&#x[0-9a-fA-F]+;", + "name": "constant.character.entity.hexadecimal.dtd" + }, + { + "match": "&#[0-9]+;", + "name": "constant.character.entity.decimal.dtd" + }, + { + "match": "&[a-zA-Z_][a-zA-Z0-9._-]*;", + "name": "constant.character.entity.named.dtd" + } + ] + }, + "string-double": { + "begin": "\"", + "beginCaptures": { + "0": { "name": "punctuation.definition.string.begin.dtd" } + }, + "end": "\"", + "endCaptures": { + "0": { "name": "punctuation.definition.string.end.dtd" } + }, + "name": "string.quoted.double.dtd", + "patterns": [ + { "include": "#entity-ref" }, + { "include": "#parameter-entity-ref" } + ] + }, + "string-single": { + "begin": "'", + "beginCaptures": { + "0": { "name": "punctuation.definition.string.begin.dtd" } + }, + "end": "'", + "endCaptures": { + "0": { "name": "punctuation.definition.string.end.dtd" } + }, + "name": "string.quoted.single.dtd", + "patterns": [ + { "include": "#entity-ref" }, + { "include": "#parameter-entity-ref" } + ] + }, + "string": { + "patterns": [ + { "include": "#string-double" }, + { "include": "#string-single" } + ] + }, + "element-declaration": { + "begin": "()", + "endCaptures": { + "1": { "name": "punctuation.definition.tag.dtd" } + }, + "name": "meta.declaration.element.dtd", + "patterns": [ + { + "match": "#PCDATA|\\b(ANY|EMPTY)\\b", "name": "constant.language.dtd" }, { - "begin": "'|\"", - "end": "'|\"", - "name": "string.quoted.double.dtd" + "match": "[|,?*+()]", + "name": "keyword.operator.dtd" }, + { "include": "#parameter-entity-ref" }, { - "begin": "(%[a-zA-Z][a-zA-Z0-9_-])", - "end": ";", - "name": "variable.language.dtd" + "match": "[a-zA-Z_][a-zA-Z0-9._-]*", + "name": "entity.name.element.ref.dtd" } ] }, - { - "begin": "()", - "name": "comment.block.dtd" + "attlist-declaration": { + "begin": "()", + "endCaptures": { + "1": { "name": "punctuation.definition.tag.dtd" } + }, + "name": "meta.declaration.attlist.dtd", + "patterns": [ + { + "match": "\\b(CDATA|IDREFS|IDREF|ID|NMTOKENS|NMTOKEN|ENTITIES|ENTITY|NOTATION)\\b", + "name": "keyword.other.data-type.dtd" + }, + { + "match": "#REQUIRED|#IMPLIED|#FIXED", + "name": "constant.language.dtd" + }, + { "include": "#string" }, + { "include": "#parameter-entity-ref" }, + { + "match": "[a-zA-Z_][a-zA-Z0-9._-]*", + "name": "variable.other.attribute-name.dtd" + } + ] + }, + "entity-declaration": { + "begin": "()", + "endCaptures": { + "1": { "name": "punctuation.definition.tag.dtd" } + }, + "name": "meta.declaration.entity.dtd", + "patterns": [ + { + "match": "\\b(SYSTEM|PUBLIC|NDATA)\\b", + "name": "keyword.other.dtd" + }, + { "include": "#string" }, + { "include": "#parameter-entity-ref" } + ] + }, + "notation-declaration": { + "begin": "()", + "endCaptures": { + "1": { "name": "punctuation.definition.tag.dtd" } + }, + "name": "meta.declaration.notation.dtd", + "patterns": [ + { + "match": "\\b(SYSTEM|PUBLIC)\\b", + "name": "keyword.other.dtd" + }, + { "include": "#string" } + ] } - ] -} \ No newline at end of file + } +} diff --git a/org.eclipse.wildwebdeveloper.xml/plugin.xml b/org.eclipse.wildwebdeveloper.xml/plugin.xml index 92445cabe3..ae6aa85e83 100644 --- a/org.eclipse.wildwebdeveloper.xml/plugin.xml +++ b/org.eclipse.wildwebdeveloper.xml/plugin.xml @@ -51,7 +51,7 @@ file-extensions="dtd" id="org.eclipse.wildwebdeveloper.dtd" name="DTD" - priority="low"> + priority="medium"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From c1fda57b5b22b40e5b1242853cb1f834f77b0a37 Mon Sep 17 00:00:00 2001 From: azerr Date: Wed, 25 Nov 2026 11:06:12 +0100 Subject: [PATCH 2/2] Fix DTD TextMate grammar: multi-line, qualified names, enumerations, nested IGNORE Multi-line declarations: TextMate evaluates begin expressions one line at a time, so never opened. Separate the keyword from the declaration name: begin only matches ( previously closed the outer IGNORE scope, exposing ignored declarations. Add an ignored-content rule that recursively balances pairs without interpreting their content, and reference it from the IGNORE contentName pattern. Signed-off-by: azerr --- .../grammars/dtd/dtd.tmLanguage.json | 518 ++++--- .../snippets/dtd/sample.dtd | 1279 ++++------------- 2 files changed, 551 insertions(+), 1246 deletions(-) diff --git a/org.eclipse.wildwebdeveloper.xml/grammars/dtd/dtd.tmLanguage.json b/org.eclipse.wildwebdeveloper.xml/grammars/dtd/dtd.tmLanguage.json index 554eeeacf7..b299abca96 100644 --- a/org.eclipse.wildwebdeveloper.xml/grammars/dtd/dtd.tmLanguage.json +++ b/org.eclipse.wildwebdeveloper.xml/grammars/dtd/dtd.tmLanguage.json @@ -1,224 +1,294 @@ -{ - "name": "DTD", - "scopeName": "text.xml.dtd", - "fileTypes": [ - "dtd" - ], - "patterns": [ - { "include": "#comment" }, - { "include": "#processing-instruction" }, - { "include": "#conditional-section" }, - { "include": "#element-declaration" }, - { "include": "#attlist-declaration" }, - { "include": "#entity-declaration" }, - { "include": "#notation-declaration" }, - { "include": "#parameter-entity-ref" } - ], - "repository": { - "comment": { - "begin": "", - "endCaptures": { - "0": { "name": "punctuation.definition.comment.end.dtd" } - }, - "name": "comment.block.dtd" - }, - "processing-instruction": { - "begin": "<\\?", - "beginCaptures": { - "0": { "name": "punctuation.definition.processing-instruction.begin.dtd" } - }, - "end": "\\?>", - "endCaptures": { - "0": { "name": "punctuation.definition.processing-instruction.end.dtd" } - }, - "name": "meta.processing-instruction.dtd", - "patterns": [ - { - "match": "\\G[a-zA-Z_][a-zA-Z0-9._-]*", - "name": "entity.name.processing-instruction.dtd" - } - ] - }, - "conditional-section": { - "patterns": [ - { - "begin": "", - "name": "meta.conditional.include.dtd", - "patterns": [{ "include": "$self" }] - }, - { - "begin": "", - "name": "meta.conditional.ignore.dtd", - "contentName": "comment.block.ignored.dtd" - } - ] - }, - "parameter-entity-ref": { - "match": "%[a-zA-Z_][a-zA-Z0-9._-]*;", - "name": "variable.other.parameter-entity.dtd" - }, - "entity-ref": { - "patterns": [ - { - "match": "&#x[0-9a-fA-F]+;", - "name": "constant.character.entity.hexadecimal.dtd" - }, - { - "match": "&#[0-9]+;", - "name": "constant.character.entity.decimal.dtd" - }, - { - "match": "&[a-zA-Z_][a-zA-Z0-9._-]*;", - "name": "constant.character.entity.named.dtd" - } - ] - }, - "string-double": { - "begin": "\"", - "beginCaptures": { - "0": { "name": "punctuation.definition.string.begin.dtd" } - }, - "end": "\"", - "endCaptures": { - "0": { "name": "punctuation.definition.string.end.dtd" } - }, - "name": "string.quoted.double.dtd", - "patterns": [ - { "include": "#entity-ref" }, - { "include": "#parameter-entity-ref" } - ] - }, - "string-single": { - "begin": "'", - "beginCaptures": { - "0": { "name": "punctuation.definition.string.begin.dtd" } - }, - "end": "'", - "endCaptures": { - "0": { "name": "punctuation.definition.string.end.dtd" } - }, - "name": "string.quoted.single.dtd", - "patterns": [ - { "include": "#entity-ref" }, - { "include": "#parameter-entity-ref" } - ] - }, - "string": { - "patterns": [ - { "include": "#string-double" }, - { "include": "#string-single" } - ] - }, - "element-declaration": { - "begin": "()", - "endCaptures": { - "1": { "name": "punctuation.definition.tag.dtd" } - }, - "name": "meta.declaration.element.dtd", - "patterns": [ - { - "match": "#PCDATA|\\b(ANY|EMPTY)\\b", - "name": "constant.language.dtd" - }, - { - "match": "[|,?*+()]", - "name": "keyword.operator.dtd" - }, - { "include": "#parameter-entity-ref" }, - { - "match": "[a-zA-Z_][a-zA-Z0-9._-]*", - "name": "entity.name.element.ref.dtd" - } - ] - }, - "attlist-declaration": { - "begin": "()", - "endCaptures": { - "1": { "name": "punctuation.definition.tag.dtd" } - }, - "name": "meta.declaration.attlist.dtd", - "patterns": [ - { - "match": "\\b(CDATA|IDREFS|IDREF|ID|NMTOKENS|NMTOKEN|ENTITIES|ENTITY|NOTATION)\\b", - "name": "keyword.other.data-type.dtd" - }, - { - "match": "#REQUIRED|#IMPLIED|#FIXED", - "name": "constant.language.dtd" - }, - { "include": "#string" }, - { "include": "#parameter-entity-ref" }, - { - "match": "[a-zA-Z_][a-zA-Z0-9._-]*", - "name": "variable.other.attribute-name.dtd" - } - ] - }, - "entity-declaration": { - "begin": "()", - "endCaptures": { - "1": { "name": "punctuation.definition.tag.dtd" } - }, - "name": "meta.declaration.entity.dtd", - "patterns": [ - { - "match": "\\b(SYSTEM|PUBLIC|NDATA)\\b", - "name": "keyword.other.dtd" - }, - { "include": "#string" }, - { "include": "#parameter-entity-ref" } - ] - }, - "notation-declaration": { - "begin": "()", - "endCaptures": { - "1": { "name": "punctuation.definition.tag.dtd" } - }, - "name": "meta.declaration.notation.dtd", - "patterns": [ - { - "match": "\\b(SYSTEM|PUBLIC)\\b", - "name": "keyword.other.dtd" - }, - { "include": "#string" } - ] - } - } -} +{ + "name": "DTD", + "scopeName": "text.xml.dtd", + "fileTypes": [ + "dtd" + ], + "patterns": [ + { "include": "#comment" }, + { "include": "#processing-instruction" }, + { "include": "#conditional-section" }, + { "include": "#element-declaration" }, + { "include": "#attlist-declaration" }, + { "include": "#entity-declaration" }, + { "include": "#notation-declaration" }, + { "include": "#parameter-entity-ref" } + ], + "repository": { + "comment": { + "begin": "", + "endCaptures": { + "0": { "name": "punctuation.definition.comment.end.dtd" } + }, + "name": "comment.block.dtd" + }, + "processing-instruction": { + "begin": "<\\?", + "beginCaptures": { + "0": { "name": "punctuation.definition.processing-instruction.begin.dtd" } + }, + "end": "\\?>", + "endCaptures": { + "0": { "name": "punctuation.definition.processing-instruction.end.dtd" } + }, + "name": "meta.processing-instruction.dtd", + "patterns": [ + { + "match": "\\G[\\p{L}_:][\\p{L}\\p{N}._:-]*", + "name": "entity.name.processing-instruction.dtd" + } + ] + }, + "conditional-section": { + "patterns": [ + { + "begin": "", + "patterns": [ + { + "begin": "(INCLUDE)\\s*\\[", + "beginCaptures": { + "1": { "name": "keyword.other.dtd" } + }, + "end": "(?=\\]\\]>)", + "name": "meta.conditional.include.dtd", + "patterns": [{ "include": "$self" }] + }, + { + "begin": "(IGNORE)\\s*\\[", + "beginCaptures": { + "1": { "name": "keyword.other.dtd" } + }, + "end": "(?=\\]\\]>)", + "name": "meta.conditional.ignore.dtd", + "contentName": "comment.block.ignored.dtd", + "patterns": [{ "include": "#ignored-content" }] + }, + { "include": "#parameter-entity-ref" }, + { + "begin": "\\[", + "end": "(?=\\]\\]>)", + "name": "meta.conditional.dtd", + "patterns": [{ "include": "$self" }] + } + ] + } + ] + }, + "ignored-content": { + "begin": "", + "patterns": [{ "include": "#ignored-content" }] + }, + "parameter-entity-ref": { + "match": "%[\\p{L}_:][\\p{L}\\p{N}._:-]*;", + "name": "variable.other.parameter-entity.dtd" + }, + "entity-ref": { + "patterns": [ + { + "match": "&#x[0-9a-fA-F]+;", + "name": "constant.character.entity.hexadecimal.dtd" + }, + { + "match": "&#[0-9]+;", + "name": "constant.character.entity.decimal.dtd" + }, + { + "match": "&[\\p{L}_:][\\p{L}\\p{N}._:-]*;", + "name": "constant.character.entity.named.dtd" + } + ] + }, + "string-double": { + "begin": "\"", + "beginCaptures": { + "0": { "name": "punctuation.definition.string.begin.dtd" } + }, + "end": "\"", + "endCaptures": { + "0": { "name": "punctuation.definition.string.end.dtd" } + }, + "name": "string.quoted.double.dtd", + "patterns": [ + { "include": "#entity-ref" }, + { "include": "#parameter-entity-ref" } + ] + }, + "string-single": { + "begin": "'", + "beginCaptures": { + "0": { "name": "punctuation.definition.string.begin.dtd" } + }, + "end": "'", + "endCaptures": { + "0": { "name": "punctuation.definition.string.end.dtd" } + }, + "name": "string.quoted.single.dtd", + "patterns": [ + { "include": "#entity-ref" }, + { "include": "#parameter-entity-ref" } + ] + }, + "string": { + "patterns": [ + { "include": "#string-double" }, + { "include": "#string-single" } + ] + }, + "element-declaration": { + "begin": "()", + "endCaptures": { + "1": { "name": "punctuation.definition.tag.dtd" } + }, + "name": "meta.declaration.element.dtd", + "patterns": [ + { + "begin": "(%[\\p{L}_:][\\p{L}\\p{N}._:-]*;|[\\p{L}_:][\\p{L}\\p{N}._:-]*)", + "beginCaptures": { + "1": { "name": "entity.name.tag.dtd" } + }, + "end": "(?=>)", + "patterns": [ + { + "match": "#PCDATA|\\b(ANY|EMPTY)\\b", + "name": "constant.language.dtd" + }, + { + "match": "[|,?*+()]", + "name": "keyword.operator.dtd" + }, + { "include": "#parameter-entity-ref" }, + { + "match": "[\\p{L}_:][\\p{L}\\p{N}._:-]*", + "name": "entity.name.element.ref.dtd" + } + ] + }, + { "include": "#parameter-entity-ref" } + ] + }, + "attlist-declaration": { + "begin": "()", + "endCaptures": { + "1": { "name": "punctuation.definition.tag.dtd" } + }, + "name": "meta.declaration.attlist.dtd", + "patterns": [ + { + "begin": "(%[\\p{L}_:][\\p{L}\\p{N}._:-]*;|[\\p{L}_:][\\p{L}\\p{N}._:-]*)", + "beginCaptures": { + "1": { "name": "entity.name.element.dtd" } + }, + "end": "(?=>)", + "patterns": [ + { + "match": "\\b(CDATA|IDREFS|IDREF|ID|NMTOKENS|NMTOKEN|ENTITIES|ENTITY|NOTATION)\\b", + "name": "keyword.other.data-type.dtd" + }, + { + "match": "#REQUIRED|#IMPLIED|#FIXED", + "name": "constant.language.dtd" + }, + { "include": "#string" }, + { + "begin": "\\(", + "beginCaptures": { "0": { "name": "keyword.operator.dtd" } }, + "end": "\\)", + "endCaptures": { "0": { "name": "keyword.operator.dtd" } }, + "patterns": [ + { "match": "\\|", "name": "keyword.operator.dtd" }, + { "include": "#parameter-entity-ref" }, + { + "match": "[\\p{L}\\p{N}._:-]+", + "name": "constant.other.enum-value.dtd" + } + ] + }, + { "include": "#parameter-entity-ref" }, + { + "match": "[\\p{L}_:][\\p{L}\\p{N}._:-]*", + "name": "variable.other.attribute-name.dtd" + } + ] + }, + { "include": "#parameter-entity-ref" } + ] + }, + "entity-declaration": { + "begin": "()", + "endCaptures": { + "1": { "name": "punctuation.definition.tag.dtd" } + }, + "name": "meta.declaration.entity.dtd", + "patterns": [ + { + "match": "%(?![\\p{L}_:])", + "name": "punctuation.definition.entity.dtd" + }, + { + "begin": "([\\p{L}_:][\\p{L}\\p{N}._:-]*)", + "beginCaptures": { + "1": { "name": "entity.name.entity.dtd" } + }, + "end": "(?=>)", + "patterns": [ + { + "match": "\\b(SYSTEM|PUBLIC|NDATA)\\b", + "name": "keyword.other.dtd" + }, + { "include": "#string" }, + { "include": "#parameter-entity-ref" } + ] + } + ] + }, + "notation-declaration": { + "begin": "()", + "endCaptures": { + "1": { "name": "punctuation.definition.tag.dtd" } + }, + "name": "meta.declaration.notation.dtd", + "patterns": [ + { + "begin": "([\\p{L}_:][\\p{L}\\p{N}._:-]*)", + "beginCaptures": { + "1": { "name": "entity.name.notation.dtd" } + }, + "end": "(?=>)", + "patterns": [ + { + "match": "\\b(SYSTEM|PUBLIC)\\b", + "name": "keyword.other.dtd" + }, + { "include": "#string" } + ] + } + ] + } + } +} diff --git a/org.eclipse.wildwebdeveloper.xml/snippets/dtd/sample.dtd b/org.eclipse.wildwebdeveloper.xml/snippets/dtd/sample.dtd index b4bd3908db..1cac7f5dae 100644 --- a/org.eclipse.wildwebdeveloper.xml/snippets/dtd/sample.dtd +++ b/org.eclipse.wildwebdeveloper.xml/snippets/dtd/sample.dtd @@ -1,1022 +1,257 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + +%common; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]]> + + + + + + + + + + + ]]> +]]> + + + + + + + + + +]]> + + +]]>