Merge branch 'mathml-fixes' into v2.0-candidate

This commit is contained in:
Davide P. Cervone 2011-09-11 10:59:38 -04:00
commit dcc8620459
19 changed files with 95 additions and 74 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

File diff suppressed because one or more lines are too long

View File

@ -12,5 +12,5 @@
* http://www.apache.org/licenses/LICENSE-2.0
*/
MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function(){var b="1.1.1";var a=MathJax.ElementJax.mml;a.mbase.Augment({toMathML:function(k){var g=(this.inferred&&this.parent.inferRow);if(k==null){k=""}var e=this.type,d=this.MathMLattributes();if(e==="mspace"){return k+"<"+e+d+" />"}var j=[];var h=(this.isToken?"":k+(g?"":" "));for(var f=0,c=this.data.length;f<c;f++){if(this.data[f]){j.push(this.data[f].toMathML(h))}else{if(!this.isToken){j.push(h+"<mrow />")}}}if(this.isToken){return k+"<"+e+d+">"+j.join("")+"</"+e+">"}if(g){return j.join("\n")}if(j.length===0||(j.length===1&&j[0]==="")){return k+"<"+e+d+" />"}return k+"<"+e+d+">\n"+j.join("\n")+"\n"+k+"</"+e+">"},MathMLattributes:function(){var j=[],g=this.defaults;var c=this.copyAttributes,l=this.skipAttributes;if(this.type==="math"){j.push('xmlns="http://www.w3.org/1998/Math/MathML"')}if(this.type==="mstyle"){g=a.math.prototype.defaults}for(var d in g){if(!l[d]&&g.hasOwnProperty(d)){var e=(d==="open"||d==="close");if(this[d]!=null&&(e||this[d]!==g[d])){var k=this[d];delete this[d];if(e||this.Get(d)!==k){j.push(d+'="'+this.quoteHTML(k)+'"')}this[d]=k}}}for(var h=0,f=c.length;h<f;h++){if(this[c[h]]!=null){j.push(c[h]+'="'+this.quoteHTML(this[c[h]])+'"')}}if(j.length){return" "+j.join(" ")}else{return""}},copyAttributes:["fontfamily","fontsize","fontweight","fontstyle","color","background","id","class","href","style"],skipAttributes:{texClass:1,useHeight:1,texprimestyle:1},quoteHTML:function(e){e=String(e).split("");for(var f=0,d=e.length;f<d;f++){var h=e[f].charCodeAt(0);if(h<32||h>126){e[f]="&#x"+h.toString(16).toUpperCase()+";"}else{var g={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"}[e[f]];if(g){e[f]=g}}}return e.join("")}});a.msubsup.Augment({toMathML:function(h){var e=this.type;if(this.data[this.sup]==null){e="msub"}if(this.data[this.sub]==null){e="msup"}var d=this.MathMLattributes();delete this.data[0].inferred;var g=[];for(var f=0,c=this.data.length;f<c;f++){if(this.data[f]){g.push(this.data[f].toMathML(h+" "))}}return h+"<"+e+d+">\n"+g.join("\n")+"\n"+h+"</"+e+">"}});a.munderover.Augment({toMathML:function(h){var e=this.type;if(this.data[this.under]==null){e="mover"}if(this.data[this.over]==null){e="munder"}var d=this.MathMLattributes();delete this.data[0].inferred;var g=[];for(var f=0,c=this.data.length;f<c;f++){if(this.data[f]){g.push(this.data[f].toMathML(h+" "))}}return h+"<"+e+d+">\n"+g.join("\n")+"\n"+h+"</"+e+">"}});a.TeXAtom.Augment({toMathML:function(c){return c+"<mrow>\n"+this.data[0].toMathML(c+" ")+"\n"+c+"</mrow>"}});a.chars.Augment({toMathML:function(c){return(c||"")+this.quoteHTML(this.toString())}});a.entity.Augment({toMathML:function(c){return(c||"")+"&"+this.data[0]+";<!-- "+this.toString()+" -->"}});a.xml.Augment({toMathML:function(c){return(c||"")+this.toString()}});MathJax.Hub.Register.StartupHook("TeX mathchoice Ready",function(){a.TeXmathchoice.Augment({toMathML:function(c){return this.Core().toMathML(c)}})});MathJax.Hub.Startup.signal.Post("toMathML Ready")});MathJax.Ajax.loadComplete("[MathJax]/extensions/toMathML.js");
MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function(){var b="1.1.2";var a=MathJax.ElementJax.mml;a.mbase.Augment({toMathML:function(k){var g=(this.inferred&&this.parent.inferRow);if(k==null){k=""}var e=this.type,d=this.MathMLattributes();if(e==="mspace"){return k+"<"+e+d+" />"}var j=[];var h=(this.isToken?"":k+(g?"":" "));for(var f=0,c=this.data.length;f<c;f++){if(this.data[f]){j.push(this.data[f].toMathML(h))}else{if(!this.isToken){j.push(h+"<mrow />")}}}if(this.isToken){return k+"<"+e+d+">"+j.join("")+"</"+e+">"}if(g){return j.join("\n")}if(j.length===0||(j.length===1&&j[0]==="")){return k+"<"+e+d+" />"}return k+"<"+e+d+">\n"+j.join("\n")+"\n"+k+"</"+e+">"},MathMLattributes:function(){var j=[],g=this.defaults;var c=this.copyAttributes,l=this.skipAttributes;if(this.type==="math"){j.push('xmlns="http://www.w3.org/1998/Math/MathML"')}if(this.type==="mstyle"){g=a.math.prototype.defaults}for(var d in g){if(!l[d]&&g.hasOwnProperty(d)){var e=(d==="open"||d==="close");if(this[d]!=null&&(e||this[d]!==g[d])){var k=this[d];delete this[d];if(e||this.Get(d)!==k){j.push(d+'="'+this.formatAttr(k)+'"')}this[d]=k}}}for(var h=0,f=c.length;h<f;h++){if(this[c[h]]!=null){j.push(c[h]+'="'+this.quoteHTML(this[c[h]])+'"')}}if(j.length){return" "+j.join(" ")}else{return""}},copyAttributes:["fontfamily","fontsize","fontweight","fontstyle","color","background","id","class","href","style"],skipAttributes:{texClass:1,useHeight:1,texprimestyle:1},formatAttr:function(c){if(typeof(c)==="string"&&c.replace(/ /g,"").match(/^(([-+])?(\d+(\.\d*)?|\.\d+))mu$/)){return(RegExp.$2+(1/18)*RegExp.$1).replace(/(\.\d\d\d).*/,"$1")+"em"}if(c==="-tex-caligraphic"){return"script"}if(c==="-tex-oldstyle"){return"normal"}return this.quoteHTML(c)},quoteHTML:function(e){e=String(e).split("");for(var f=0,d=e.length;f<d;f++){var h=e[f].charCodeAt(0);if(h<32||h>126){e[f]="&#x"+h.toString(16).toUpperCase()+";"}else{var g={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"}[e[f]];if(g){e[f]=g}}}return e.join("")}});a.msubsup.Augment({toMathML:function(h){var e=this.type;if(this.data[this.sup]==null){e="msub"}if(this.data[this.sub]==null){e="msup"}var d=this.MathMLattributes();delete this.data[0].inferred;var g=[];for(var f=0,c=this.data.length;f<c;f++){if(this.data[f]){g.push(this.data[f].toMathML(h+" "))}}return h+"<"+e+d+">\n"+g.join("\n")+"\n"+h+"</"+e+">"}});a.munderover.Augment({toMathML:function(h){var e=this.type;if(this.data[this.under]==null){e="mover"}if(this.data[this.over]==null){e="munder"}var d=this.MathMLattributes();delete this.data[0].inferred;var g=[];for(var f=0,c=this.data.length;f<c;f++){if(this.data[f]){g.push(this.data[f].toMathML(h+" "))}}return h+"<"+e+d+">\n"+g.join("\n")+"\n"+h+"</"+e+">"}});a.TeXAtom.Augment({toMathML:function(c){return c+"<mrow>\n"+this.data[0].toMathML(c+" ")+"\n"+c+"</mrow>"}});a.chars.Augment({toMathML:function(c){return(c||"")+this.quoteHTML(this.toString())}});a.entity.Augment({toMathML:function(c){return(c||"")+"&"+this.data[0]+";<!-- "+this.toString()+" -->"}});a.xml.Augment({toMathML:function(c){return(c||"")+this.toString()}});MathJax.Hub.Register.StartupHook("TeX mathchoice Ready",function(){a.TeXmathchoice.Augment({toMathML:function(c){return this.Core().toMathML(c)}})});MathJax.Hub.Startup.signal.Post("toMathML Ready")});MathJax.Ajax.loadComplete("[MathJax]/extensions/toMathML.js");

View File

@ -12,5 +12,5 @@
* http://www.apache.org/licenses/LICENSE-2.0
*/
MathJax.InputJax.MathML=MathJax.InputJax({id:"MathML",version:"1.1.4",directory:MathJax.InputJax.directory+"/MathML",extensionDir:MathJax.InputJax.extensionDir+"/MathML",entityDir:MathJax.InputJax.directory+"/MathML/entities",config:{useMathMLspacing:false}});MathJax.InputJax.MathML.Register("math/mml");MathJax.InputJax.MathML.loadComplete("config.js");
MathJax.InputJax.MathML=MathJax.InputJax({id:"MathML",version:"1.1.7",directory:MathJax.InputJax.directory+"/MathML",extensionDir:MathJax.InputJax.extensionDir+"/MathML",entityDir:MathJax.InputJax.directory+"/MathML/entities",config:{useMathMLspacing:false}});MathJax.InputJax.MathML.Register("math/mml");MathJax.InputJax.MathML.loadComplete("config.js");

File diff suppressed because one or more lines are too long

View File

@ -12,5 +12,5 @@
* http://www.apache.org/licenses/LICENSE-2.0
*/
MathJax.OutputJax.NativeMML=MathJax.OutputJax({id:"NativeMML",version:"1.1.4",directory:MathJax.OutputJax.directory+"/NativeMML",extensionDir:MathJax.OutputJax.extensionDir+"/NativeMML",config:{scale:100,showMathMenu:true,showMathMenuMSIE:true,styles:{"DIV.MathJax_MathML":{"text-align":"center",margin:".75em 0px"}}}});if(!MathJax.Hub.config.delayJaxRegistration){MathJax.OutputJax.NativeMML.Register("jax/mml")}MathJax.OutputJax.NativeMML.loadComplete("config.js");
MathJax.OutputJax.NativeMML=MathJax.OutputJax({id:"NativeMML",version:"1.1.6",directory:MathJax.OutputJax.directory+"/NativeMML",extensionDir:MathJax.OutputJax.extensionDir+"/NativeMML",config:{scale:100,showMathMenu:true,showMathMenuMSIE:true,styles:{"DIV.MathJax_MathML":{"text-align":"center",margin:".75em 0px"}}}});if(!MathJax.Hub.config.delayJaxRegistration){MathJax.OutputJax.NativeMML.Register("jax/mml")}MathJax.OutputJax.NativeMML.loadComplete("config.js");

File diff suppressed because one or more lines are too long

View File

@ -13,11 +13,12 @@
<p>
When <math><mi>a</mi><mo>&#x2260;</mo><mn>0</mn></math>,
there are two solutions to <math>
there are two solutions to
<math>
<mi>a</mi><msup><mi>x</mi><mn>2</mn></msup>
<mo>+</mo> <mi>b</mi><mi>x</mi>
<mo>+</mo> <mi>c</mi> <mo>=</mo> <mn>0</mn>
</math> and they are
<mo>+</mo> <mi>c</mi> <mo>=</mo> <mn>0</mn></math>
and they are
<math mode="display">
<mi>x</mi> <mo>=</mo>
<mrow>

View File

@ -23,7 +23,7 @@
*/
MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () {
var VERSION = "1.1.1";
var VERSION = "1.1.2";
var MML = MathJax.ElementJax.mml;
@ -58,7 +58,7 @@ MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () {
if (this[id] != null && (force || this[id] !== defaults[id])) {
var value = this[id]; delete this[id];
if (force || this.Get(id) !== value)
{attr.push(id+'="'+this.quoteHTML(value)+'"')}
{attr.push(id+'="'+this.formatAttr(value)+'"')}
this[id] = value;
}
}}
@ -74,6 +74,18 @@ MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () {
],
skipAttributes: {texClass: 1, useHeight: 1, texprimestyle: 1},
formatAttr: function (value) {
if (typeof(value) === "string" &&
value.replace(/ /g,"").match(/^(([-+])?(\d+(\.\d*)?|\.\d+))mu$/)) {
// FIXME: should take scriptlevel into account
return (RegExp.$2+(1/18)*RegExp.$1).replace(/(\.\d\d\d).*/,"$1")+"em";
}
// FIXME: set classes for these?
if (value === "-tex-caligraphic") {return "script"}
if (value === "-tex-oldstyle") {return "normal"}
return this.quoteHTML(value);
},
quoteHTML: function (string) {
string = String(string).split("");
for (var i = 0, m = string.length; i < m; i++) {

View File

@ -24,7 +24,7 @@
MathJax.InputJax.MathML = MathJax.InputJax({
id: "MathML",
version: "1.1.4",
version: "1.1.7",
directory: MathJax.InputJax.directory + "/MathML",
extensionDir: MathJax.InputJax.extensionDir + "/MathML",
entityDir: MathJax.InputJax.directory + "/MathML/entities",

View File

@ -38,6 +38,12 @@
if (typeof math !== "string") {doc = math.parentNode} else {
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].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");
math = math.replace(/&([a-z][a-z0-9]*);/ig,this.replaceEntity);
doc = MATHML.ParseXML(math); if (doc == null) {MATHML.Error("Error parsing MathML")}
@ -98,9 +104,10 @@
},
trimSpace: function (string) {
return string.replace(/^[ \t\n\r]+/,"") // initial whitespace
.replace(/[ \t\n\r]+$/,"") // trailing whitespace
.replace(/[ \t\n\r][ \t\n\r]+/g," "); // internal multiple whitespace
return string.replace(/[\t\n\r]/g," ") // whitespace to spaces
.replace(/^ +/,"") // initial whitespace
.replace(/ +$/,"") // trailing whitespace
.replace(/ +/g," "); // internal multiple whitespace
},
replaceEntity: function (match,entity) {
@ -206,7 +213,7 @@
MML = MathJax.ElementJax.mml;
MML.mspace.Augment({mmlSelfClosing: true});
MML.none.Augment({mmlSelfClosing: true});
MML.mprescripts.Augment({mmlSelfClossing:true});
MML.mprescripts.Augment({mmlSelfClosing:true});
}
});

View File

@ -24,7 +24,7 @@
MathJax.OutputJax.NativeMML = MathJax.OutputJax({
id: "NativeMML",
version: "1.1.4",
version: "1.1.6",
directory: MathJax.OutputJax.directory + "/NativeMML",
extensionDir: MathJax.OutputJax.extensionDir + "/NativeMML",

View File

@ -298,9 +298,10 @@
NativeMMLattribute: function (id,value) {
value = String(value);
if (nMML.NAMEDSPACE[value]) {value = nMML.NAMEDSPACE[value]} // MP doesn't do negative spaes
else if (value.match(/^\s*([-+]?(\d+(\.\d*)?|\.\d+))\s*mu\s*$/)) {value = ((1/18)*RegExp.$1)+"em"} // FIXME: should take scriptlevel into account
else if (value === "-tex-caligraphic") {value = "script"}
else if (value === "-tex-oldstyle") {value = "normal"}
else if (value.match(/^\s*(([-+])?(\d+(\.\d*)?|\.\d+))\s*mu\s*$/))
{value = (RegExp.$2+(1/18)*RegExp.$1).replace(/(\.\d\d\d).*/,"$1")+"em"} // FIXME: should take scriptlevel into account
else if (value === "-tex-caligraphic") {value = "script"} // FIXME: add a class?
else if (value === "-tex-oldstyle") {value = "normal"} // FIXME: add a class?
return value;
},
//
@ -394,7 +395,7 @@
}
});
var fontDir = MathJax.Hub.config.root + "/fonts/HTML-CSS/TeX/otf";
var fontDir = MathJax.OutputJax.fontDir + "/HTML-CSS/TeX/otf";
/*
* Add fix for mathvariant issues in FF
@ -402,44 +403,44 @@
nMML.Augment({
config: {
styles: {
'[mathvariant="double-struck"]': {"font-family":"MathJax_AMS"},
'[mathvariant="script"]': {"font-family":"MathJax_Script"},
'[mathvariant="fraktur"]': {"font-family":"MathJax_Fraktur"},
'[mathvariant="-tex-oldstyle"]': {"font-family":"MathJax_Caligraphic"},
'[mathvariant="-tex-oldstyle-bold"]': {"font-family":"MathJax_Caligraphic", "font-weight":"bold"},
'[mathvariant="-tex-caligraphic"]': {"font-family":"MathJax_Caligraphic"},
'[mathvariant="-tex-caligraphic-bold"]': {"font-family":"MathJax_Caligraphic", "font-weight":"bold"},
'[mathvariant="bold-script"]': {"font-family":"MathJax_Script", "font-weight":"bold"},
'[mathvariant="bold-fraktur"]': {"font-family":"MathJax_Fraktur", "font-weight":"bold"},
'[mathvariant="double-struck"]': {"font-family":"MathJax_AMS, MathJax_AMS-WEB"},
'[mathvariant="script"]': {"font-family":"MathJax_Script, MathJax_Script-WEB"},
'[mathvariant="fraktur"]': {"font-family":"MathJax_Fraktur, MathJax_Fraktur-WEB"},
'[mathvariant="-tex-oldstyle"]': {"font-family":"MathJax_Caligraphic, MathJax_Caligraphic-WEB"},
'[mathvariant="-tex-oldstyle-bold"]': {"font-family":"MathJax_Caligraphic, MathJax_Caligraphic-WEB", "font-weight":"bold"},
'[mathvariant="-tex-caligraphic"]': {"font-family":"MathJax_Caligraphic, MathJax_Caligraphic-WEB"},
'[mathvariant="-tex-caligraphic-bold"]': {"font-family":"MathJax_Caligraphic, MathJax_Caligraphic-WEB", "font-weight":"bold"},
'[mathvariant="bold-script"]': {"font-family":"MathJax_Script, MathJax_Caligraphic-WEB", "font-weight":"bold"},
'[mathvariant="bold-fraktur"]': {"font-family":"MathJax_Fraktur, MathJax_Fraktur-WEB", "font-weight":"bold"},
'[mathvariant="monospace"]': {"font-family":"monospace"},
'[mathvariant="sans-serif"]': {"font-family":"sansserif"},
'[mathvariant="bold-sans-serif"]': {"font-family":"sansserif", "font-weight":"bold"},
'[mathvariant="sans-serif-italic"]': {"font-family":"sansserif", "font-style":"italic"},
'[mathvariant="sans-serif-bold-italic"]': {"font-family":"sansserif", "font-style":"italic", "font-weight":"bold"},
'[mathvariant="sans-serif"]': {"font-family":"sans-serif"},
'[mathvariant="bold-sans-serif"]': {"font-family":"sans-serif", "font-weight":"bold"},
'[mathvariant="sans-serif-italic"]': {"font-family":"sans-serif", "font-style":"italic"},
'[mathvariant="sans-serif-bold-italic"]': {"font-family":"sans-serif", "font-style":"italic", "font-weight":"bold"},
'@font-face /*1*/': {
"font-family": "MathJax_AMS",
"src": "local('MathJax_AMS'), url('"+fontDir+"/MathJax_AMS-Regular.otf')"
"font-family": "MathJax_AMS-WEB",
"src": "url('"+fontDir+"/MathJax_AMS-Regular.otf')*/"
},
'@font-face /*2*/': {
"font-family": "MathJax_Script",
"src": "local('MathJax_Script'), url('"+fontDir+"/MathJax_Script-Regular.otf')"
"font-family": "MathJax_Script-WEB",
"src": "url('"+fontDir+"/MathJax_Script-Regular.otf')"
},
'@font-face /*3*/': {
"font-family": "MathJax_Fraktur",
"src": "local('MathJax_Fraktur'), url('"+fontDir+"/MathJax_Fraktur-Regular.otf')"
"font-family": "MathJax_Fraktur-WEB",
"src": "url('"+fontDir+"/MathJax_Fraktur-Regular.otf')"
},
'@font-face /*4*/': {
"font-family": "MathJax_Caligraphic",
"src": "local('MathJax_Caligraphic'), url('"+fontDir+"/MathJax_Caligraphic-Regular.otf')"
"font-family": "MathJax_Caligraphic-WEB",
"src": "url('"+fontDir+"/MathJax_Caligraphic-Regular.otf')"
},
'@font-face /*5*/': {
"font-family": "MathJax_Fraktur", "font-weight":"bold",
"src": "local('MathJax_Fraktur-Bold'), url('"+fontDir+"/MathJax_Fraktur-Bold.otf')"
"font-family": "MathJax_Fraktur-WEB", "font-weight":"bold",
"src": "url('"+fontDir+"/MathJax_Fraktur-Bold.otf')"
},
'@font-face /*6*/': {
"font-family": "MathJax_Caligraphic", "font-weight":"bold",
"src": "local('MathJax_Caligraphic-Bold'), url('"+fontDir+"/MathJax_Caligraphic-Bold.otf')"
"font-family": "MathJax_Caligraphic-WEB", "font-weight":"bold",
"src": "url('"+fontDir+"/MathJax_Caligraphic-Bold.otf')"
}
}
}