/* * /MathJax/extensions/TeX/mhchem.js * * Copyright (c) 2009-2013 The MathJax Consortium * * Part of the MathJax library. * See http://www.mathjax.org for details. * * Licensed under the Apache License, Version 2.0; * you may not use this file except in compliance with the License. * * http://www.apache.org/licenses/LICENSE-2.0 */MathJax.Extension["TeX/mhchem"]={version:"2.2"};MathJax.Hub.Register.StartupHook("TeX Jax Ready",function(){var c=MathJax.InputJax.TeX,d=MathJax.Object.Subclass({string:"",i:0,tex:"",atom:!1,sup:"",sub:"",Init:function(a){this.string=a},ParseTable:{"-":"Minus","+":"Plus","(":"Open",")":"Close","[":"Open","]":"Close","\x3c":"Less","^":"Superscript",_:"Subscript","*":"Dot",".":"Dot","\x3d":"Equal","#":"Pound",$:"Math","\\":"Macro"," ":"Space"},Arrows:{"-\x3e":"rightarrow","\x3c-":"leftarrow","\x3c-\x3e":"leftrightarrow","\x3c\x3d\x3e":"rightleftharpoons","\x3c\x3d\x3e\x3e":"Rightleftharpoons","\x3c\x3c\x3d\x3e":"Leftrightharpoons","^":"uparrow",v:"downarrow"},Bonds:{"-":"-","\x3d":"\x3d","#":"\\equiv","~":"\\tripledash","~-":"\\begin{CEstack}{}\\tripledash\\\\-\\end{CEstack}","~\x3d":"\\raise2mu{\\begin{CEstack}{}\\tripledash\\\\-\\\\-\\end{CEstack}}","~--":"\\raise2mu{\\begin{CEstack}{}\\tripledash\\\\-\\\\-\\end{CEstack}}","-~-":"\\raise2mu{\\begin{CEstack}{}-\\\\\\tripledash\\\\-\\end{CEstack}}","...":"{\\cdot}{\\cdot}{\\cdot}","....":"{\\cdot}{\\cdot}{\\cdot}{\\cdot}","-\x3e":"\\rightarrow","\x3c-":"\\leftarrow","??":"\\text{??}"},Parse:function(){this.tex="";for(this.atom=!1;this.i?|<=>>?|<<=>)/);b?this.AddArrow(b):(this.tex+=a,this.i++)},ParseSuperscript:function(a){a=this.string.charAt(++this.i);if("{"===a)this.i++,a=this.Find("}"),"-."===a?this.sup+="{-}{\\cdot}":a&&(this.sup+=d(a).Parse().replace(/^\{-\}/,"-"));else if(" "===a||""===a)this.tex+="{\\"+this.Arrows["^"]+"}",this.i++;else if(a=this.Match(/^(\d+|-\.)/))this.sup+=a},ParseSubscript:function(a){if("{"==this.string.charAt(++this.i))this.i++,this.sub+=d(this.Find("}")).Parse().replace(/^\{-\}/,"-");else if(a=this.Match(/^\d+/))this.sub+=a},ParseMath:function(a){this.FinishAtom();this.i++;this.tex+=this.Find(a)},ParseMacro:function(a){this.FinishAtom();this.i++;var b=this.Match(/^([a-z]+|.)/i)||" ";"sbond"===b?this.tex+="{-}":"dbond"===b?this.tex+="{\x3d}":"tbond"===b?this.tex+="{\\equiv}":"bond"===b?(a=this.Match(/^\{.*?\}/)||"",a=a.substr(1,a.length-2),this.tex+="{"+(this.Bonds[a]||"\\text{??}")+"}"):"{"===b?this.tex+="{\\{":"}"===b?(this.tex+="\\}}",this.atom=!0):this.tex+=a+b},ParseSpace:function(a){this.FinishAtom();this.i++},ParseOther:function(a){this.FinishAtom();this.tex+=a;this.i++},AddArrow:function(a){var b=this.Match(/^[CT]\[/);b&&(this.i--,b=b.charAt(0));var c=this.GetBracket(b),b=this.GetBracket(b);a=this.Arrows[a];c||b?(b&&(a+="["+b+"]"),a="\\mathrel{\\x"+(a+("{"+c+"}"))+"}"):a="\\long"+a+" ";this.tex+=a},FinishAtom:function(){if(this.sup||this.sub){if(this.sup&&this.sub&&!this.atom){var a=this.sup,b=this.sub;a.match(/\d/)||(a+="\\vphantom{0}");b.match(/\d/)||(b+="\\vphantom{0}");this.tex+="\\raise 1pt{\\scriptstyle\\begin{CEscriptstack}"+a+"\\\\"+b+"\\end{CEscriptstack}}\\kern-.125em "}else this.sup||(this.sup="\\Space{0pt}{0pt}{.2em}"),this.tex+="^{"+this.sup+"}_{"+this.sub+"}";this.sup=this.sub=""}this.atom=!1},GetBracket:function(a){if("["!==this.string.charAt(this.i))return"";this.i++;var b=this.Find("]");"C"===a?b="\\ce{"+b+"}":"T"===a&&(b.match(/^\{.*\}$/)||(b="{"+b+"}"),b="\\text"+b);return b},Match:function(a){if(a=a.exec(this.string.substr(this.i)))a=a[0],this.i+=a.length;return a},Find:function(a){for(var b=this.string.length,d=this.i,e=0;this.i