/* * /MathJax/jax/input/MathML/jax.js * * Copyright (c) 2010 Design Science, Inc. * * 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 */ (function(c,d){var b;var a={fontfamily:1,fontsize:1,fontweight:1,fontstyle:1,color:1,background:1,id:1,"class":1,href:1,style:1};c.Parse=MathJax.Object.Subclass({Init:function(e){this.Parse(e)},Parse:function(h){var i;if(typeof h!=="string"){i=h.parentNode}else{if(h.match(/^<[a-z]+:/i)&&!h.match(/^<[^<>]* xmlns:/)){h=h.replace(/^<([a-z]+)(:math)/i,'<$1$2 xmlns:$1="http://www.w3.org/1998/Math/MathML"')}var e=h.match(/^(])+)>)/i);if(e&&e[2].match(/ (?!xmlns=)[a-z]+=\"http:/i)){h=e[1].replace(/ (?!xmlns=)([a-z]+=(['"])http:.*?\2)/ig," xmlns:$1 $1")+h.substr(e[0].length)}h=h.replace(/^\s*(?:\/\/)?\s*$/,"$2");h=h.replace(/&([a-z][a-z0-9]*);/ig,this.replaceEntity);i=c.ParseXML(h);if(i==null){c.Error("Error parsing MathML")}}var g=i.getElementsByTagName("parsererror")[0];if(g){c.Error("Error parsing MathML: "+g.textContent.replace(/This page.*?errors:|XML Parsing Error: |Below is a rendering of the page.*/g,""))}if(i.childNodes.length!==1){c.Error("MathML must be formed by a single element")}if(i.firstChild.nodeName.toLowerCase()==="html"){var f=i.getElementsByTagName("h1")[0];if(f&&f.textContent==="XML parsing error"&&f.nextSibling){c.Error("Error parsing MathML: "+String(f.nextSibling.nodeValue).replace(/fatal parsing error: /,""))}}if(i.firstChild.nodeName.toLowerCase().replace(/^[a-z]+:/,"")!=="math"){c.Error("MathML must be formed by a element, not <"+i.firstChild.nodeName+">")}this.mml=this.MakeMML(i.firstChild)},MakeMML:function(h){var i=String(h.getAttribute("class"));var f,g=h.nodeName.toLowerCase().replace(/^[a-z]+:/,"");var e=(i.match(/(^| )MJX-TeXAtom-([^ ]*)/));if(e){f=this.TeXAtom(e[2])}else{if(!(b[g]&&b[g].isa&&b[g].isa(b.mbase))){MathJax.Hub.signal.Post(["MathML Jax - unknown node type",g]);return b.merror("Unknown node type: "+g)}else{f=b[g]()}}this.AddAttributes(f,h);this.CheckClass(f,i);this.AddChildren(f,h);if(c.config.useMathMLspacing){f.useMMLspacing=8}return f},TeXAtom:function(f){var e=b.TeXAtom().With({texClass:b.TEXCLASS[f]});if(e.texClass===b.TEXCLASS.OP){e.movesupsub=e.movablelimits=true}return e},CheckClass:function(f,h){h=h.split(/ /);var j=[];for(var g=0,e=h.length;g").replace(/&/g,"&")}}h=this.prefilterMath(h,e)}try{f=c.Parse(h).mml}catch(g){if(!g.mathmlError){throw g}f=this.formatError(g,h,e)}return b(f)},prefilterMath:function(f,e){return f},prefilterMathML:function(e){return e},formatError:function(h,g,e){var f=h.message.replace(/\n.*/,"");MathJax.Hub.signal.Post(["MathML Jax - parse error",f,g,e]);return b.merror(f)},Error:function(e){throw MathJax.Hub.Insert(Error(e),{mathmlError:true})},parseDOM:function(e){return this.parser.parseFromString(e,"text/xml")},parseMS:function(e){return(this.parser.loadXML(e)?this.parser:null)},parseDIV:function(e){this.div.innerHTML=e.replace(/<([a-z]+)([^>]*)\/>/g,"<$1$2>");return this.div},parseError:function(e){return null},createParser:function(){if(window.DOMParser){this.parser=new DOMParser();return(this.parseDOM)}else{if(window.ActiveXObject){var f=["MSXML2.DOMDocument.6.0","MSXML2.DOMDocument.5.0","MSXML2.DOMDocument.4.0","MSXML2.DOMDocument.3.0","MSXML2.DOMDocument.2.0","Microsoft.XMLDOM"];for(var g=0,e=f.length;g