Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update highlighter library #176

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ CodeCookBook.js
CodeCookBook.py
node_modules/
bin/
package-lock.json
2 changes: 1 addition & 1 deletion highlighting.hxml
Original file line number Diff line number Diff line change
@@ -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
80 changes: 80 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
45 changes: 21 additions & 24 deletions src/Highlighting.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Loading