@zklogic/draw.io
Version:
Draw.IO - Graph Editor integration in Angular-cli
1 lines • 5.25 kB
JavaScript
MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",(function(){var t=MathJax.ElementJax.mml,a=MathJax.Hub.config.menuSettings;t.mbase.Augment({toMathML:function(t){var a=this.inferred&&this.parent.inferRow;null==t&&(t="");var i=this.type,s=this.toMathMLattributes();if("mspace"===i)return t+"<"+i+s+" />";for(var h=[],e=this.isToken?"":t+(a?"":" "),n=0,o=this.data.length;n<o;n++)this.data[n]?h.push(this.data[n].toMathML(e)):this.isToken||this.isChars||h.push(e+"<mrow />");return this.isToken||this.isChars?t+"<"+i+s+">"+h.join("")+"</"+i+">":a?h.join("\n"):0===h.length||1===h.length&&""===h[0]?t+"<"+i+s+" />":t+"<"+i+s+">\n"+h.join("\n")+"\n"+t+"</"+i+">"},toMathMLattributes:function(){var a="mstyle"===this.type?t.math.prototype.defaults:this.defaults,i=this.attrNames||t.copyAttributeNames,s=t.skipAttributes,h=t.copyAttributes,e=[];if("math"!==this.type||this.attr&&"xmlns"in this.attr||e.push('xmlns="http://www.w3.org/1998/Math/MathML"'),!this.attrNames)for(var n in a)s[n]||h[n]||!a.hasOwnProperty(n)||null!=this[n]&&this[n]!==a[n]&&this.Get(n,null,1)!==this[n]&&e.push(n+'="'+this.toMathMLattribute(this[n])+'"');for(var o=0,r=i.length;o<r;o++)(1!==h[i[o]]||a.hasOwnProperty(i[o]))&&(value=(this.attr||{})[i[o]],null==value&&(value=this[i[o]]),null!=value&&e.push(i[o]+'="'+this.toMathMLquote(value)+'"'));return this.toMathMLclass(e),e.length?" "+e.join(" "):""},toMathMLclass:function(i){var s=[];if(this.class&&s.push(this.class),this.isa(t.TeXAtom)&&a.texHints){var h=["ORD","OP","BIN","REL","OPEN","CLOSE","PUNCT","INNER","VCENTER"][this.texClass];h&&(s.push("MJX-TeXAtom-"+h),"OP"!==h||this.movablelimits||s.push("MJX-fixedlimits"))}this.mathvariant&&this.toMathMLvariants[this.mathvariant]&&s.push("MJX"+this.mathvariant),this.variantForm&&s.push("MJX-variant"),s.length&&i.unshift('class="'+this.toMathMLquote(s.join(" "))+'"')},toMathMLattribute:function(t){return"string"==typeof t&&t.replace(/ /g,"").match(/^(([-+])?(\d+(\.\d*)?|\.\d+))mu$/)?(RegExp.$2||"")+(1/18*RegExp.$3).toFixed(3).replace(/\.?0+$/,"")+"em":this.toMathMLvariants[t]?this.toMathMLvariants[t]:this.toMathMLquote(t)},toMathMLvariants:{"-tex-caligraphic":t.VARIANT.SCRIPT,"-tex-caligraphic-bold":t.VARIANT.BOLDSCRIPT,"-tex-oldstyle":t.VARIANT.NORMAL,"-tex-oldstyle-bold":t.VARIANT.BOLD,"-tex-mathit":t.VARIANT.ITALIC},toMathMLquote:function(t){for(var a=0,i=(t=String(t).split("")).length;a<i;a++){var s=t[a].charCodeAt(0);if(s<=55295||57344<=s)if(s>126||s<32&&10!==s&&13!==s&&9!==s)t[a]="&#x"+s.toString(16).toUpperCase()+";";else{var h={"&":"&","<":"<",">":">",'"':"""}[t[a]];h&&(t[a]=h)}else if(a+1<i){var e=t[a+1].charCodeAt(0)-56320+(s-55296<<10)+65536;t[a]="&#x"+e.toString(16).toUpperCase()+";",t[a+1]="",a++}else t[a]=""}return t.join("")}}),t.math.Augment({toMathML:function(t,i){var s;null==t&&(t=""),i&&i.originalText&&a.semantics&&(s=MathJax.InputJax[i.inputJax].annotationEncoding);for(var h=this.data[0]&&this.data[0].data.length>1,e=this.type,n=this.toMathMLattributes(),o=[],r=t+(s?" "+(h?" ":""):"")+" ",u=0,M=this.data.length;u<M;u++)this.data[u]?o.push(this.data[u].toMathML(r)):o.push(r+"<mrow />");if(0===o.length||1===o.length&&""===o[0]){if(!s)return"<"+e+n+" />";o.push(r+"<mrow />")}if(s){h&&(o.unshift(t+" <mrow>"),o.push(t+" </mrow>")),o.unshift(t+" <semantics>");var l=i.originalText.replace(/[&<>]/g,(function(t){return{">":">","<":"<","&":"&"}[t]}));o.push(t+' <annotation encoding="'+this.toMathMLquote(s)+'">'+l+"</annotation>"),o.push(t+" </semantics>")}return t+"<"+e+n+">\n"+o.join("\n")+"\n"+t+"</"+e+">"}}),t.msubsup.Augment({toMathML:function(t){var a=this.type;null==this.data[this.sup]&&(a="msub"),null==this.data[this.sub]&&(a="msup");var i=this.toMathMLattributes();delete this.data[0].inferred;for(var s=[],h=0,e=this.data.length;h<e;h++)this.data[h]&&s.push(this.data[h].toMathML(t+" "));return t+"<"+a+i+">\n"+s.join("\n")+"\n"+t+"</"+a+">"}}),t.munderover.Augment({toMathML:function(a){var i=this.type,s=this.data[this.base];s&&s.isa(t.TeXAtom)&&s.movablelimits&&!s.Get("displaystyle")?(type="msubsup",null==this.data[this.under]&&(i="msup"),null==this.data[this.over]&&(i="msub")):(null==this.data[this.under]&&(i="mover"),null==this.data[this.over]&&(i="munder"));var h=this.toMathMLattributes();delete this.data[0].inferred;for(var e=[],n=0,o=this.data.length;n<o;n++)this.data[n]&&e.push(this.data[n].toMathML(a+" "));return a+"<"+i+h+">\n"+e.join("\n")+"\n"+a+"</"+i+">"}}),t.TeXAtom.Augment({toMathML:function(t){var a=this.toMathMLattributes();return a||1!==this.data[0].data.length?t+"<mrow"+a+">\n"+this.data[0].toMathML(t+" ")+"\n"+t+"</mrow>":t.substr(2)+this.data[0].toMathML(t)}}),t.chars.Augment({toMathML:function(t){return(t||"")+this.toMathMLquote(this.toString())}}),t.entity.Augment({toMathML:function(t){return(t||"")+"&"+this.toMathMLquote(this.data[0])+";\x3c!-- "+this.toString()+" --\x3e"}}),t.xml.Augment({toMathML:function(t){return(t||"")+this.toString()}}),MathJax.Hub.Register.StartupHook("TeX mathchoice Ready",(function(){t.TeXmathchoice.Augment({toMathML:function(t){return this.Core().toMathML(t)}})})),MathJax.Hub.Startup.signal.Post("toMathML Ready")})),MathJax.Ajax.loadComplete("[MathJax]/extensions/toMathML.js");