Skip to content

Commit e9c74a4

Browse files
Add script to sync xml syntax from vscode repo
1 parent 48f128b commit e9c74a4

File tree

3 files changed

+57
-16
lines changed

3 files changed

+57
-16
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
"clean": "rimraf dist",
4242
"install-local": "node scripts/install-local.js",
4343
"install-pull-local": "node scripts/install-local.js --pull",
44-
"uninstall-local": "node scripts/uninstall-local.js"
44+
"uninstall-local": "node scripts/uninstall-local.js",
45+
"sync-syntaxes": "node scripts/sync-scenegraph-tmlanguage.js"
4546
},
4647
"dependencies": {
4748
"array-sort": "^1.0.0",
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const fetch = require('node-fetch');
2+
var fsExtra = require('fs-extra');
3+
(async () => {
4+
const json = await (await fetch('https://raw.githubusercontent.com/microsoft/vscode/main/extensions/xml/syntaxes/xml.tmLanguage.json')).json()
5+
json.scopeName = 'scenegraph.xml';
6+
json.name = 'scenegraph';
7+
json.fileTypes = ['xml'];
8+
delete json.information_for_contributors;
9+
delete json.version;
10+
//find the CDATA pattern
11+
var pattern = json.patterns.find(x => x.name === 'string.unquoted.cdata.xml');
12+
pattern.name = 'source.brighterscript.embedded.scenegraph';
13+
pattern.patterns = [{
14+
include: "source.brs"
15+
}];
16+
fsExtra.outputFileSync(`${__dirname}/../syntaxes/scenegraph.tmLanguage.json`, JSON.stringify(json, null, 4));
17+
})().catch(e => console.error(e));

syntaxes/scenegraph.tmLanguage.json

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
{
2-
"scopeName": "scenegraph.xml",
32
"name": "scenegraph",
4-
"fileTypes": [
5-
"xml"
6-
],
3+
"scopeName": "scenegraph.xml",
74
"patterns": [
85
{
96
"begin": "(<\\?)\\s*([-_a-zA-Z0-9]+)",
@@ -191,7 +188,7 @@
191188
"name": "punctuation.definition.string.end.xml"
192189
}
193190
},
194-
"name": "source.brighterscript.embedded.xml",
191+
"name": "source.brighterscript.embedded.scenegraph",
195192
"patterns": [
196193
{
197194
"include": "source.brs"
@@ -341,7 +338,7 @@
341338
"name": "entity.other.attribute-name.localname.xml"
342339
}
343340
},
344-
"match": "(?:^|\\s+)(?:([-\\w.]+)((:)))?([-\\w.:]+)="
341+
"match": "(?:^|\\s+)(?:([-\\w.]+)((:)))?([-\\w.:]+)\\s*="
345342
},
346343
{
347344
"include": "#doublequotedString"
@@ -352,15 +349,41 @@
352349
]
353350
},
354351
"comments": {
355-
"begin": "<[!%]--",
356-
"captures": {
357-
"0": {
358-
"name": "punctuation.definition.comment.xml"
352+
"patterns": [
353+
{
354+
"begin": "<%--",
355+
"captures": {
356+
"0": {
357+
"name": "punctuation.definition.comment.xml"
358+
},
359+
"end": "--%>",
360+
"name": "comment.block.xml"
361+
}
362+
},
363+
{
364+
"begin": "<!--",
365+
"captures": {
366+
"0": {
367+
"name": "punctuation.definition.comment.xml"
368+
}
369+
},
370+
"end": "-->",
371+
"name": "comment.block.xml",
372+
"patterns": [
373+
{
374+
"begin": "--(?!>)",
375+
"captures": {
376+
"0": {
377+
"name": "invalid.illegal.bad-comments-or-CDATA.xml"
378+
}
379+
}
380+
}
381+
]
359382
}
360-
},
361-
"end": "--%?>",
362-
"name": "comment.block.xml"
383+
]
363384
}
364385
},
365-
"version": "https://github.com/atom/language-xml/commit/f461d428fb87040cb8a52d87d0b95151b9d3c0cc"
366-
}
386+
"fileTypes": [
387+
"xml"
388+
]
389+
}

0 commit comments

Comments
 (0)