Fix html derivative grammar consuming php code, fixes #237262 (#245076)

Co-authored-by: Alex Ross <38270282+alexr00@users.noreply.github.com>
This commit is contained in:
KapitanOczywisty 2025-04-02 15:41:24 +02:00 committed by GitHub
parent c0fb773eb9
commit 4064f17252
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 1 deletions

View File

@ -32,6 +32,22 @@ function patchGrammar(grammar) {
console.warn(`Expected to patch 2 occurrences of source.js & source.css: Was ${patchCount}`);
}
return grammar;
}
function patchGrammarDerivative(grammar) {
let patchCount = 0;
let patterns = grammar.patterns;
for (let key in patterns) {
if (patterns[key]?.name === 'meta.tag.other.unrecognized.html.derivative' && patterns[key]?.begin === '(</?)(\\w[^\\s>]*)(?<!/)') {
patterns[key].begin = '(</?)(\\w[^\\s<>]*)(?<!/)';
patchCount++;
}
}
if (patchCount !== 1) {
console.warn(`Expected to do 1 patch: Was ${patchCount}`);
}
return grammar;
}
@ -40,4 +56,6 @@ const tsGrammarRepo = 'textmate/html.tmbundle';
const grammarPath = 'Syntaxes/HTML.plist';
vscodeGrammarUpdater.update(tsGrammarRepo, grammarPath, './syntaxes/html.tmLanguage.json', grammar => patchGrammar(grammar));
const grammarDerivativePath = 'Syntaxes/HTML%20%28Derivative%29.tmLanguage';
vscodeGrammarUpdater.update(tsGrammarRepo, grammarDerivativePath, './syntaxes/html-derivative.tmLanguage.json', grammar => patchGrammarDerivative(grammar));

View File

@ -23,7 +23,7 @@
"include": "text.html.basic#core-minus-invalid"
},
{
"begin": "(</?)(\\w[^\\s>]*)(?<!/)",
"begin": "(</?)(\\w[^\\s<>]*)(?<!/)",
"beginCaptures": {
"1": {
"name": "punctuation.definition.tag.begin.html"