Merge pull request #82377 from microsoft/fix/php-custom-tags

php - fix custom tags appearing invalid
This commit is contained in:
Rob Lourens 2019-10-14 16:00:04 -07:00 committed by GitHub
commit 3e1276cb51
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 82 additions and 2 deletions

View file

@ -21,6 +21,14 @@ function adaptInjectionScope(grammar) {
injections[newInjectionKey] = injection;
}
function includeDerivativeHtml(grammar) {
grammar.patterns.forEach(pattern => {
if (pattern.include === 'text.html.basic') {
pattern.include = 'text.html.derivative';
}
});
}
// Workaround for https://github.com/Microsoft/vscode/issues/40279
// and https://github.com/Microsoft/vscode-textmate/issues/59
function fixBadRegex(grammar) {
@ -61,4 +69,7 @@ function fixBadRegex(grammar) {
}
updateGrammar.update('atom/language-php', 'grammars/php.cson', './syntaxes/php.tmLanguage.json', fixBadRegex);
updateGrammar.update('atom/language-php', 'grammars/html.cson', './syntaxes/html.tmLanguage.json', adaptInjectionScope);
updateGrammar.update('atom/language-php', 'grammars/html.cson', './syntaxes/html.tmLanguage.json', grammar => {
adaptInjectionScope(grammar);
includeDerivativeHtml(grammar);
});

View file

@ -129,7 +129,7 @@
"name": "comment.line.shebang.php"
},
{
"include": "text.html.basic"
"include": "text.html.derivative"
}
],
"repository": {

View file

@ -0,0 +1 @@
<hello></hello>

View file

@ -0,0 +1,68 @@
[
{
"c": "<",
"t": "text.html.php meta.tag.other.unrecognized.html.derivative punctuation.definition.tag.begin.html",
"r": {
"dark_plus": "punctuation.definition.tag: #808080",
"light_plus": "punctuation.definition.tag: #800000",
"dark_vs": "punctuation.definition.tag: #808080",
"light_vs": "punctuation.definition.tag: #800000",
"hc_black": "punctuation.definition.tag: #808080"
}
},
{
"c": "hello",
"t": "text.html.php meta.tag.other.unrecognized.html.derivative entity.name.tag.html",
"r": {
"dark_plus": "entity.name.tag: #569CD6",
"light_plus": "entity.name.tag: #800000",
"dark_vs": "entity.name.tag: #569CD6",
"light_vs": "entity.name.tag: #800000",
"hc_black": "entity.name.tag: #569CD6"
}
},
{
"c": ">",
"t": "text.html.php meta.tag.other.unrecognized.html.derivative punctuation.definition.tag.end.html",
"r": {
"dark_plus": "punctuation.definition.tag: #808080",
"light_plus": "punctuation.definition.tag: #800000",
"dark_vs": "punctuation.definition.tag: #808080",
"light_vs": "punctuation.definition.tag: #800000",
"hc_black": "punctuation.definition.tag: #808080"
}
},
{
"c": "</",
"t": "text.html.php meta.tag.other.unrecognized.html.derivative punctuation.definition.tag.begin.html",
"r": {
"dark_plus": "punctuation.definition.tag: #808080",
"light_plus": "punctuation.definition.tag: #800000",
"dark_vs": "punctuation.definition.tag: #808080",
"light_vs": "punctuation.definition.tag: #800000",
"hc_black": "punctuation.definition.tag: #808080"
}
},
{
"c": "hello",
"t": "text.html.php meta.tag.other.unrecognized.html.derivative entity.name.tag.html",
"r": {
"dark_plus": "entity.name.tag: #569CD6",
"light_plus": "entity.name.tag: #800000",
"dark_vs": "entity.name.tag: #569CD6",
"light_vs": "entity.name.tag: #800000",
"hc_black": "entity.name.tag: #569CD6"
}
},
{
"c": ">",
"t": "text.html.php meta.tag.other.unrecognized.html.derivative punctuation.definition.tag.end.html",
"r": {
"dark_plus": "punctuation.definition.tag: #808080",
"light_plus": "punctuation.definition.tag: #800000",
"dark_vs": "punctuation.definition.tag: #808080",
"light_vs": "punctuation.definition.tag: #800000",
"hc_black": "punctuation.definition.tag: #808080"
}
}
]