-
-
Notifications
You must be signed in to change notification settings - Fork 105
Expand file tree
/
Copy pathHighlighting.hx
More file actions
42 lines (35 loc) · 1.34 KB
/
Highlighting.hx
File metadata and controls
42 lines (35 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import haxe.Json;
import highlighter.Highlighter;
import sys.io.File;
class Highlighting {
public static function main() {
Sys.println("Applying syntax 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 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",
];
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);
});
}
}
@:jsRequire("cson-parser")
extern class CSON {
static function parse (content:String) : Dynamic;
}