Skip to content

Commit

Permalink
Add script to sync xml syntax from vscode repo
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron committed Jun 24, 2021
1 parent 48f128b commit e9c74a4
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 16 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
"clean": "rimraf dist",
"install-local": "node scripts/install-local.js",
"install-pull-local": "node scripts/install-local.js --pull",
"uninstall-local": "node scripts/uninstall-local.js"
"uninstall-local": "node scripts/uninstall-local.js",
"sync-syntaxes": "node scripts/sync-scenegraph-tmlanguage.js"
},
"dependencies": {
"array-sort": "^1.0.0",
Expand Down
17 changes: 17 additions & 0 deletions scripts/sync-scenegraph-tmlanguage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const fetch = require('node-fetch');
var fsExtra = require('fs-extra');
(async () => {
const json = await (await fetch('https://raw.githubusercontent.com/microsoft/vscode/main/extensions/xml/syntaxes/xml.tmLanguage.json')).json()
json.scopeName = 'scenegraph.xml';
json.name = 'scenegraph';
json.fileTypes = ['xml'];
delete json.information_for_contributors;
delete json.version;
//find the CDATA pattern
var pattern = json.patterns.find(x => x.name === 'string.unquoted.cdata.xml');
pattern.name = 'source.brighterscript.embedded.scenegraph';
pattern.patterns = [{
include: "source.brs"
}];
fsExtra.outputFileSync(`${__dirname}/../syntaxes/scenegraph.tmLanguage.json`, JSON.stringify(json, null, 4));
})().catch(e => console.error(e));
53 changes: 38 additions & 15 deletions syntaxes/scenegraph.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"scopeName": "scenegraph.xml",
"name": "scenegraph",
"fileTypes": [
"xml"
],
"scopeName": "scenegraph.xml",
"patterns": [
{
"begin": "(<\\?)\\s*([-_a-zA-Z0-9]+)",
Expand Down Expand Up @@ -191,7 +188,7 @@
"name": "punctuation.definition.string.end.xml"
}
},
"name": "source.brighterscript.embedded.xml",
"name": "source.brighterscript.embedded.scenegraph",
"patterns": [
{
"include": "source.brs"
Expand Down Expand Up @@ -341,7 +338,7 @@
"name": "entity.other.attribute-name.localname.xml"
}
},
"match": "(?:^|\\s+)(?:([-\\w.]+)((:)))?([-\\w.:]+)="
"match": "(?:^|\\s+)(?:([-\\w.]+)((:)))?([-\\w.:]+)\\s*="
},
{
"include": "#doublequotedString"
Expand All @@ -352,15 +349,41 @@
]
},
"comments": {
"begin": "<[!%]--",
"captures": {
"0": {
"name": "punctuation.definition.comment.xml"
"patterns": [
{
"begin": "<%--",
"captures": {
"0": {
"name": "punctuation.definition.comment.xml"
},
"end": "--%>",
"name": "comment.block.xml"
}
},
{
"begin": "<!--",
"captures": {
"0": {
"name": "punctuation.definition.comment.xml"
}
},
"end": "-->",
"name": "comment.block.xml",
"patterns": [
{
"begin": "--(?!>)",
"captures": {
"0": {
"name": "invalid.illegal.bad-comments-or-CDATA.xml"
}
}
}
]
}
},
"end": "--%?>",
"name": "comment.block.xml"
]
}
},
"version": "https://github.com/atom/language-xml/commit/f461d428fb87040cb8a52d87d0b95151b9d3c0cc"
}
"fileTypes": [
"xml"
]
}

0 comments on commit e9c74a4

Please sign in to comment.