'use strict';(function(f){"object"==typeof exports&&"object"==typeof module?f(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],f):f(CodeMirror)})(function(f){f.defineMode("stex",function(f,m){function n(a){a=a.cmdState;for(var b=a.length-1;0<=b;b--){var c=a[b];if("DEFAULT"!=c.name)return c}return{styleIdentifier:function(){return null}}}function d(a,b,c){return function(){this.name=a;this.bracketNo=0;this.style=b;this.styles=c;this.argument=null;
this.styleIdentifier=function(){return this.styles[this.bracketNo-1]||null};this.openBracket=function(){this.bracketNo++;return"bracket"};this.closeBracket=function(){}}}function k(a,b){a.f=b}function g(a,b){if(a.match(/^\\[a-zA-Z@]+/)){a=a.current().slice(1);var c=e[a]||e.DEFAULT;c=new c;b.cmdState.push(c);b.f=l;return c.style}if(a.match(/^\\[$&%#{}_]/)||a.match(/^\\[,;!\/\\]/))return"tag";if(a.match("\\["))return k(b,function(a,b){return h(a,b,"\\]")}),"keyword";if(a.match("\\("))return k(b,function(a,
b){return h(a,b,"\\)")}),"keyword";if(a.match("$$"))return k(b,function(a,b){return h(a,b,"$$")}),"keyword";if(a.match("$"))return k(b,function(a,b){return h(a,b,"$")}),"keyword";var d=a.next();if("%"==d)return a.skipToEnd(),"comment";if("}"==d||"]"==d){if(c=0<b.cmdState.length?b.cmdState[b.cmdState.length-1]:null)c.closeBracket(d),b.f=l;else return"error";return"bracket"}if("{"==d||"["==d)return c=e.DEFAULT,c=new c,b.cmdState.push(c),"bracket";if(/\d/.test(d))return a.eatWhile(/[\w.%]/),"atom";a.eatWhile(/[\w\-_]/);
c=n(b);"begin"==c.name&&(c.argument=a.current());return c.styleIdentifier()}function h(a,b,c){if(a.eatSpace())return null;if(c&&a.match(c))return b.f=g,"keyword";if(a.match(/^\\[a-zA-Z@]+/))return"tag";if(a.match(/^[a-zA-Z]+/))return"variable-2";if(a.match(/^\\[$&%#{}_]/)||a.match(/^\\[,;!\/]/)||a.match(/^[\^_&]/))return"tag";if(a.match(/^[+\-<>|=,\/@!*:;'"`~#?]/))return null;if(a.match(/^(\d+\.\d*|\d*\.\d+|\d+)/))return"number";b=a.next();return"{"==b||"}"==b||"["==b||"]"==b||"("==b||")"==b?"bracket":
"%"==b?(a.skipToEnd(),"comment"):"error"}function l(a,b){var c=a.peek();if("{"==c||"["==c){var d=0<b.cmdState.length?b.cmdState[b.cmdState.length-1]:null;d.openBracket(c);a.eat(c);b.f=g;return"bracket"}if(/[ \t\r]/.test(c))return a.eat(c),null;b.f=g;(c=b.cmdState.pop())&&c.closeBracket();return g(a,b)}var e={};e.importmodule=d("importmodule","tag",["string","builtin"]);e.documentclass=d("documentclass","tag",["","atom"]);e.usepackage=d("usepackage","tag",["atom"]);e.begin=d("begin","tag",["atom"]);
e.end=d("end","tag",["atom"]);e.label=d("label","tag",["atom"]);e.ref=d("ref","tag",["atom"]);e.eqref=d("eqref","tag",["atom"]);e.cite=d("cite","tag",["atom"]);e.bibitem=d("bibitem","tag",["atom"]);e.Bibitem=d("Bibitem","tag",["atom"]);e.RBibitem=d("RBibitem","tag",["atom"]);e.DEFAULT=function(){this.name="DEFAULT";this.style="tag";this.styleIdentifier=this.openBracket=this.closeBracket=function(){}};return{startState:function(){return{cmdState:[],f:m.inMathMode?function(a,b){return h(a,b)}:g}},copyState:function(a){return{cmdState:a.cmdState.slice(),
f:a.f}},token:function(a,b){return b.f(a,b)},blankLine:function(a){a.f=g;a.cmdState.length=0},lineComment:"%"}});f.defineMIME("text/x-stex","stex");f.defineMIME("text/x-latex","stex")});
