Improve the previous fix for xmlns by using better regexp so as to no longer need replaceXMLNS function

This commit is contained in:
Davide P. Cervone 2011-07-27 15:06:02 -04:00
parent 7f6c93b1c9
commit d2b40a3235
8 changed files with 10 additions and 15 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -39,9 +39,9 @@
if (math.match(/^<[a-z]+:/i) && !math.match(/^<[^<>]* xmlns:/))
{math = math.replace(/^<([a-z]+)(:math)/i,'<$1$2 xmlns:$1="http://www.w3.org/1998/Math/MathML"')}
// HTML5 removes xmlns: namespaces, so put them back for XML
var match = math.match(/^(<math( ('[^']*'|"[^"]"|[^>])+)>)/i);
if (match && match[2].replace(/ xmlns=".*?"/,"").match(/ [a-z]+=\"http:/i)) {
math = match[1].replace(/ ([a-z]+)=("http:.*?")/ig,this.replaceXMLNS) +
var match = math.match(/^(<math( ('.*?'|".*?"|[^>])+)>)/i);
if (match && match[2].match(/ (?!xmlns=)[a-z]+=\"http:/i)) {
math = match[1].replace(/ (?!xmlns=)([a-z]+=(['"])http:.*?\2)/ig," xmlns:$1 $1") +
math.substr(match[0].length);
}
math = math.replace(/^\s*(?:\/\/)?<!(--)?\[CDATA\[((.|\n)*)(\/\/)?\]\]\1>\s*$/,"$2");
@ -109,11 +109,6 @@
.replace(/[ \t\n\r][ \t\n\r]+/g," "); // internal multiple whitespace
},
replaceXMLNS: function (match,name,value) {
if (name === "xmlns") {return " " + name + "=" + value}
return " xmlns:"+name+"="+value + " " + name+"="+value;
},
replaceEntity: function (match,entity) {
if (entity.match(/^(lt|amp|quot)$/)) {return match} // these mess up attribute parsing
if (MATHML.Parse.Entity[entity]) {return MATHML.Parse.Entity[entity]}