diff --git a/package.json b/package.json index 1cd56f24..39523487 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/sync-scenegraph-tmlanguage.js b/scripts/sync-scenegraph-tmlanguage.js new file mode 100644 index 00000000..6c43b93d --- /dev/null +++ b/scripts/sync-scenegraph-tmlanguage.js @@ -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)); diff --git a/syntaxes/scenegraph.tmLanguage.json b/syntaxes/scenegraph.tmLanguage.json index 53b57d97..67f5c122 100644 --- a/syntaxes/scenegraph.tmLanguage.json +++ b/syntaxes/scenegraph.tmLanguage.json @@ -1,9 +1,6 @@ { - "scopeName": "scenegraph.xml", "name": "scenegraph", - "fileTypes": [ - "xml" - ], + "scopeName": "scenegraph.xml", "patterns": [ { "begin": "(<\\?)\\s*([-_a-zA-Z0-9]+)", @@ -191,7 +188,7 @@ "name": "punctuation.definition.string.end.xml" } }, - "name": "source.brighterscript.embedded.xml", + "name": "source.brighterscript.embedded.scenegraph", "patterns": [ { "include": "source.brs" @@ -341,7 +338,7 @@ "name": "entity.other.attribute-name.localname.xml" } }, - "match": "(?:^|\\s+)(?:([-\\w.]+)((:)))?([-\\w.:]+)=" + "match": "(?:^|\\s+)(?:([-\\w.]+)((:)))?([-\\w.:]+)\\s*=" }, { "include": "#doublequotedString" @@ -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": "", + "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" + ] +} \ No newline at end of file