php - fix custom tags appearing invalid

Fixes https://github.com/microsoft/vscode/issues/76997
This commit is contained in:
Connor Peet
2019-10-10 15:59:58 -07:00
parent 3ee53ad714
commit f840384927
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);
});