Menu

#110 bug in highlight.js: function maj_highlight

v1.0 (example)
open
nobody
None
5
2016-03-07
2016-03-07
athenaxing
No

the maj_highlight function will crash sometime at this line:

trace_new = t.get_syntax_trace(changes.newTextLine).replace(/\r/g, '');

the get_syntax_trace function will return undefined value sometime.

solution:

change the code
    // return identication that allow to know if revalidating only the text line won't make the syntax go mad
    EditArea.prototype.get_syntax_trace= function(text){
        if(this.settings["syntax"].length>0 && parent.editAreaLoader.syntax[this.settings["syntax"]]["syntax_trace_regexp"])
            return text.replace(parent.editAreaLoader.syntax[this.settings["syntax"]]["syntax_trace_regexp"], "$3");
    };

to

    // return identication that allow to know if revalidating only the text line won't make the syntax go mad
EditArea.prototype.get_syntax_trace= function(text){
    if(this.settings["syntax"].length>0 && parent.editAreaLoader.syntax[this.settings["syntax"]]["syntax_trace_regexp"])
        return text.replace(parent.editAreaLoader.syntax[this.settings["syntax"]]["syntax_trace_regexp"], "$3");
       return " ";
};

Discussion


Log in to post a comment.

MongoDB Logo MongoDB