/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */ /* vim: set ts=2 et sw=2 tw=80: */ /************************************************************* * * MathJax/extensions/mml2jax.js * * Implements the MathML to Jax preprocessor that locates nodes * within the text of a document and replaces them with SCRIPT tags * for processing by MathJax. * * --------------------------------------------------------------------- * * Copyright (c) 2010-2013 The MathJax Consortium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */MathJax.Extension.mml2jax={version:"2.2",config:{preview:"alttext"},MMLnamespace:"http://www.w3.org/1998/Math/MathML",PreProcess:function(a){this.configured||(this.config=MathJax.Hub.CombineConfig("mml2jax",this.config),this.config.Augment&&MathJax.Hub.Insert(this,this.config.Augment),this.InitBrowser(),this.configured=!0);"string"===typeof a&&(a=document.getElementById(a));a||(a=document.body);this.ProcessMathArray(a.getElementsByTagName("math"));a.getElementsByTagNameNS&&this.ProcessMathArray(a.getElementsByTagNameNS(this.MMLnamespace,"math"));var b,c;if("undefined"!==typeof document.namespaces)try{for(b=0,c=document.namespaces.length;b/i,"").replace(/<\?xml:namespace .*?\/>/i,""),d=d.replace(/ /g,"\x26#xA0;"));MathJax.HTML.setScript(c,d);b.removeChild(a)}else b=MathJax.HTML.Element("span"),b.appendChild(a),MathJax.HTML.setScript(c,b.innerHTML);"none"!==this.config.preview&&this.createPreview(a,c)},ProcessMathFlattened:function(a){var b=a.parentNode,c=document.createElement("script");c.type="math/mml";b.insertBefore(c,a);for(var b="",d,e=a;a&&"/MATH"!==a.nodeName;)d=a,a=a.nextSibling,b+=this.NodeHTML(d),d.parentNode.removeChild(d);a&&"/MATH"===a.nodeName&&a.parentNode.removeChild(a);c.text=b+"\x3c/math\x3e";"none"!==this.config.preview&&this.createPreview(e,c)},NodeHTML:function(a){var b,c,d;if("#text"===a.nodeName)b=this.quoteHTML(a.nodeValue);else if("#comment"===a.nodeName)b="\x3c!--"+a.nodeValue+"--\x3e";else{b="\x3c"+a.nodeName.toLowerCase();c=0;for(d=a.attributes.length;c|\/>)$/)){c=0;for(d=a.childNodes.length;c/g,"\x26gt;").replace(/\"/g,"\x26quot;")},createPreview:function(a,b){var c=this.config.preview;"none"!==c&&("alttext"===c&&(c=a.getAttribute("alttext"),c=null!=c?[this.filterPreview(c)]:null),c&&(c=MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},c),b.parentNode.insertBefore(c,b)))},filterPreview:function(a){return a},InitBrowser:function(){var a=MathJax.HTML.Element("span",{id:"\x3c",className:"mathjax",innerHTML:"\x3cmath\x3e\x3cmi\x3ex\x3c/mi\x3e\x3cmspace /\x3e\x3c/math\x3e"}),b=a.outerHTML||"";this.AttributeBug=""!==b&&!(b.match(/id="<"/)&&b.match(/class="mathjax"/)&&b.match(/<\/math>/));this.MathTagBug=1