Skip to content

Commit 9fae30f

Browse files
tobil4skkLabz
andauthored
Update highlighter library (#176)
* Update highlighter library * Check in package-lock.json * [ci] Stop using ancient version of node We now need node v14 or above --------- Co-authored-by: Rudy Ges <[email protected]>
1 parent 995d1ab commit 9fae30f

File tree

6 files changed

+105
-32
lines changed

6 files changed

+105
-32
lines changed

.github/workflows/main.yml

-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ jobs:
1717
with:
1818
haxe-version: 4.3.5
1919

20-
# we are using this version in order to build vscode-textmate
21-
- name: Setup Node
22-
uses: actions/setup-node@v1
23-
2420
- name: Install
2521
# at some point all npm needs to be in package.json
2622
run: |

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,3 @@ CodeCookBook.js
1818
CodeCookBook.py
1919
node_modules/
2020
bin/
21-
package-lock.json

highlighting.hxml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-cp src
22
-main Highlighting
33
-lib hxnodejs
4-
-lib highlighter:0.6.1
4+
-lib highlighter
55
-js bin/patch.js
66
-cmd node bin/patch.js

package-lock.json

+80
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "code-cookbook",
33
"version": "0.1.0",
44
"devDependencies": {
5-
"vscode-textmate": "5.0.2",
6-
"cson-parser": "3.0.0"
5+
"cson-parser": "3.0.0",
6+
"vscode-oniguruma": "^2.0.1",
7+
"vscode-textmate": "^9.1.0"
78
}
89
}

src/Highlighting.hx

+21-24
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,30 @@ class Highlighting {
99
// Convert CSON grammar to json for vscode-textmate
1010
File.saveContent("bin/javascript.json", Json.stringify(CSON.parse(File.getContent("grammars/language-javascript/grammars/javascript.cson"))));
1111

12-
var haxeGrammar = new Highlighter("grammars/haxe-TmLanguage/haxe.tmLanguage");
13-
var hxmlGrammar = new Highlighter("grammars/haxe-TmLanguage/hxml.tmLanguage");
14-
var xmlGrammar = new Highlighter("grammars/xml.tmbundle/Syntaxes/XML.plist");
15-
var jsGrammar = new Highlighter("bin/javascript.json");
16-
17-
var grammars = [
18-
"haxe" => haxeGrammar,
19-
"hxml" => hxmlGrammar,
20-
"html" => xmlGrammar,
21-
"js" => jsGrammar,
22-
"javascript" => jsGrammar,
12+
var grammarFiles = [
13+
"haxe" => "grammars/haxe-TmLanguage/haxe.tmLanguage",
14+
"hxml" => "grammars/haxe-TmLanguage/hxml.tmLanguage",
15+
"html" => "grammars/xml.tmbundle/Syntaxes/XML.plist",
16+
"js" => "bin/javascript.json",
17+
"javascript" => "bin/javascript.json",
2318
];
2419

25-
// Go over the generated HTML file and apply syntax highlighting
26-
var missingGrammars = Highlighter.patchFolder(Config.outputPath, grammars, function (classList) {
27-
return classList.substr(12);
20+
Highlighter.loadHighlighters(grammarFiles, function(highlighters) {
21+
// Go over the generated HTML file and apply syntax highlighting
22+
var missingGrammars = Highlighter.patchFolder(Config.outputPath, highlighters, function(classList) {
23+
return classList.substr(12);
24+
});
25+
26+
for (g in missingGrammars) {
27+
Sys.println('Missing grammar for "${g}"');
28+
}
29+
30+
// Add CSS rules for highlighting
31+
var path = Config.outputPath + "/css/haxe-nav.min.css";
32+
var baseStyle = File.getContent(path);
33+
var syntaxStyle = highlighters["haxe"].runCss();
34+
File.saveContent(path, baseStyle + syntaxStyle);
2835
});
29-
30-
for (g in missingGrammars) {
31-
Sys.println('Missing grammar for "${g}"');
32-
}
33-
34-
// Add CSS rules for highlighting
35-
var path = Config.outputPath + "/css/haxe-nav.min.css";
36-
var baseStyle = File.getContent(path);
37-
var syntaxStyle = haxeGrammar.runCss();
38-
File.saveContent(path, baseStyle + syntaxStyle);
3936
}
4037
}
4138

0 commit comments

Comments
 (0)