/* * /MathJax/extensions/jsMath2jax.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.jsMath2jax={version:"2.2",config:{preview:"TeX"},PreProcess:function(a){this.configured||(this.config=MathJax.Hub.CombineConfig("jsMath2jax",this.config),this.config.Augment&&MathJax.Hub.Insert(this,this.config.Augment),"undefined"===typeof this.config.previewTeX||this.config.previewTeX||(this.config.preview="none"),this.previewClass=MathJax.Hub.config.preRemoveClass,this.configured=!0);"string"===typeof a&&(a=document.getElementById(a));a||(a=document.body);var c=a.getElementsByTagName("span"),b;for(b=c.length-1;0<=b;b--)String(c[b].className).match(/(^| )math( |$)/)&&this.ConvertMath(c[b],"");a=a.getElementsByTagName("div");for(b=a.length-1;0<=b;b--)String(a[b].className).match(/(^| )math( |$)/)&&this.ConvertMath(a[b],"; mode\x3ddisplay")},ConvertMath:function(a,c){if(0===a.getElementsByTagName("script").length){var b=a.parentNode,d=this.createMathTag(c,a.innerHTML);a.nextSibling?b.insertBefore(d,a.nextSibling):b.appendChild(d);"none"!==this.config.preview&&this.createPreview(a);b.removeChild(a)}},createPreview:function(a){var c=this.config.preview;"TeX"===c&&(c=[this.filterPreview(a.innerHTML)]);c&&(c=MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},c),a.parentNode.insertBefore(c,a))},createMathTag:function(a,c){c=c.replace(/</g,"\x3c").replace(/>/g,"\x3e").replace(/&/g,"\x26");var b=document.createElement("script");b.type="math/tex"+a;MathJax.HTML.setScript(b,c);return b},filterPreview:function(a){return a}};MathJax.Hub.Register.PreProcessor(["PreProcess",MathJax.Extension.jsMath2jax],8);MathJax.Ajax.loadComplete("[MathJax]/extensions/jsMath2jax.js");