##// END OF EJS Templates
avoid jsonlib returning Decimal...
avoid jsonlib returning Decimal The only functional change is that Decimal objects will no longer come out of jsonlib, but the code that handles jsonlib's two minor differences wrt other json libraries is now a bit clearer and better documented. Relevant test is added.

File last commit:

r5970:b6bb1663
r6060:4506273c
Show More
runmode.js
27 lines | 968 B | application/javascript | JavascriptLexer
CodeMirror.runMode = function(string, modespec, callback) {
var mode = CodeMirror.getMode({indentUnit: 2}, modespec);
var isNode = callback.nodeType == 1;
if (isNode) {
var node = callback, accum = [];
callback = function(string, style) {
if (string == "\n")
accum.push("<br>");
else if (style)
accum.push("<span class=\"cm-" + CodeMirror.htmlEscape(style) + "\">" + CodeMirror.htmlEscape(string) + "</span>");
else
accum.push(CodeMirror.htmlEscape(string));
}
}
var lines = CodeMirror.splitLines(string), state = CodeMirror.startState(mode);
for (var i = 0, e = lines.length; i < e; ++i) {
if (i) callback("\n");
var stream = new CodeMirror.StringStream(lines[i]);
while (!stream.eol()) {
var style = mode.token(stream, state);
callback(stream.current(), style, i, stream.start);
stream.start = stream.pos;
}
}
if (isNode)
node.innerHTML = accum.join("");
};