物管理前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
3.1 KiB

  1. function g(k){function l(t,e){t.cmdState.push(e)}function h(t){return t.cmdState.length>0?t.cmdState[t.cmdState.length-1]:null}function b(t){var e=t.cmdState.pop();e&&e.closeBracket()}function p(t){for(var e=t.cmdState,r=e.length-1;r>=0;r--){var a=e[r];if(a.name!="DEFAULT")return a}return{styleIdentifier:function(){return null}}}function i(t,e,r){return function(){this.name=t,this.bracketNo=0,this.style=e,this.styles=r,this.argument=null,this.styleIdentifier=function(){return this.styles[this.bracketNo-1]||null},this.openBracket=function(){return this.bracketNo++,"bracket"},this.closeBracket=function(){}}}var n={};n.importmodule=i("importmodule","tag",["string","builtin"]),n.documentclass=i("documentclass","tag",["","atom"]),n.usepackage=i("usepackage","tag",["atom"]),n.begin=i("begin","tag",["atom"]),n.end=i("end","tag",["atom"]),n.label=i("label","tag",["atom"]),n.ref=i("ref","tag",["atom"]),n.eqref=i("eqref","tag",["atom"]),n.cite=i("cite","tag",["atom"]),n.bibitem=i("bibitem","tag",["atom"]),n.Bibitem=i("Bibitem","tag",["atom"]),n.RBibitem=i("RBibitem","tag",["atom"]),n.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}};function c(t,e){t.f=e}function m(t,e){var r;if(t.match(/^\\[a-zA-Z@\xc0-\u1fff\u2060-\uffff]+/)){var a=t.current().slice(1);return r=n.hasOwnProperty(a)?n[a]:n.DEFAULT,r=new r,l(e,r),c(e,d),r.style}if(t.match(/^\\[$&%#{}_]/)||t.match(/^\\[,;!\/\\]/))return"tag";if(t.match("\\["))return c(e,function(o,f){return s(o,f,"\\]")}),"keyword";if(t.match("\\("))return c(e,function(o,f){return s(o,f,"\\)")}),"keyword";if(t.match("$$"))return c(e,function(o,f){return s(o,f,"$$")}),"keyword";if(t.match("$"))return c(e,function(o,f){return s(o,f,"$")}),"keyword";var u=t.next();if(u=="%")return t.skipToEnd(),"comment";if(u=="}"||u=="]"){if(r=h(e),r)r.closeBracket(u),c(e,d);else return"error";return"bracket"}else return u=="{"||u=="["?(r=n.DEFAULT,r=new r,l(e,r),"bracket"):/\d/.test(u)?(t.eatWhile(/[\w.%]/),"atom"):(t.eatWhile(/[\w\-_]/),r=p(e),r.name=="begin"&&(r.argument=t.current()),r.styleIdentifier())}function s(t,e,r){if(t.eatSpace())return null;if(r&&t.match(r))return c(e,m),"keyword";if(t.match(/^\\[a-zA-Z@]+/))return"tag";if(t.match(/^[a-zA-Z]+/))return"variableName.special";if(t.match(/^\\[$&%#{}_]/)||t.match(/^\\[,;!\/]/)||t.match(/^[\^_&]/))return"tag";if(t.match(/^[+\-<>|=,\/@!*:;'"`~#?]/))return null;if(t.match(/^(\d+\.\d*|\d*\.\d+|\d+)/))return"number";var a=t.next();return a=="{"||a=="}"||a=="["||a=="]"||a=="("||a==")"?"bracket":a=="%"?(t.skipToEnd(),"comment"):"error"}function d(t,e){var r=t.peek(),a;return r=="{"||r=="["?(a=h(e),a.openBracket(r),t.eat(r),c(e,m),"bracket"):/[ \t\r]/.test(r)?(t.eat(r),null):(c(e,m),b(e),m(t,e))}return{name:"stex",startState:function(){var t=k?function(e,r){return s(e,r)}:m;return{cmdState:[],f:t}},copyState:function(t){return{cmdState:t.cmdState.slice(),f:t.f}},token:function(t,e){return e.f(t,e)},blankLine:function(t){t.f=m,t.cmdState.length=0},languageData:{commentTokens:{line:"%"}}}}const y=g(!1),S=g(!0);export{y as stex,S as stexMath};