diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4e0ac3f1..01511e29 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,10 +17,6 @@ jobs: with: haxe-version: 4.3.5 - # we are using this version in order to build vscode-textmate - - name: Setup Node - uses: actions/setup-node@v1 - - name: Install # at some point all npm needs to be in package.json run: | diff --git a/.gitignore b/.gitignore index a3e849be..61cc7125 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,3 @@ CodeCookBook.js CodeCookBook.py node_modules/ bin/ -package-lock.json diff --git a/highlighting.hxml b/highlighting.hxml index ef490794..6ccce7b8 100644 --- a/highlighting.hxml +++ b/highlighting.hxml @@ -1,6 +1,6 @@ -cp src -main Highlighting -lib hxnodejs --lib highlighter:0.6.1 +-lib highlighter -js bin/patch.js -cmd node bin/patch.js diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..a718afec --- /dev/null +++ b/package-lock.json @@ -0,0 +1,80 @@ +{ + "name": "code-cookbook", + "version": "0.1.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "code-cookbook", + "version": "0.1.0", + "devDependencies": { + "cson-parser": "3.0.0", + "vscode-oniguruma": "^2.0.1", + "vscode-textmate": "^9.1.0" + } + }, + "node_modules/coffeescript": { + "version": "1.12.7", + "resolved": "https://registry.npmjs.org/coffeescript/-/coffeescript-1.12.7.tgz", + "integrity": "sha512-pLXHFxQMPklVoEekowk8b3erNynC+DVJzChxS/LCBBgR6/8AJkHivkm//zbowcfc7BTCAjryuhx6gPqPRfsFoA==", + "dev": true, + "bin": { + "cake": "bin/cake", + "coffee": "bin/coffee" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/cson-parser": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/cson-parser/-/cson-parser-3.0.0.tgz", + "integrity": "sha512-khmLtNmwe6SSlWz5vrhay9yWd/Fwwyiel+vt+1vIcCT9AsdqNuLXuK9tYhhAw1FdSSHjLc56PW8xa565/x73XQ==", + "dev": true, + "dependencies": { + "coffeescript": "^1.10.0" + } + }, + "node_modules/vscode-oniguruma": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/vscode-oniguruma/-/vscode-oniguruma-2.0.1.tgz", + "integrity": "sha512-poJU8iHIWnC3vgphJnrLZyI3YdqRlR27xzqDmpPXYzA93R4Gk8z7T6oqDzDoHjoikA2aS82crdXFkjELCdJsjQ==", + "dev": true + }, + "node_modules/vscode-textmate": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-9.1.0.tgz", + "integrity": "sha512-lxKSVp2DkFOx9RDAvpiYUrB9/KT1fAfi1aE8CBGstP8N7rLF+Seifj8kDA198X0mYj1CjQUC+81+nQf8CO0nVA==", + "dev": true + } + }, + "dependencies": { + "coffeescript": { + "version": "1.12.7", + "resolved": "https://registry.npmjs.org/coffeescript/-/coffeescript-1.12.7.tgz", + "integrity": "sha512-pLXHFxQMPklVoEekowk8b3erNynC+DVJzChxS/LCBBgR6/8AJkHivkm//zbowcfc7BTCAjryuhx6gPqPRfsFoA==", + "dev": true + }, + "cson-parser": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/cson-parser/-/cson-parser-3.0.0.tgz", + "integrity": "sha512-khmLtNmwe6SSlWz5vrhay9yWd/Fwwyiel+vt+1vIcCT9AsdqNuLXuK9tYhhAw1FdSSHjLc56PW8xa565/x73XQ==", + "dev": true, + "requires": { + "coffeescript": "^1.10.0" + } + }, + "vscode-oniguruma": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/vscode-oniguruma/-/vscode-oniguruma-2.0.1.tgz", + "integrity": "sha512-poJU8iHIWnC3vgphJnrLZyI3YdqRlR27xzqDmpPXYzA93R4Gk8z7T6oqDzDoHjoikA2aS82crdXFkjELCdJsjQ==", + "dev": true + }, + "vscode-textmate": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-9.1.0.tgz", + "integrity": "sha512-lxKSVp2DkFOx9RDAvpiYUrB9/KT1fAfi1aE8CBGstP8N7rLF+Seifj8kDA198X0mYj1CjQUC+81+nQf8CO0nVA==", + "dev": true + } + } +} diff --git a/package.json b/package.json index 47804320..1cfbc652 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,8 @@ "name": "code-cookbook", "version": "0.1.0", "devDependencies": { - "vscode-textmate": "3.1.5", - "cson-parser": "3.0.0" + "cson-parser": "3.0.0", + "vscode-oniguruma": "^2.0.1", + "vscode-textmate": "^9.1.0" } } diff --git a/src/Highlighting.hx b/src/Highlighting.hx index d832157d..604458d9 100644 --- a/src/Highlighting.hx +++ b/src/Highlighting.hx @@ -9,33 +9,30 @@ class Highlighting { // Convert CSON grammar to json for vscode-textmate File.saveContent("bin/javascript.json", Json.stringify(CSON.parse(File.getContent("grammars/language-javascript/grammars/javascript.cson")))); - var haxeGrammar = new Highlighter("grammars/haxe-TmLanguage/haxe.tmLanguage"); - var hxmlGrammar = new Highlighter("grammars/haxe-TmLanguage/hxml.tmLanguage"); - var xmlGrammar = new Highlighter("grammars/xml.tmbundle/Syntaxes/XML.plist"); - var jsGrammar = new Highlighter("bin/javascript.json"); - - var grammars = [ - "haxe" => haxeGrammar, - "hxml" => hxmlGrammar, - "html" => xmlGrammar, - "js" => jsGrammar, - "javascript" => jsGrammar, + var grammarFiles = [ + "haxe" => "grammars/haxe-TmLanguage/haxe.tmLanguage", + "hxml" => "grammars/haxe-TmLanguage/hxml.tmLanguage", + "html" => "grammars/xml.tmbundle/Syntaxes/XML.plist", + "js" => "bin/javascript.json", + "javascript" => "bin/javascript.json", ]; - // Go over the generated HTML file and apply syntax highlighting - var missingGrammars = Highlighter.patchFolder(Config.outputPath, grammars, function (classList) { - return classList.substr(12); + Highlighter.loadHighlighters(grammarFiles, function(highlighters) { + // Go over the generated HTML file and apply syntax highlighting + var missingGrammars = Highlighter.patchFolder(Config.outputPath, highlighters, function(classList) { + return classList.substr(12); + }); + + for (g in missingGrammars) { + Sys.println('Missing grammar for "${g}"'); + } + + // Add CSS rules for highlighting + var path = Config.outputPath + "/css/haxe-nav.min.css"; + var baseStyle = File.getContent(path); + var syntaxStyle = highlighters["haxe"].runCss(); + File.saveContent(path, baseStyle + syntaxStyle); }); - - for (g in missingGrammars) { - Sys.println('Missing grammar for "${g}"'); - } - - // Add CSS rules for highlighting - var path = Config.outputPath + "/css/haxe-nav.min.css"; - var baseStyle = File.getContent(path); - var syntaxStyle = haxeGrammar.runCss(); - File.saveContent(path, baseStyle + syntaxStyle); } }