Skip to content

Commit f840384

Browse files
committed
php - fix custom tags appearing invalid
Fixes microsoft#76997
1 parent 3ee53ad commit f840384

4 files changed

Lines changed: 82 additions & 2 deletions

File tree

extensions/php/build/update-grammar.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ function adaptInjectionScope(grammar) {
2121
injections[newInjectionKey] = injection;
2222
}
2323

24+
function includeDerivativeHtml(grammar) {
25+
grammar.patterns.forEach(pattern => {
26+
if (pattern.include === 'text.html.basic') {
27+
pattern.include = 'text.html.derivative';
28+
}
29+
});
30+
}
31+
2432
// Workaround for https://github.com/Microsoft/vscode/issues/40279
2533
// and https://github.com/Microsoft/vscode-textmate/issues/59
2634
function fixBadRegex(grammar) {
@@ -61,4 +69,7 @@ function fixBadRegex(grammar) {
6169
}
6270

6371
updateGrammar.update('atom/language-php', 'grammars/php.cson', './syntaxes/php.tmLanguage.json', fixBadRegex);
64-
updateGrammar.update('atom/language-php', 'grammars/html.cson', './syntaxes/html.tmLanguage.json', adaptInjectionScope);
72+
updateGrammar.update('atom/language-php', 'grammars/html.cson', './syntaxes/html.tmLanguage.json', grammar => {
73+
adaptInjectionScope(grammar);
74+
includeDerivativeHtml(grammar);
75+
});

extensions/php/syntaxes/html.tmLanguage.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
"name": "comment.line.shebang.php"
130130
},
131131
{
132-
"include": "text.html.basic"
132+
"include": "text.html.derivative"
133133
}
134134
],
135135
"repository": {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<hello></hello>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
[
2+
{
3+
"c": "<",
4+
"t": "text.html.php meta.tag.other.unrecognized.html.derivative punctuation.definition.tag.begin.html",
5+
"r": {
6+
"dark_plus": "punctuation.definition.tag: #808080",
7+
"light_plus": "punctuation.definition.tag: #800000",
8+
"dark_vs": "punctuation.definition.tag: #808080",
9+
"light_vs": "punctuation.definition.tag: #800000",
10+
"hc_black": "punctuation.definition.tag: #808080"
11+
}
12+
},
13+
{
14+
"c": "hello",
15+
"t": "text.html.php meta.tag.other.unrecognized.html.derivative entity.name.tag.html",
16+
"r": {
17+
"dark_plus": "entity.name.tag: #569CD6",
18+
"light_plus": "entity.name.tag: #800000",
19+
"dark_vs": "entity.name.tag: #569CD6",
20+
"light_vs": "entity.name.tag: #800000",
21+
"hc_black": "entity.name.tag: #569CD6"
22+
}
23+
},
24+
{
25+
"c": ">",
26+
"t": "text.html.php meta.tag.other.unrecognized.html.derivative punctuation.definition.tag.end.html",
27+
"r": {
28+
"dark_plus": "punctuation.definition.tag: #808080",
29+
"light_plus": "punctuation.definition.tag: #800000",
30+
"dark_vs": "punctuation.definition.tag: #808080",
31+
"light_vs": "punctuation.definition.tag: #800000",
32+
"hc_black": "punctuation.definition.tag: #808080"
33+
}
34+
},
35+
{
36+
"c": "</",
37+
"t": "text.html.php meta.tag.other.unrecognized.html.derivative punctuation.definition.tag.begin.html",
38+
"r": {
39+
"dark_plus": "punctuation.definition.tag: #808080",
40+
"light_plus": "punctuation.definition.tag: #800000",
41+
"dark_vs": "punctuation.definition.tag: #808080",
42+
"light_vs": "punctuation.definition.tag: #800000",
43+
"hc_black": "punctuation.definition.tag: #808080"
44+
}
45+
},
46+
{
47+
"c": "hello",
48+
"t": "text.html.php meta.tag.other.unrecognized.html.derivative entity.name.tag.html",
49+
"r": {
50+
"dark_plus": "entity.name.tag: #569CD6",
51+
"light_plus": "entity.name.tag: #800000",
52+
"dark_vs": "entity.name.tag: #569CD6",
53+
"light_vs": "entity.name.tag: #800000",
54+
"hc_black": "entity.name.tag: #569CD6"
55+
}
56+
},
57+
{
58+
"c": ">",
59+
"t": "text.html.php meta.tag.other.unrecognized.html.derivative punctuation.definition.tag.end.html",
60+
"r": {
61+
"dark_plus": "punctuation.definition.tag: #808080",
62+
"light_plus": "punctuation.definition.tag: #800000",
63+
"dark_vs": "punctuation.definition.tag: #808080",
64+
"light_vs": "punctuation.definition.tag: #800000",
65+
"hc_black": "punctuation.definition.tag: #808080"
66+
}
67+
}
68+
]

0 commit comments

Comments
 (0)