UNPKG

mathjax

Version:

Beautiful and accessible math in all browsers. MathJax is an open-source JavaScript display engine for LaTeX, MathML, and AsciiMath notation that works in all browsers. This package includes the packaged components (install mathjax-full to get the source

1 lines 10.2 kB
(()=>{"use strict";var t={d:(e,a)=>{for(var o in a)t.o(a,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:a[o]})}};t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),t.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),t.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var e={};t.r(e),t.d(e,{TextParser:()=>P});var a={};t.r(a),t.d(a,{TextMacrosMethods:()=>L});var o={};t.r(o),t.d(o,{TextBaseConfiguration:()=>z,TextMacrosConfiguration:()=>j});const s=("undefined"!=typeof window?window:t.g).MathJax._.components.global,r=(s.GLOBAL,s.isObject,s.combineConfig,s.combineDefaults,s.combineWithMathJax),n=(s.MathJax,MathJax._.input.tex.HandlerTypes),i=n.ConfigurationType,c=n.HandlerType,l=MathJax._.input.tex.Configuration,h=l.Configuration,p=(l.ConfigurationHandler,l.ParserConfiguration),m=MathJax._.input.tex.ParseOptions.default,u=MathJax._.input.tex.Tags,d=(u.Label,u.TagInfo,u.AbstractTags,u.NoTags,u.AllTags,u.TagsFactory),x=MathJax._.input.tex.base.BaseItems,M=x.StartItem,g=x.StopItem,S=(x.OpenItem,x.CloseItem,x.NullItem,x.PrimeItem,x.SubsupItem,x.OverItem,x.LeftItem,x.Middle,x.RightItem,x.BreakItem,x.BeginItem,x.EndItem,x.StyleItem),f=(x.PositionItem,x.CellItem,x.MmlItem),A=(x.FnItem,x.NotItem,x.NonscriptItem,x.DotsItem,x.ArrayItem,x.EqnArrayItem,x.MstyleItem,x.EquationItem,MathJax._.input.tex.TexParser.default),k=MathJax._.input.tex.TexError.default,T=MathJax._.input.tex.ParseUtil,C=(T.KeyValueDef,T.KeyValueTypes,T.ParseUtil),b=MathJax._.core.MmlTree.MmlNode,v=(b.TEXCLASS,b.TEXCLASSNAMES,b.MATHVARIANTS,b.indentAttributes,b.AbstractMmlNode),O=(b.AbstractMmlTokenNode,b.AbstractMmlLayoutNode,b.AbstractMmlBaseNode,b.AbstractMmlEmptyNode,b.TextNode,b.XMLNode,MathJax._.input.tex.NodeUtil.default);class P extends A{get texParser(){return this.configuration.packageData.get("textmacros").texParser}get tags(){return this.texParser.tags}constructor(t,e,a,o){super(t,e,a),this.level=o}mml(){return this.copyLists(),this.configuration.popParser(),null!=this.level?this.create("node","mstyle",this.nodes,{displaystyle:!1,scriptlevel:this.level}):1===this.nodes.length?this.nodes[0]:this.create("node","mrow",this.nodes)}copyLists(){const t=this.texParser.configuration;for(const[e,a]of Object.entries(this.configuration.nodeLists))for(const o of a)t.addNode(e,o);this.configuration.nodeLists={}}Parse(){this.text="",this.nodes=[],this.envStack=[],super.Parse()}saveText(){if(this.text){const t=this.stack.env.mathvariant,e=C.internalText(this,this.text,t?{mathvariant:t}:{});this.text="",this.Push(e)}}Push(t){if(this.text&&this.saveText(),t instanceof g)return super.Push(t);t instanceof S?this.stack.env.mathcolor=this.stack.env.color:t instanceof v&&(this.addAttributes(t),this.nodes.push(t))}PushMath(t){const e=this.stack.env;for(const a of["mathsize","mathcolor"])e[a]&&!t.attributes.hasExplicit(a)&&(t.isToken||t.isKind("mstyle")||(t=this.create("node","mstyle",[t])),O.setAttribute(t,a,e[a]));t.isInferred&&(t=this.create("node","mrow",t.childNodes)),t.isKind("TeXAtom")||(t=this.create("node","TeXAtom",[t])),this.nodes.push(t)}addAttributes(t){const e=this.stack.env;if(t.isToken)for(const a of["mathsize","mathcolor","mathvariant"])e[a]&&!t.attributes.hasExplicit(a)&&O.setAttribute(t,a,e[a])}ParseTextArg(t,e){const a=this.GetArgument(t);return e=Object.assign(Object.assign({},this.stack.env),e),new P(a,e,this.configuration).mml()}ParseArg(t){return new P(this.GetArgument(t),this.stack.env,this.configuration).mml()}Error(t,e,...a){throw new k(t,e,...a)}}const y=MathJax._.util.Retries,I=(y.handleRetriesFor,y.retryAfter),R=MathJax._.input.tex.base.BaseMethods,E=(R.splitAlignArray,R.default),L={Comment(t,e){for(;t.i<t.string.length&&"\n"!==t.string.charAt(t.i);)t.i++;t.i++},Math(t,e){t.saveText();const a=t.i;let o,s,r=0;for(;s=t.GetNext();)switch(o=t.i++,s){case"\\":")"===t.GetCS()&&(s="\\(");case"$":if(0===r&&e===s){const e=t.texParser.configuration,s=new A(t.string.substring(a,o),t.stack.env,e).mml();return void t.PushMath(s)}break;case"{":r++;break;case"}":0===r&&t.Error("ExtraCloseMissingOpen","Extra close brace or missing open brace"),r--}t.Error("MathNotTerminated","Math mode is not properly terminated")},MathModeOnly(t,e){t.Error("MathModeOnly","'%1' allowed only in math mode",e)},Misplaced(t,e){t.Error("Misplaced","Misplaced '%1'",e)},OpenBrace(t,e){const a=t.stack.env;t.envStack.push(a),t.stack.env=Object.assign({},a)},CloseBrace(t,e){t.envStack.length?(t.saveText(),t.stack.env=t.envStack.pop()):t.Error("ExtraCloseMissingOpen","Extra close brace or missing open brace")},OpenQuote(t,e){t.string.charAt(t.i)===e?(t.text+="\u201c",t.i++):t.text+="\u2018"},CloseQuote(t,e){t.string.charAt(t.i)===e?(t.text+="\u201d",t.i++):t.text+="\u2019"},Tilde(t,e){t.text+="\xa0"},Space(t,e){t.text+=" ",t.GetNext()},SelfQuote(t,e){t.text+=e.substring(1)},Insert(t,e,a){t.text+=a},Accent(t,e,a){const o=t.ParseArg(e),s=t.create("token","mo",{},a);t.addAttributes(s),t.Push(t.create("node","mover",[o,s]))},Emph(t,e){const a="-tex-mathit"===t.stack.env.mathvariant?"normal":"-tex-mathit";t.Push(t.ParseTextArg(e,{mathvariant:a}))},TextFont(t,e,a){t.saveText(),t.Push(t.ParseTextArg(e,{mathvariant:a}))},SetFont(t,e,a){t.saveText(),t.stack.env.mathvariant=a},SetSize(t,e,a){t.saveText(),t.stack.env.mathsize=a},CheckAutoload(t,e){const a=t.configuration.packageData.get("autoload"),o=t.texParser;e=e.slice(1);const s=o.lookup(c.MACRO,e);if(!s||a&&s._func===a.Autoload){if(o.parse(c.MACRO,[o,e]),!s)return;I(Promise.resolve())}o.parse(c.MACRO,[t,e])},Macro:E.Macro,Spacer:E.Spacer,Hskip:E.Hskip,rule:E.rule,Rule:E.Rule,HandleRef:E.HandleRef,UnderOver:E.UnderOver,Lap:E.Lap,Phantom:E.Phantom,Smash:E.Smash,MmlToken:E.MmlToken},N=MathJax._.input.tex.TokenMap,w=(N.parseResult,N.AbstractTokenMap,N.RegExpMap,N.AbstractParseMap,N.CharacterMap,N.DelimiterMap,N.MacroMap),F=N.CommandMap,_=(N.EnvironmentMap,MathJax._.input.tex.TexConstants.TexConstant),H=MathJax._.util.lengths,J=(H.BIGDIMEN,H.UNITS,H.RELUNITS,H.MATHSPACE),D=(H.length2em,H.percent,H.em,H.px,_.Variant);new w("text-special",{$:L.Math,"%":L.Comment,"^":L.MathModeOnly,_:L.MathModeOnly,"&":L.Misplaced,"#":L.Misplaced,"~":L.Tilde," ":L.Space,"\t":L.Space,"\r":L.Space,"\n":L.Space,"\xa0":L.Tilde,"{":L.OpenBrace,"}":L.CloseBrace,"`":L.OpenQuote,"'":L.CloseQuote}),new F("text-macros",{"(":L.Math,$:L.SelfQuote,_:L.SelfQuote,"%":L.SelfQuote,"{":L.SelfQuote,"}":L.SelfQuote," ":L.SelfQuote,"&":L.SelfQuote,"#":L.SelfQuote,"\\":[L.Macro,"$\\\\$"],"'":[L.Accent,"\xb4"],"\u2019":[L.Accent,"\xb4"],"`":[L.Accent,"`"],"\u2018":[L.Accent,"`"],"^":[L.Accent,"^"],'"':[L.Accent,"\xa8"],"~":[L.Accent,"~"],"=":[L.Accent,"\xaf"],".":[L.Accent,"\u02d9"],u:[L.Accent,"\u02d8"],v:[L.Accent,"\u02c7"],emph:L.Emph,rm:[L.SetFont,D.NORMAL],mit:[L.SetFont,D.ITALIC],oldstyle:[L.SetFont,D.OLDSTYLE],cal:[L.SetFont,D.CALLIGRAPHIC],it:[L.SetFont,"-tex-mathit"],bf:[L.SetFont,D.BOLD],sf:[L.SetFont,D.SANSSERIF],tt:[L.SetFont,D.MONOSPACE],frak:[L.TextFont,D.FRAKTUR],Bbb:[L.TextFont,D.DOUBLESTRUCK],tiny:[L.SetSize,.5],Tiny:[L.SetSize,.6],scriptsize:[L.SetSize,.7],small:[L.SetSize,.85],normalsize:[L.SetSize,1],large:[L.SetSize,1.2],Large:[L.SetSize,1.44],LARGE:[L.SetSize,1.73],huge:[L.SetSize,2.07],Huge:[L.SetSize,2.49],textnormal:[L.Macro,"{\\rm #1}",1],textup:[L.Macro,"{\\rm #1}",1],textrm:[L.Macro,"{\\rm #1}",1],textit:[L.Macro,"{\\it #1}",1],textbf:[L.Macro,"{\\bf #1}",1],textsf:[L.Macro,"{\\sf #1}",1],texttt:[L.Macro,"{\\tt #1}",1],dagger:[L.Insert,"\u2020"],ddagger:[L.Insert,"\u2021"],S:[L.Insert,"\xa7"],AA:[L.Insert,"\u212b"],ldots:[L.Insert,"\u2026"],vdots:[L.Insert,"\u22ee"],",":[L.Spacer,J.thinmathspace],":":[L.Spacer,J.mediummathspace],">":[L.Spacer,J.mediummathspace],";":[L.Spacer,J.thickmathspace],"!":[L.Spacer,J.negativethinmathspace],enspace:[L.Spacer,.5],quad:[L.Spacer,1],qquad:[L.Spacer,2],thinspace:[L.Spacer,J.thinmathspace],negthinspace:[L.Spacer,J.negativethinmathspace],hskip:L.Hskip,hspace:L.Hskip,kern:L.Hskip,mskip:L.Hskip,mspace:L.Hskip,mkern:L.Hskip,rule:L.rule,Rule:[L.Rule],Space:[L.Rule,"blank"],color:L.CheckAutoload,textcolor:L.CheckAutoload,colorbox:L.CheckAutoload,fcolorbox:L.CheckAutoload,href:L.CheckAutoload,style:L.CheckAutoload,class:L.CheckAutoload,data:L.CheckAutoload,cssId:L.CheckAutoload,unicode:L.CheckAutoload,U:L.CheckAutoload,char:L.CheckAutoload,ref:[L.HandleRef,!1],eqref:[L.HandleRef,!0],underline:[L.UnderOver,"2015"],llap:L.Lap,rlap:L.Lap,phantom:L.Phantom,vphantom:[L.Phantom,1,0],hphantom:[L.Phantom,0,1],smash:L.Smash,mmlToken:L.MmlToken});const z=h.create("text-base",{[i.PARSER]:"text",[i.PRIORITY]:1,[i.HANDLER]:{[c.CHARACTER]:["command","text-special"],[c.MACRO]:["text-macros"]},[i.FALLBACK]:{[c.CHARACTER]:(t,e)=>{t.text+=e},[c.MACRO]:(t,e)=>{const a=t.texParser,o=a.lookup(c.MACRO,e);o&&o._func!==L.Macro&&t.Error("MathMacro","%1 is only supported in math mode","\\"+e),a.parse(c.MACRO,[t,e])}},[i.ITEMS]:{[M.prototype.kind]:M,[g.prototype.kind]:g,[f.prototype.kind]:f,[S.prototype.kind]:S}});function B(t,e,a,o){const s=t.configuration.packageData.get("textmacros");return t instanceof P||(s.texParser=t),s.parseOptions.clear(),[new P(e,o?{mathvariant:o}:{},s.parseOptions,a).mml()]}const j=h.create("textmacros",{[i.PRIORITY]:1,[i.CONFIG]:(t,e)=>{const a=new p(e.parseOptions.options.textmacros.packages,["tex","text"]);a.init();const o=new m(a,[]);o.options=e.parseOptions.options,a.config(e),d.addTags(a.tags),o.tags=d.getDefault(),o.tags.configuration=o,o.packageData=e.parseOptions.packageData,o.packageData.set("textmacros",{textConf:a,parseOptions:o,jax:e,texParser:null}),o.options.internalMath=B},[i.PREPROCESSORS]:[t=>{const e=t.data.packageData.get("textmacros");e.parseOptions.nodeFactory.setMmlFactory(e.jax.mmlFactory)}],[i.OPTIONS]:{textmacros:{packages:["text-base"]}}});MathJax.loader&&MathJax.loader.checkVersion("[tex]/textmacros","4.1.0","tex-extension"),r({_:{input:{tex:{textmacros:{TextMacrosConfiguration:o,TextMacrosMethods:a,TextParser:e}}}}})})();