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