Help Syntax Highlighting [STUCK]

81 views
Skip to first unread message

Ramin Razi

unread,
Nov 16, 2013, 2:27:16 PM11/16/13
to ace-d...@googlegroups.com
Hello,
Iv been working several hours and still cant get syntax highlighting to work at all.

Here is a copy of my mode-cisco_ios_highlight_rules.js file which is located in the same directory of my ace.js file.

I have tested this mode file in the ace mode creator and it works fine.
However when I try and use it in my scripts it does not work..


I am using 
editor.getSession().setMode("ace/mode/mode-cisco_ios_highlight_rules");

I get the error "dropping module define was not a string"


Any help will be very much appreciated. Thanks.

Harutyun Amirjanyan

unread,
Nov 16, 2013, 3:13:06 PM11/16/13
to ace-d...@googlegroups.com
Hi

mode creator is a bit misleading since it shows only highlight rules,
and setMode expects a mode
also build files are using require.js shim not real require
so you'll need to make somethink like

define('ace/mode/cisco_ios', ['require', 'exports', 'module'],
function(require, exports, module) {
var AdaHighlightRules = require("./cisco_ios_highlight_rules").HighliightRules ;

var Mode = function() {
this.HighlightRules = AdaHighlightRules;
};
oop.inherits(Mode, TextMode);

(function() {
this.lineCommentStart = "!";
}).call(Mode.prototype);

exports.Mode = Mode;

})

define('ace/mode/cisco_ios_highlight_rules', ['require', 'exports',
'module'], function(require, exports, module) {

exports.HighliightRules = ...
})

see e.g https://github.com/ajaxorg/ace-builds/blob/master/src/mode-ada.js#L31

but
of course it would be much better to not edit build files manually,
create mode in https://github.com/ajaxorg/ace/tree/master/lib/ace/mode
and make a pull request to ace

Ramin Razi

unread,
Nov 16, 2013, 4:34:21 PM11/16/13
to ace-d...@googlegroups.com
Thanks Harutyun! I made the updates that you suggested and im not getting anymore java script errors but it still isnt highlighting like it was in the creator. Could you take a look at it and see if you see anything that would cause it not to work? I really appreciate the help.

Harutyun Amirjanyan

unread,
Nov 16, 2013, 4:49:58 PM11/16/13
to ace-d...@googlegroups.com
file should be called mode-cisco_ios.js
and setMode call should be
editor.session.setMode("ace/mode/cisco_ios")
Reply all
Reply to author
Forward
0 new messages