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 #74

Open
wants to merge 2 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
6 changes: 1 addition & 5 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ jobs:
with:
submodules: true

# we are using this version in order to build vscode-textmate
- name: Setup Node
uses: actions/setup-node@v1

- name: Setup Haxe
uses: krdlab/setup-haxe@v1
with:
Expand All @@ -36,7 +32,7 @@ jobs:
haxelib install all --always
haxelib git heaps https://github.com/heapsio/heaps
haxelib list

- name: Script
run: |
haxe build-run-dox.hxml
Expand Down
57 changes: 30 additions & 27 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "heaps-website",
"version": "0.1.0",
"devDependencies": {
"vscode-textmate": "3.1.5"
"vscode-oniguruma": "^2.0.1",
"vscode-textmate": "^9.1.0"
}
}
59 changes: 28 additions & 31 deletions src/SyntaxHighlighter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,37 @@ class SyntaxHighlighter
public static function patch () {
Sys.println("Applying syntax highlighting ...");

var haxeGrammar = new Highlighter("grammars/haxe-TmLanguage/haxe.tmLanguage");
var hxmlGrammar = new Highlighter("grammars/haxe-TmLanguage/hxml.tmLanguage");
var htmlGrammar = new Highlighter("grammars/html.tmbundle/Syntaxes/HTML.plist");

var grammars = [
"haxe" => haxeGrammar,
"hxml" => hxmlGrammar,
"html" => htmlGrammar,
var grammarFiles = [
"haxe" => "grammars/haxe-TmLanguage/haxe.tmLanguage",
"hxml" => "grammars/haxe-TmLanguage/hxml.tmLanguage",
"html" => "grammars/html.tmbundle/Syntaxes/HTML.plist",
];

// Go over the generated HTML file and apply syntax highlighting
var missingGrammars = Highlighter.patchFolder("output/documentation", 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("output/documentation", highlighters, function(classList) {
return classList.substr(12);
});

for (g in missingGrammars) {
Sys.println('Missing grammar for "${g}"');
}

// Go over the generated HTML file and apply syntax highlighting
missingGrammars = Highlighter.patchFolder("output/samples", highlighters, function(classList) {
return classList.substr(12);
});

for (g in missingGrammars) {
Sys.println('Missing grammar for "${g}"');
}

// Add CSS rules for highlighting
var path = "output/css/styles.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}"');
}

// Go over the generated HTML file and apply syntax highlighting
missingGrammars = Highlighter.patchFolder("output/samples", grammars, function (classList) {
return classList.substr(12);
});

for (g in missingGrammars) {
Sys.println('Missing grammar for "${g}"');
}


// Add CSS rules for highlighting
var path = "output/css/styles.min.css";
var baseStyle = File.getContent(path);
var syntaxStyle = haxeGrammar.runCss();
File.saveContent(path, baseStyle + syntaxStyle);
}

public static function main(){
Expand Down