mirror of
https://github.com/Microsoft/vscode
synced 2024-10-02 09:18:59 +00:00
[html] issues caused by HTML grammar associating '<' with JS. Fixes #86998
This commit is contained in:
parent
c97c457d0a
commit
18bab626b9
44
extensions/html/build/update-grammar.js
Normal file
44
extensions/html/build/update-grammar.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* 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": [
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<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",
|
||||
|
|
1003
extensions/html/test/colorize-results/test-embedding_html.json
Normal file
1003
extensions/html/test/colorize-results/test-embedding_html.json
Normal file
File diff suppressed because it is too large
Load diff
|
@ -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"
|
||||
}
|
||||
}
|
||||
]
|
||||
]
|
|
@ -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",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
[{
|
||||
[
|
||||
{
|
||||
"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",
|
||||
|
|
Loading…
Reference in a new issue