Created
January 15, 2018 14:32
-
-
Save JackuB/3d589bd64dc96c1b18486baaaf58d910 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This only defines high-level behaviour of the Mode like folding etc. | |
ace.define('ace/mode/custom', ['require', 'exports', 'ace/lib/oop', 'ace/mode/text', 'ace/mode/custom_highlight_rules'], (acequire, exports) => { | |
const oop = acequire('ace/lib/oop'); | |
const TextMode = acequire('ace/mode/text').Mode; | |
const CustomHighlightRules = acequire('ace/mode/custom_highlight_rules').CustomHighlightRules; | |
oop.inherits(Mode, TextMode); // ACE's way of doing inheritance | |
exports.Mode = Mode; // eslint-disable-line no-param-reassign | |
}); | |
// This is where we really create the highlighting rules | |
ace.define('ace/mode/custom_highlight_rules', ['require', 'exports', 'ace/lib/oop', 'ace/mode/text_highlight_rules'], (acequire, exports) => { | |
const oop = acequire('ace/lib/oop'); | |
const TextHighlightRules = acequire('ace/mode/text_highlight_rules').TextHighlightRules; | |
const CustomHighlightRules = function CustomHighlightRules() { | |
this.$rules = new TextHighlightRules().getRules(); // Use Text's rules as a base | |
}; | |
oop.inherits(CustomHighlightRules, TextHighlightRules); | |
exports.CustomHighlightRules = CustomHighlightRules; | |
}); |
Mode
is not defined on line 7
There is a missing step where the CustomHighlighter has to be set for the Mode
let Mode = function() {
// this ensures that all your highlight rules are set for your custom mode
this.HighlightRules = CustomHighlightRules;
}
oop.inherits(Mode, TextMode); // ACE's way of doing inheritance
The custom mode will otherwise not have any highlight rules.
Worth pointing out, that is a part of an article on writing custom highlight rules
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I wonder why you're not getting "acequire is not defined" errors, cause I certainly am.