public/javascripts/erp_app/codemirror/mode/stex/stex.js in erp_app-3.0.7 vs public/javascripts/erp_app/codemirror/mode/stex/stex.js in erp_app-3.0.8
- old
+ new
@@ -80,26 +80,41 @@
function setState(state, f) {
state.f = f;
}
function normal(source, state) {
- if (source.match(/^\\[a-z]+/)) {
+ if (source.match(/^\\[a-zA-Z@]+/)) {
var cmdName = source.current();
cmdName = cmdName.substr(1, cmdName.length-1);
- var plug = plugins[cmdName];
- if (typeof(plug) == 'undefined') {
- plug = plugins["DEFAULT"];
- }
+ var plug;
+ if (plugins.hasOwnProperty(cmdName)) {
+ plug = plugins[cmdName];
+ } else {
+ plug = plugins["DEFAULT"];
+ }
plug = new plug();
pushCommand(state, plug);
setState(state, beginParams);
return plug.style;
}
+ // escape characters
+ if (source.match(/^\\[$&%#{}_]/)) {
+ return "tag";
+ }
+
+ // white space control characters
+ if (source.match(/^\\[,;!\/]/)) {
+ return "tag";
+ }
+
var ch = source.next();
if (ch == "%") {
- setState(state, inCComment);
+ // special case: % at end of its own line; stay in same state
+ if (!source.eol()) {
+ setState(state, inCComment);
+ }
return "comment";
}
else if (ch=='}' || ch==']') {
plug = peekCommand(state);
if (plug) {
@@ -161,7 +176,7 @@
return t;
}
};
});
-
CodeMirror.defineMIME("text/x-stex", "stex");
+CodeMirror.defineMIME("text/x-latex", "stex");