-
Notifications
You must be signed in to change notification settings - Fork 29.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[html] issues caused by HTML grammar associating '<' with JS. Fixes #…
- Loading branch information
Showing
10 changed files
with
1,072 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.