提交 18bab626 编写于 作者: M Martin Aeschlimann

[html] issues caused by HTML grammar associating '<' with JS. Fixes #86998

上级 c97c457d
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// @ts-check
'use strict';
var updateGrammar = require('../../../build/npm/update-grammar');
function patchGrammar(grammar) {
let patchCount = 0;
let visit = function (rule, parent) {
if (rule.name === 'source.js' || rule.name === 'source.css') {
if (parent.parent && parent.parent.property === 'endCaptures') {
rule.name = rule.name + '-ignored-vscode';
patchCount++;
}
}
for (let property in rule) {
let value = rule[property];
if (typeof value === 'object') {
visit(value, { node: rule, property: property, parent: parent });
}
}
};
let repository = grammar.repository;
for (let key in repository) {
visit(repository[key], { node: repository, property: key, parent: undefined });
}
if (patchCount !== 6) {
console.warn(`Expected to patch 6 occurrences of source.js & source.css: Was ${patchCount}`);
}
return grammar;
}
const tsGrammarRepo = 'textmate/html.tmbundle';
const grammarPath = 'Syntaxes/HTML.plist';
updateGrammar.update(tsGrammarRepo, grammarPath, './syntaxes/html.tmLanguage.json', grammar => patchGrammar(grammar));
......@@ -9,7 +9,7 @@
"vscode": "0.10.x"
},
"scripts": {
"update-grammar": "node ../../build/npm/update-grammar.js textmate/html.tmbundle Syntaxes/HTML.plist ./syntaxes/html.tmLanguage.json Syntaxes/HTML%20%28Derivative%29.tmLanguage ./syntaxes/html-derivative.tmLanguage.json"
"update-grammar": "node ./build/update-grammar.js"
},
"contributes": {
"languages": [
......
......@@ -108,7 +108,7 @@
"name": "punctuation.definition.string.end.html"
},
"1": {
"name": "source.css"
"name": "source.css-ignored-vscode"
}
},
"name": "string.quoted.double.html",
......@@ -132,7 +132,7 @@
"name": "punctuation.definition.string.end.html"
},
"1": {
"name": "source.css"
"name": "source.css-ignored-vscode"
}
},
"name": "string.quoted.single.html",
......@@ -207,7 +207,7 @@
"name": "punctuation.definition.string.end.html"
},
"1": {
"name": "source.js"
"name": "source.js-ignored-vscode"
}
},
"name": "string.quoted.double.html",
......@@ -265,7 +265,7 @@
"name": "punctuation.definition.string.end.html"
},
"1": {
"name": "source.js"
"name": "source.js-ignored-vscode"
}
},
"name": "string.quoted.single.html",
......@@ -1785,7 +1785,7 @@
"name": "punctuation.definition.tag.begin.html"
},
"2": {
"name": "source.css"
"name": "source.css-ignored-vscode"
},
"3": {
"name": "entity.name.tag.html"
......@@ -1892,7 +1892,7 @@
"name": "punctuation.definition.tag.begin.html"
},
"2": {
"name": "source.js"
"name": "source.js-ignored-vscode"
}
},
"patterns": [
......
<script>console.log('x')</script>
<style>test { display: none }</style>
<a onblur="doBlur()" onclick='doClick()' ondrag=doDrag()></a>
<div style="x { }"></div>
<div style='y { }'></div>
<div style=z{}></div>
......@@ -210,7 +210,7 @@
},
{
"c": "<",
"t": "text.html.derivative meta.embedded.block.html meta.tag.metadata.script.end.html punctuation.definition.tag.begin.html source.js",
"t": "text.html.derivative meta.embedded.block.html meta.tag.metadata.script.end.html punctuation.definition.tag.begin.html source.js-ignored-vscode",
"r": {
"dark_plus": "punctuation.definition.tag: #808080",
"light_plus": "punctuation.definition.tag: #800000",
......@@ -397,7 +397,7 @@
},
{
"c": "<",
"t": "text.html.derivative meta.embedded.block.html meta.tag.metadata.script.end.html punctuation.definition.tag.begin.html source.js",
"t": "text.html.derivative meta.embedded.block.html meta.tag.metadata.script.end.html punctuation.definition.tag.begin.html source.js-ignored-vscode",
"r": {
"dark_plus": "punctuation.definition.tag: #808080",
"light_plus": "punctuation.definition.tag: #800000",
......
......@@ -518,7 +518,7 @@
},
{
"c": "<",
"t": "text.html.derivative meta.embedded.block.html meta.tag.metadata.script.end.html punctuation.definition.tag.begin.html source.js",
"t": "text.html.derivative meta.embedded.block.html meta.tag.metadata.script.end.html punctuation.definition.tag.begin.html source.js-ignored-vscode",
"r": {
"dark_plus": "punctuation.definition.tag: #808080",
"light_plus": "punctuation.definition.tag: #800000",
......
......@@ -782,7 +782,7 @@
},
{
"c": "<",
"t": "text.html.derivative meta.embedded.block.html meta.tag.metadata.style.end.html punctuation.definition.tag.begin.html source.css",
"t": "text.html.derivative meta.embedded.block.html meta.tag.metadata.style.end.html punctuation.definition.tag.begin.html source.css-ignored-vscode",
"r": {
"dark_plus": "punctuation.definition.tag: #808080",
"light_plus": "punctuation.definition.tag: #800000",
......@@ -1200,7 +1200,7 @@
},
{
"c": "<",
"t": "text.html.derivative meta.embedded.block.html meta.tag.metadata.script.end.html punctuation.definition.tag.begin.html source.js",
"t": "text.html.derivative meta.embedded.block.html meta.tag.metadata.script.end.html punctuation.definition.tag.begin.html source.js-ignored-vscode",
"r": {
"dark_plus": "punctuation.definition.tag: #808080",
"light_plus": "punctuation.definition.tag: #800000",
......@@ -1354,7 +1354,7 @@
},
{
"c": "<",
"t": "text.html.derivative meta.embedded.block.html meta.tag.metadata.script.end.html punctuation.definition.tag.begin.html source.js",
"t": "text.html.derivative meta.embedded.block.html meta.tag.metadata.script.end.html punctuation.definition.tag.begin.html source.js-ignored-vscode",
"r": {
"dark_plus": "punctuation.definition.tag: #808080",
"light_plus": "punctuation.definition.tag: #800000",
......@@ -2212,7 +2212,7 @@
},
{
"c": "<",
"t": "text.html.derivative meta.embedded.block.html meta.tag.metadata.script.end.html punctuation.definition.tag.begin.html source.js",
"t": "text.html.derivative meta.embedded.block.html meta.tag.metadata.script.end.html punctuation.definition.tag.begin.html source.js-ignored-vscode",
"r": {
"dark_plus": "punctuation.definition.tag: #808080",
"light_plus": "punctuation.definition.tag: #800000",
......@@ -3189,4 +3189,4 @@
"hc_black": "punctuation.definition.tag: #808080"
}
}
]
]
\ No newline at end of file
......@@ -1134,7 +1134,7 @@
},
{
"c": "<",
"t": "text.html.markdown meta.embedded.block.html meta.tag.metadata.style.end.html punctuation.definition.tag.begin.html source.css",
"t": "text.html.markdown meta.embedded.block.html meta.tag.metadata.style.end.html punctuation.definition.tag.begin.html source.css-ignored-vscode",
"r": {
"dark_plus": "punctuation.definition.tag: #808080",
"light_plus": "punctuation.definition.tag: #800000",
......
[{
[
{
"c": "<",
"t": "text.html.php meta.embedded.block.html meta.tag.metadata.script.start.html punctuation.definition.tag.begin.html",
"r": {
......@@ -495,7 +496,7 @@
},
{
"c": "<",
"t": "text.html.php meta.embedded.block.html meta.tag.metadata.script.end.html punctuation.definition.tag.begin.html source.js",
"t": "text.html.php meta.embedded.block.html meta.tag.metadata.script.end.html punctuation.definition.tag.begin.html source.js-ignored-vscode",
"r": {
"dark_plus": "punctuation.definition.tag: #808080",
"light_plus": "punctuation.definition.tag: #800000",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册