Preliminary change to custom tag names (for easier readability, and less chance of CSS bleed-through).
This commit is contained in:
parent
8f5677f2de
commit
6399338521
|
@ -37,40 +37,47 @@
|
||||||
HFUZZ = .05, DFUZZ = 0; // adjustments to bounding box of character boxes
|
HFUZZ = .05, DFUZZ = 0; // adjustments to bounding box of character boxes
|
||||||
|
|
||||||
var STYLES = {
|
var STYLES = {
|
||||||
".MJXc-script": {"font-size":SCRIPTFACTOR+"em"},
|
".MJXc-display": {
|
||||||
".MJXc-right": {
|
"display": "block",
|
||||||
"-webkit-transform-origin":"right",
|
"text-align": "center",
|
||||||
"-moz-transform-origin":"right",
|
"margin": "1em 0"
|
||||||
"-ms-transform-origin":"right",
|
|
||||||
"-o-transform-origin":"right",
|
|
||||||
"transform-origin":"right"
|
|
||||||
},
|
},
|
||||||
|
|
||||||
".MJXc-math": {
|
"mjx-math": {
|
||||||
"display":"inline-block",
|
"display": "inline-block",
|
||||||
"line-height":"0",
|
"line-height": 0,
|
||||||
"text-indent":"0",
|
"text-indent": 0,
|
||||||
"white-space":"nowrap",
|
"white-space": "nowrap",
|
||||||
"border-collapse":"collapse"
|
"border-collapse":"collapse"
|
||||||
},
|
},
|
||||||
".MJXc-display": {
|
"mjx-math *": {display:"inline-block"},
|
||||||
"display": "block",
|
|
||||||
"text-align": "center",
|
|
||||||
"margin": "1em 0"
|
|
||||||
},
|
|
||||||
".MJXc-math span": {"display":"inline-block"},
|
|
||||||
".MJXc-box": {"display":"block!important", "text-align":"center"},
|
|
||||||
".MJXc-rule": {"display":"block!important", "margin-top":"1px"},
|
|
||||||
".MJXc-char": {"display":"block!important"},
|
|
||||||
|
|
||||||
".MJXc-mfrac": {"margin":"0 .125em", "vertical-align":AXISHEIGHT+"em",
|
"mjx-mfrac": {"vertical-align":".25em"},
|
||||||
"display":"inline-table!important", "text-align":"center"},
|
"mjx-fbox": {width:"100%"},
|
||||||
".MJXc-mfrac > span": {"display":"table-row!important"},
|
|
||||||
".MJXc-num > span": {"display":"inline-block", "width":"100%"},
|
"mjx-mphantom": {"visibility":"hidden"},
|
||||||
".MJXc-num > span > span": {"display":"table!important", "width":"100%"},
|
|
||||||
".MJXc-den > span": {"display":"table-cell!important"},
|
"mjx-merror": {
|
||||||
".MJXc-mfrac-row": {"display":"table-row!important"},
|
"background-color":"#FFFF88",
|
||||||
".MJXc-mfrac-row > span": {"display":"table-cell!important", "width":"100%"},
|
color: "#CC0000",
|
||||||
|
border: "1px solid #CC0000",
|
||||||
|
padding: "1px 3px",
|
||||||
|
"font-style": "normal",
|
||||||
|
"font-size": "90%"
|
||||||
|
},
|
||||||
|
|
||||||
|
"mjx-box": {display:"inline-block"},
|
||||||
|
"mjx-block": {display:"block"},
|
||||||
|
"mjx-char": {display:"block", "xline-height":"normal"},
|
||||||
|
"mjx-itable": {display:"inline-table"},
|
||||||
|
"mjx-row": {display:"table-row"},
|
||||||
|
"mjx-cell": {display:"table-cell", "text-align":"center"},
|
||||||
|
"mjx-table": {display:"table", width:"100%"},
|
||||||
|
"mjx-line": {display:"block", width:"100%", "border-top":"0 solid"},
|
||||||
|
|
||||||
|
".MJXc-script": {"font-size":SCRIPTFACTOR+"em"},
|
||||||
|
|
||||||
|
/*********************************/
|
||||||
|
|
||||||
".MJXc-surd": {"vertical-align":"top"},
|
".MJXc-surd": {"vertical-align":"top"},
|
||||||
".MJXc-surd > span": {"display":"block!important"},
|
".MJXc-surd > span": {"display":"block!important"},
|
||||||
|
@ -80,8 +87,6 @@
|
||||||
".MJXc-script-box > span:last-child > span": {"vertical-align":"bottom"},
|
".MJXc-script-box > span:last-child > span": {"vertical-align":"bottom"},
|
||||||
".MJXc-script-box > span > span > span": {"display":"block!important"},
|
".MJXc-script-box > span > span > span": {"display":"block!important"},
|
||||||
|
|
||||||
".MJXc-mphantom": {"visibility":"hidden"},
|
|
||||||
|
|
||||||
".MJXc-munderover": {"display":"inline-table!important"},
|
".MJXc-munderover": {"display":"inline-table!important"},
|
||||||
".MJXc-over": {"display":"inline-block!important", "text-align":"center"},
|
".MJXc-over": {"display":"inline-block!important", "text-align":"center"},
|
||||||
".MJXc-over > span": {"display":"block!important"},
|
".MJXc-over > span": {"display":"block!important"},
|
||||||
|
@ -321,7 +326,7 @@
|
||||||
do {math = math.nextSibling} while (math && math.nodeName.toLowerCase() !== "script");
|
do {math = math.nextSibling} while (math && math.nodeName.toLowerCase() !== "script");
|
||||||
return HUB.getJaxFor(math);
|
return HUB.getJaxFor(math);
|
||||||
},
|
},
|
||||||
getHoverSpan: function (jax,math) {return jax.root.CHTMLspanElement()},
|
getHoverSpan: function (jax,math) {return jax.root.CHTMLnodeElement()},
|
||||||
getHoverBBox: function (jax,span,math) {
|
getHoverBBox: function (jax,span,math) {
|
||||||
// var bbox = span.CHTML, em = jax.CHTML.outerEm;
|
// var bbox = span.CHTML, em = jax.CHTML.outerEm;
|
||||||
// var BBOX = {w:bbox.w*em, h:bbox.h*em, d:bbox.d*em};
|
// var BBOX = {w:bbox.w*em, h:bbox.h*em, d:bbox.d*em};
|
||||||
|
@ -470,7 +475,7 @@
|
||||||
},
|
},
|
||||||
unknownChar: function (variant,n) {},
|
unknownChar: function (variant,n) {},
|
||||||
|
|
||||||
addCharList: function (span,list,bbox) {
|
addCharList: function (node,list,bbox) {
|
||||||
var text = "", className;
|
var text = "", className;
|
||||||
for (var i = 0, m = list.length; i < m; i++) {
|
for (var i = 0, m = list.length; i < m; i++) {
|
||||||
var item = list[i];
|
var item = list[i];
|
||||||
|
@ -478,7 +483,7 @@
|
||||||
case "char":
|
case "char":
|
||||||
var font = item.font;
|
var font = item.font;
|
||||||
if (className && font.className !== className) {
|
if (className && font.className !== className) {
|
||||||
HTML.addElement(span,"span",{className:className},[text]);
|
HTML.addElement(node,"span",{className:className},[text]);
|
||||||
text = ""; className = null;
|
text = ""; className = null;
|
||||||
}
|
}
|
||||||
var C = font[item.n];
|
var C = font[item.n];
|
||||||
|
@ -492,11 +497,11 @@
|
||||||
if (bbox.D < font.descent) bbox.D = font.descent;
|
if (bbox.D < font.descent) bbox.D = font.descent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (span.childNodes.length) {
|
if (node.childNodes.length) {
|
||||||
HTML.addElement(span,"span",{className:className},[text]);
|
HTML.addElement(node,"span",{className:className},[text]);
|
||||||
} else {
|
} else {
|
||||||
HTML.addText(span,text);
|
HTML.addText(node,text);
|
||||||
span.className += " "+className;
|
node.className += " "+className;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -580,25 +585,25 @@
|
||||||
MML = MathJax.ElementJax.mml;
|
MML = MathJax.ElementJax.mml;
|
||||||
|
|
||||||
MML.mbase.Augment({
|
MML.mbase.Augment({
|
||||||
toCommonHTML: function (span,options) {
|
toCommonHTML: function (node,options) {
|
||||||
return this.CHTMLdefaultSpan(span,options);
|
return this.CHTMLdefaultNode(node,options);
|
||||||
},
|
},
|
||||||
|
|
||||||
CHTMLdefaultSpan: function (span,options) {
|
CHTMLdefaultNode: function (node,options) {
|
||||||
if (!options) options = {};
|
if (!options) options = {};
|
||||||
span = this.CHTMLcreateSpan(span);
|
node = this.CHTMLcreateNode(node);
|
||||||
this.CHTMLhandleSpace(span);
|
this.CHTMLhandleSpace(node);
|
||||||
this.CHTMLhandleStyle(span);
|
this.CHTMLhandleStyle(node);
|
||||||
this.CHTMLhandleColor(span);
|
this.CHTMLhandleColor(node);
|
||||||
for (var i = 0, m = this.data.length; i < m; i++) this.CHTMLaddChild(span,i,options);
|
for (var i = 0, m = this.data.length; i < m; i++) this.CHTMLaddChild(node,i,options);
|
||||||
return span;
|
return node;
|
||||||
},
|
},
|
||||||
CHTMLaddChild: function (span,i,options) {
|
CHTMLaddChild: function (node,i,options) {
|
||||||
var child = this.data[i];
|
var child = this.data[i];
|
||||||
if (child) {
|
if (child) {
|
||||||
if (options.childSpans)
|
if (options.childNodes)
|
||||||
span = HTML.addElement(span,"span",{className:options.className});
|
node = HTML.addElement(node,options.childNodes);
|
||||||
child.toCommonHTML(span,options.childOptions);
|
child.toCommonHTML(node,options.childOptions);
|
||||||
if (!options.noBBox) {
|
if (!options.noBBox) {
|
||||||
var bbox = this.CHTML, cbox = child.CHTML;
|
var bbox = this.CHTML, cbox = child.CHTML;
|
||||||
if (cbox.r + bbox.w > bbox.r) bbox.r = bbox.w + cbox.r;
|
if (cbox.r + bbox.w > bbox.r) bbox.r = bbox.w + cbox.r;
|
||||||
|
@ -608,7 +613,7 @@
|
||||||
if (cbox.d > bbox.d) bbox.d = cbox.d;
|
if (cbox.d > bbox.d) bbox.d = cbox.d;
|
||||||
if (cbox.ic) {bbox.ic = cbox.ic} else {delete bbox.ic}
|
if (cbox.ic) {bbox.ic = cbox.ic} else {delete bbox.ic}
|
||||||
}
|
}
|
||||||
} else if (options.forceChild) {HTML.addElement(span,"span")}
|
} else if (options.forceChild) {HTML.addElement(node,"span")}
|
||||||
},
|
},
|
||||||
CHTMLstretchChild: function (i,H,D) {
|
CHTMLstretchChild: function (i,H,D) {
|
||||||
var data = this.data[i];
|
var data = this.data[i];
|
||||||
|
@ -621,54 +626,54 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
CHTMLcreateSpan: function (span) {
|
CHTMLcreateNode: function (node) {
|
||||||
if (!this.CHTML) this.CHTML = {};
|
if (!this.CHTML) this.CHTML = {};
|
||||||
this.CHTML = {w:0, h:0, d:0, l:0, r:0, t:0, b:0};
|
this.CHTML = {w:0, h:0, d:0, l:0, r:0, t:0, b:0};
|
||||||
if (this.inferred) return span;
|
if (this.inferred) return node;
|
||||||
if (!this.CHTMLspanID) {this.CHTMLspanID = CHTML.GetID()};
|
if (!this.CHTMLnodeID) {this.CHTMLnodeID = CHTML.GetID()};
|
||||||
var id = (this.id || "MJXc-Span-"+this.CHTMLspanID);
|
var id = (this.id || "MJXc-Node-"+this.CHTMLnodeID);
|
||||||
return HTML.addElement(span,"span",{className:"MJXc-"+this.type, id:id});
|
return HTML.addElement(node,"mjx-"+this.type,{className:"MJXc-"+this.type, id:id});
|
||||||
},
|
},
|
||||||
CHTMLspanElement: function () {
|
CHTMLnodeElement: function () {
|
||||||
if (!this.CHTMLspanID) {return null}
|
if (!this.CHTMLnodeID) {return null}
|
||||||
return document.getElementById(this.id||"MJXc-Span-"+this.CHTMLspanID);
|
return document.getElementById(this.id||"MJXc-Node-"+this.CHTMLnodeID);
|
||||||
},
|
},
|
||||||
|
|
||||||
CHTMLhandleStyle: function (span) {
|
CHTMLhandleStyle: function (node) {
|
||||||
if (this.style) span.style.cssText = this.style;
|
if (this.style) node.style.cssText = this.style;
|
||||||
},
|
},
|
||||||
|
|
||||||
CHTMLhandleColor: function (span) {
|
CHTMLhandleColor: function (node) {
|
||||||
if (this.mathcolor) {span.style.color = this.mathcolor}
|
if (this.mathcolor) {node.style.color = this.mathcolor}
|
||||||
else if (this.color) {span.style.color = this.color}
|
else if (this.color) {node.style.color = this.color}
|
||||||
if (this.mathbackground) {span.style.backgroundColor = this.mathbackground}
|
if (this.mathbackground) {node.style.backgroundColor = this.mathbackground}
|
||||||
else if (this.background) {span.style.backgroundColor = this.background}
|
else if (this.background) {node.style.backgroundColor = this.background}
|
||||||
},
|
},
|
||||||
|
|
||||||
CHTMLhandleSpace: function (span) {
|
CHTMLhandleSpace: function (node) {
|
||||||
if (!this.useMMLspacing) {
|
if (!this.useMMLspacing) {
|
||||||
var space = this.texSpacing();
|
var space = this.texSpacing();
|
||||||
if (space !== "") span.style.marginLeft = CHTML.Em(CHTML.length2em(space));
|
if (space !== "") node.style.marginLeft = CHTML.Em(CHTML.length2em(space));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
CHTMLhandleScriptlevel: function (span,dlevel) {
|
CHTMLhandleScriptlevel: function (node,dlevel) {
|
||||||
var level = this.Get("scriptlevel");
|
var level = this.Get("scriptlevel");
|
||||||
if (level === 0) return;
|
if (level === 0) return;
|
||||||
// ### FIXME: handle scriptminsize
|
// ### FIXME: handle scriptminsize
|
||||||
if (level > 2) level = 2;
|
if (level > 2) level = 2;
|
||||||
if (level > 0 && dlevel == null) {
|
if (level > 0 && dlevel == null) {
|
||||||
span.className += " MJXc-script";
|
node.className += " MJXc-script";
|
||||||
} else {
|
} else {
|
||||||
if (dlevel) level -= dlevel;
|
if (dlevel) level -= dlevel;
|
||||||
var scale = Math.floor(Math.pow(SCRIPTFACTOR,level)*100);
|
var scale = Math.floor(Math.pow(SCRIPTFACTOR,level)*100);
|
||||||
span.style.fontSize = scale+"%";
|
node.style.fontSize = scale+"%";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
CHTMLhandleText: function (span,text,variant) {
|
CHTMLhandleText: function (node,text,variant) {
|
||||||
if (span.childNodes.length === 0) {
|
if (node.childNodes.length === 0) {
|
||||||
HTML.addElement(span,"span",{className:"MJXc-char"});
|
HTML.addElement(node,"mjx-char");
|
||||||
this.CHTML = {h:-BIGDIMEN, d:-BIGDIMEN, w:0, l:BIGDIMEN, r:-BIGDIMEN,
|
this.CHTML = {h:-BIGDIMEN, d:-BIGDIMEN, w:0, l:BIGDIMEN, r:-BIGDIMEN,
|
||||||
D:-BIGDIMEN, H:-BIGDIMEN};
|
D:-BIGDIMEN, H:-BIGDIMEN};
|
||||||
}
|
}
|
||||||
|
@ -680,7 +685,7 @@
|
||||||
var n = CHTML.getUnicode(string);
|
var n = CHTML.getUnicode(string);
|
||||||
list.push.apply(list,CHTML.getCharList(variant,n));
|
list.push.apply(list,CHTML.getCharList(variant,n));
|
||||||
}
|
}
|
||||||
CHTML.addCharList(span.firstChild,list,bbox);
|
CHTML.addCharList(node.firstChild,list,bbox);
|
||||||
if (bbox.h === -BIGDIMEN) bbox.h = 0;
|
if (bbox.h === -BIGDIMEN) bbox.h = 0;
|
||||||
if (bbox.d === -BIGDIMEN) bbox.d = 0;
|
if (bbox.d === -BIGDIMEN) bbox.d = 0;
|
||||||
if (bbox.l === BIGDIMEN) bbox.l = 0;
|
if (bbox.l === BIGDIMEN) bbox.l = 0;
|
||||||
|
@ -689,14 +694,25 @@
|
||||||
if (bbox.D === -BIGDIMEN) bbox.D = .2;
|
if (bbox.D === -BIGDIMEN) bbox.D = .2;
|
||||||
bbox.h += HFUZZ; bbox.d += DFUZZ;
|
bbox.h += HFUZZ; bbox.d += DFUZZ;
|
||||||
var a = (bbox.H-bbox.D)/2; // center of font (line-height:0)
|
var a = (bbox.H-bbox.D)/2; // center of font (line-height:0)
|
||||||
span.firstChild.style.marginTop = CHTML.Em(bbox.h-a);
|
node.firstChild.style.marginTop = CHTML.Em(bbox.h-a);
|
||||||
span.firstChild.style.marginBottom = CHTML.Em(bbox.d+a);
|
node.firstChild.style.marginBottom = CHTML.Em(bbox.d+a);
|
||||||
},
|
},
|
||||||
|
|
||||||
CHTMLbboxFor: function (n) {
|
CHTMLbboxFor: function (n) {
|
||||||
if (this.data[n] && this.data[n].CHTML) return this.data[n].CHTML;
|
if (this.data[n] && this.data[n].CHTML) return this.data[n].CHTML;
|
||||||
return {w:0, h:0, d:0, l:0, r:0};
|
return {w:0, h:0, d:0, l:0, r:0};
|
||||||
},
|
},
|
||||||
|
//
|
||||||
|
// Debugging function to see if internal BBox matches actual bbox
|
||||||
|
//
|
||||||
|
CHTMLdrawBBox: function (node) {
|
||||||
|
var bbox = this.CHTML;
|
||||||
|
HTML.addElement(node.parentNode,"mjx-box",{style:{opacity:.5,"margin-left":CHTML.Em(-bbox.w)}},[
|
||||||
|
["mjx-box",{style:{height:CHTML.Em(bbox.h),width:CHTML.Em(bbox.w),"background-color":"red"}}],
|
||||||
|
["mjx-box",{style:{height:CHTML.Em(bbox.d),width:CHTML.Em(bbox.w),"margin-left":CHTML.Em(-bbox.w),"vertical-align":CHTML.Em(-bbox.d),"background-color":"green"}}]
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
CHTMLcanStretch: function (direction,H,D) {
|
CHTMLcanStretch: function (direction,H,D) {
|
||||||
if (this.isEmbellished()) {
|
if (this.isEmbellished()) {
|
||||||
|
@ -711,47 +727,47 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
MML.chars.Augment({
|
MML.chars.Augment({
|
||||||
toCommonHTML: function (span,options) {
|
toCommonHTML: function (node,options) {
|
||||||
if (options == null) options = {};
|
if (options == null) options = {};
|
||||||
var text = this.toString();
|
var text = this.toString();
|
||||||
if (options.remap) text = options.remap(text,options.remapchars);
|
if (options.remap) text = options.remap(text,options.remapchars);
|
||||||
// ### FIXME: handle mtextFontInherit
|
// ### FIXME: handle mtextFontInherit
|
||||||
this.CHTMLhandleText(span,text,options.variant||this.parent.Get("mathvariant"));
|
this.CHTMLhandleText(node,text,options.variant||this.parent.Get("mathvariant"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
MML.entity.Augment({
|
MML.entity.Augment({
|
||||||
toCommonHTML: function (span,options) {
|
toCommonHTML: function (node,options) {
|
||||||
if (options == null) options = {};
|
if (options == null) options = {};
|
||||||
var text = this.toString();
|
var text = this.toString();
|
||||||
if (options.remapchars) text = options.remap(text,options.remapchars);
|
if (options.remapchars) text = options.remap(text,options.remapchars);
|
||||||
// ### FIXME: handle mtextFontInherit
|
// ### FIXME: handle mtextFontInherit
|
||||||
this.CHTMLhandleText(span,text,options.variant||this.parent.Get("mathvariant"));
|
this.CHTMLhandleText(node,text,options.variant||this.parent.Get("mathvariant"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
MML.math.Augment({
|
MML.math.Augment({
|
||||||
toCommonHTML: function (span) {
|
toCommonHTML: function (node) {
|
||||||
span = this.CHTMLdefaultSpan(span);
|
node = this.CHTMLdefaultNode(node);
|
||||||
if (this.Get("display") === "block") {span.className += " MJXc-display"}
|
if (this.Get("display") === "block") {node.className += " MJXc-display"}
|
||||||
return span;
|
return node;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
MML.mi.Augment({
|
MML.mi.Augment({
|
||||||
toCommonHTML: function (span) {
|
toCommonHTML: function (node) {
|
||||||
span = this.CHTMLdefaultSpan(span);
|
node = this.CHTMLdefaultNode(node);
|
||||||
var bbox = this.CHTML, text = this.data.join("");
|
var bbox = this.CHTML, text = this.data.join("");
|
||||||
if (bbox.skew != null && text.length !== 1) delete bbox.skew;
|
if (bbox.skew != null && text.length !== 1) delete bbox.skew;
|
||||||
if (bbox.r > bbox.w && text.length === 1 /*&& !variant.noIC*/) { // ### FIXME: handle variants
|
if (bbox.r > bbox.w && text.length === 1 /*&& !variant.noIC*/) { // ### FIXME: handle variants
|
||||||
bbox.ic = bbox.r - bbox.w; bbox.w = bbox.r;
|
bbox.ic = bbox.r - bbox.w; bbox.w = bbox.r;
|
||||||
span.style.paddingRight = CHTML.Em(bbox.ic);
|
node.style.paddingRight = CHTML.Em(bbox.ic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
MML.mo.Augment({
|
MML.mo.Augment({
|
||||||
toCommonHTML: function (span) {
|
toCommonHTML: function (node) {
|
||||||
span = this.CHTMLcreateSpan(span);
|
node = this.CHTMLcreateNode(node);
|
||||||
|
|
||||||
var values = this.getValues("displaystyle","largeop","mathvariant");
|
var values = this.getValues("displaystyle","largeop","mathvariant");
|
||||||
values.text = this.data.join("");
|
values.text = this.data.join("");
|
||||||
|
@ -759,22 +775,22 @@
|
||||||
this.CHTMLadjustVariant(values);
|
this.CHTMLadjustVariant(values);
|
||||||
|
|
||||||
for (var i = 0, m = this.data.length; i < m; i++) {
|
for (var i = 0, m = this.data.length; i < m; i++) {
|
||||||
this.CHTMLaddChild(span,i,{childOptions:{
|
this.CHTMLaddChild(node,i,{childOptions:{
|
||||||
variant: values.mathvariant,
|
variant: values.mathvariant,
|
||||||
remap: this.remap,
|
remap: this.remap,
|
||||||
remapchars: values.mapchars
|
remapchars: values.mapchars
|
||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
if (values.text.length !== 1) delete this.CHTML.skew;
|
if (values.text.length !== 1) delete this.CHTML.skew;
|
||||||
if (values.largeop) this.CHTMLcenterOp(span);
|
if (values.largeop) this.CHTMLcenterOp(node);
|
||||||
|
|
||||||
this.CHTMLhandleSpace(span);
|
this.CHTMLhandleSpace(node);
|
||||||
this.CHTMLhandleStyle(span);
|
this.CHTMLhandleStyle(node);
|
||||||
this.CHTMLhandleColor(span);
|
this.CHTMLhandleColor(node);
|
||||||
|
|
||||||
return span;
|
return node;
|
||||||
},
|
},
|
||||||
CHTMLhandleSpace: function (span) {
|
CHTMLhandleSpace: function (node) {
|
||||||
if (this.useMMLspacing) {
|
if (this.useMMLspacing) {
|
||||||
var values = this.getValues("scriptlevel","lspace","rspace");
|
var values = this.getValues("scriptlevel","lspace","rspace");
|
||||||
values.lspace = Math.max(0,CHTML.length2em(values.lspace));
|
values.lspace = Math.max(0,CHTML.length2em(values.lspace));
|
||||||
|
@ -785,9 +801,9 @@
|
||||||
}
|
}
|
||||||
var core = this, parent = this.Parent();
|
var core = this, parent = this.Parent();
|
||||||
while (parent && parent.isEmbellished() && parent.Core() === core)
|
while (parent && parent.isEmbellished() && parent.Core() === core)
|
||||||
{core = parent; parent = parent.Parent(); span = core.CHTMLspanElement()}
|
{core = parent; parent = parent.Parent(); node = core.CHTMLnodeElement()}
|
||||||
if (values.lspace) {span.style.paddingLeft = CHTML.Em(values.lspace)}
|
if (values.lspace) {node.style.paddingLeft = CHTML.Em(values.lspace)}
|
||||||
if (values.rspace) {span.style.paddingRight = CHTML.Em(values.rspace)}
|
if (values.rspace) {node.style.paddingRight = CHTML.Em(values.rspace)}
|
||||||
} else {
|
} else {
|
||||||
this.SUPER(arguments).CHTMLhandleSpace.apply(this,arguments);
|
this.SUPER(arguments).CHTMLhandleSpace.apply(this,arguments);
|
||||||
}
|
}
|
||||||
|
@ -814,14 +830,14 @@
|
||||||
data.mathvariant = "-TeX-variant"; // ### FIXME: handle other fonts
|
data.mathvariant = "-TeX-variant"; // ### FIXME: handle other fonts
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
CHTMLcenterOp: function (span) {
|
CHTMLcenterOp: function (node) {
|
||||||
var bbox = this.CHTML;
|
var bbox = this.CHTML;
|
||||||
var p = (bbox.h - bbox.d)/2 - AXISHEIGHT;
|
var p = (bbox.h - bbox.d)/2 - AXISHEIGHT;
|
||||||
if (Math.abs(p) > .001) span.style.verticalAlign = CHTML.Em(-p);
|
if (Math.abs(p) > .001) node.style.verticalAlign = CHTML.Em(-p);
|
||||||
bbox.h -= p; bbox.d += p;
|
bbox.h -= p; bbox.d += p;
|
||||||
if (bbox.r > bbox.w) {
|
if (bbox.r > bbox.w) {
|
||||||
bbox.ic = bbox.r - bbox.w; bbox.w = bbox.r;
|
bbox.ic = bbox.r - bbox.w; bbox.w = bbox.r;
|
||||||
span.style.paddingRight = CHTML.Em(bbox.ic);
|
node.style.paddingRight = CHTML.Em(bbox.ic);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
CHTMLcanStretch: function (direction,H,D) {
|
CHTMLcanStretch: function (direction,H,D) {
|
||||||
|
@ -837,7 +853,7 @@
|
||||||
return stretch;
|
return stretch;
|
||||||
},
|
},
|
||||||
CHTMLstretchV: function (h,d) {
|
CHTMLstretchV: function (h,d) {
|
||||||
var span = this.CHTMLspanElement(), bbox = this.CHTML; //bbox.w = .4; // ## adjust width
|
var node = this.CHTMLnodeElement(), bbox = this.CHTML; //bbox.w = .4; // ## adjust width
|
||||||
var values = this.getValues("symmetric","maxsize","minsize");
|
var values = this.getValues("symmetric","maxsize","minsize");
|
||||||
if (values.symmetric) {H = 2*Math.max(h-AXISHEIGHT,d+AXISHEIGHT)} else {H = h + d}
|
if (values.symmetric) {H = 2*Math.max(h-AXISHEIGHT,d+AXISHEIGHT)} else {H = h + d}
|
||||||
values.maxsize = CHTML.length2em(values.maxsize,bbox.h+bbox.d);
|
values.maxsize = CHTML.length2em(values.maxsize,bbox.h+bbox.d);
|
||||||
|
@ -851,42 +867,42 @@
|
||||||
box.style.marginLeft = CHTML.Em(bbox.w*(sX/10-1)+.07);
|
box.style.marginLeft = CHTML.Em(bbox.w*(sX/10-1)+.07);
|
||||||
bbox.w *= scale*sX/10;
|
bbox.w *= scale*sX/10;
|
||||||
}
|
}
|
||||||
box.appendChild(span.firstChild); span.appendChild(box);
|
box.appendChild(node.firstChild); node.appendChild(box);
|
||||||
if (values.symmetric) span.style.verticalAlign = CHTML.Em(AXISHEIGHT*(1-scale));
|
if (values.symmetric) node.style.verticalAlign = CHTML.Em(AXISHEIGHT*(1-scale));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
MML.mspace.Augment({
|
MML.mspace.Augment({
|
||||||
toCommonHTML: function (span) {
|
toCommonHTML: function (node) {
|
||||||
span = this.CHTMLcreateSpan(span);
|
node = this.CHTMLcreateNode(node);
|
||||||
this.CHTMLhandleStyle(span);
|
this.CHTMLhandleStyle(node);
|
||||||
this.CHTMLhandleColor(span);
|
this.CHTMLhandleColor(node);
|
||||||
var values = this.getValues("height","depth","width");
|
var values = this.getValues("height","depth","width");
|
||||||
var w = CHTML.length2em(values.width),
|
var w = CHTML.length2em(values.width),
|
||||||
h = CHTML.length2em(values.height),
|
h = CHTML.length2em(values.height),
|
||||||
d = CHTML.length2em(values.depth);
|
d = CHTML.length2em(values.depth);
|
||||||
var bbox = this.CHTML;
|
var bbox = this.CHTML;
|
||||||
bbox.w = w; bbox.h = h; bbox.d = d;
|
bbox.w = w; bbox.h = h; bbox.d = d;
|
||||||
if (w < 0) {span.style.marginRight = CHTML.Em(w); w = 0}
|
if (w < 0) {node.style.marginRight = CHTML.Em(w); w = 0}
|
||||||
span.style.width = CHTML.Em(w);
|
node.style.width = CHTML.Em(w);
|
||||||
span.style.height = CHTML.Em(h+d);
|
node.style.height = CHTML.Em(h+d);
|
||||||
if (d) span.style.verticalAlign = CHTML.Em(-d);
|
if (d) node.style.verticalAlign = CHTML.Em(-d);
|
||||||
return span;
|
return node;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
MML.mpadded.Augment({
|
MML.mpadded.Augment({
|
||||||
toCommonHTML: function (span) {
|
toCommonHTML: function (node) {
|
||||||
span = this.CHTMLdefaultSpan(span,{
|
node = this.CHTMLdefaultNode(node,{
|
||||||
childSpans:true, className:"MJXc-box", forceChild:true
|
childNodes:"mjx-box", forceChild:true
|
||||||
});
|
});
|
||||||
var child = span.firstChild;
|
var child = node.firstChild;
|
||||||
var values = this.getValues("width","height","depth","lspace","voffset");
|
var values = this.getValues("width","height","depth","lspace","voffset");
|
||||||
var dimen = this.CHTMLdimen(values.lspace);
|
var dimen = this.CHTMLdimen(values.lspace);
|
||||||
var T = 0, B = 0, L = dimen.len, R = -dimen.len, V = 0;
|
var T = 0, B = 0, L = dimen.len, R = -dimen.len, V = 0;
|
||||||
if (values.width !== "") {
|
if (values.width !== "") {
|
||||||
dimen = this.CHTMLdimen(values.width,"w",0);
|
dimen = this.CHTMLdimen(values.width,"w",0);
|
||||||
if (dimen.pm) {R += dimen.len} else {span.style.width = CHTML.Em(dimen.len)}
|
if (dimen.pm) {R += dimen.len} else {node.style.width = CHTML.Em(dimen.len)}
|
||||||
}
|
}
|
||||||
if (values.height !== "") {
|
if (values.height !== "") {
|
||||||
dimen = this.CHTMLdimen(values.height,"h",0);
|
dimen = this.CHTMLdimen(values.height,"h",0);
|
||||||
|
@ -907,8 +923,8 @@
|
||||||
if (B) child.style.marginBottom = CHTML.Em(B);
|
if (B) child.style.marginBottom = CHTML.Em(B);
|
||||||
if (L) child.style.marginLeft = CHTML.Em(L);
|
if (L) child.style.marginLeft = CHTML.Em(L);
|
||||||
if (R) child.style.marginRight = CHTML.Em(R);
|
if (R) child.style.marginRight = CHTML.Em(R);
|
||||||
if (V) span.style.verticalAlign = CHTML.Em(V);
|
if (V) node.style.verticalAlign = CHTML.Em(V);
|
||||||
return span;
|
return node;
|
||||||
},
|
},
|
||||||
CHTMLdimen: function (length,d,m) {
|
CHTMLdimen: function (length,d,m) {
|
||||||
if (m == null) {m = -BIGDIMEN}
|
if (m == null) {m = -BIGDIMEN}
|
||||||
|
@ -920,30 +936,30 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
MML.munderover.Augment({
|
MML.munderover.Augment({
|
||||||
toCommonHTML: function (span) {
|
toCommonHTML: function (node) {
|
||||||
var values = this.getValues("displaystyle","accent","accentunder","align");
|
var values = this.getValues("displaystyle","accent","accentunder","align");
|
||||||
if (!values.displaystyle && this.data[this.base] != null &&
|
if (!values.displaystyle && this.data[this.base] != null &&
|
||||||
this.data[this.base].CoreMO().Get("movablelimits")) {
|
this.data[this.base].CoreMO().Get("movablelimits")) {
|
||||||
span = MML.msubsup.prototype.toCommonHTML.call(this,span);
|
node = MML.msubsup.prototype.toCommonHTML.call(this,node);
|
||||||
//
|
//
|
||||||
// Change class to msubsup for CSS rules.
|
// Change class to msubsup for CSS rules.
|
||||||
// ### FIXME: should this be handled via adding another class instead?
|
// ### FIXME: should this be handled via adding another class instead?
|
||||||
//
|
//
|
||||||
span.className = span.className.replace(/munderover/,"msubsup");
|
node.className = node.className.replace(/munderover/,"msubsup");
|
||||||
return span;
|
return node;
|
||||||
}
|
}
|
||||||
span = this.CHTMLdefaultSpan(span,{childSpans:true, className:"", noBBox:true});
|
node = this.CHTMLdefaultNode(node,{childNodes:"span", noBBox:true});
|
||||||
var obox = this.CHTMLbboxFor(this.over),
|
var obox = this.CHTMLbboxFor(this.over),
|
||||||
ubox = this.CHTMLbboxFor(this.under),
|
ubox = this.CHTMLbboxFor(this.under),
|
||||||
bbox = this.CHTMLbboxFor(this.base),
|
bbox = this.CHTMLbboxFor(this.base),
|
||||||
BBOX = this.CHTML, acc = obox.acc;
|
BBOX = this.CHTML, acc = obox.acc;
|
||||||
if (this.data[this.over]) {
|
if (this.data[this.over]) {
|
||||||
span.lastChild.firstChild.style.marginLeft = obox.l =
|
node.lastChild.firstChild.style.marginLeft = obox.l =
|
||||||
span.lastChild.firstChild.style.marginRight = obox.r = 0;
|
node.lastChild.firstChild.style.marginRight = obox.r = 0;
|
||||||
var over = HTML.Element("span",{},[["span",{className:"MJXc-over"}]]);
|
var over = HTML.Element("span",{},[["span",{className:"MJXc-over"}]]);
|
||||||
over.firstChild.appendChild(span.lastChild);
|
over.firstChild.appendChild(node.lastChild);
|
||||||
if (span.childNodes.length > (this.data[this.under] ? 1 : 0))
|
if (node.childNodes.length > (this.data[this.under] ? 1 : 0))
|
||||||
over.firstChild.appendChild(span.firstChild);
|
over.firstChild.appendChild(node.firstChild);
|
||||||
this.data[this.over].CHTMLhandleScriptlevel(over.firstChild.firstChild);
|
this.data[this.over].CHTMLhandleScriptlevel(over.firstChild.firstChild);
|
||||||
if (acc != null) {
|
if (acc != null) {
|
||||||
if (obox.vec) {
|
if (obox.vec) {
|
||||||
|
@ -953,31 +969,31 @@
|
||||||
acc = acc - obox.d + .1; if (bbox.t != null) {acc += bbox.t - bbox.h}
|
acc = acc - obox.d + .1; if (bbox.t != null) {acc += bbox.t - bbox.h}
|
||||||
over.firstChild.firstChild.style.marginBottom = CHTML.Em(acc);
|
over.firstChild.firstChild.style.marginBottom = CHTML.Em(acc);
|
||||||
}
|
}
|
||||||
if (span.firstChild) {span.insertBefore(over,span.firstChild)}
|
if (node.firstChild) {node.insertBefore(over,node.firstChild)}
|
||||||
else {span.appendChild(over)}
|
else {node.appendChild(over)}
|
||||||
}
|
}
|
||||||
if (this.data[this.under]) {
|
if (this.data[this.under]) {
|
||||||
span.lastChild.firstChild.style.marginLeft = ubox.l =
|
node.lastChild.firstChild.style.marginLeft = ubox.l =
|
||||||
span.lastChild.firstChild.marginRight = ubox.r = 0;
|
node.lastChild.firstChild.marginRight = ubox.r = 0;
|
||||||
this.data[this.under].CHTMLhandleScriptlevel(span.lastChild);
|
this.data[this.under].CHTMLhandleScriptlevel(node.lastChild);
|
||||||
}
|
}
|
||||||
BBOX.w = Math.max(SCRIPTFACTOR*obox.w,SCRIPTFACTOR*ubox.w,bbox.w);
|
BBOX.w = Math.max(SCRIPTFACTOR*obox.w,SCRIPTFACTOR*ubox.w,bbox.w);
|
||||||
BBOX.h = SCRIPTFACTOR*(obox.h+obox.d+(acc||0)) + bbox.h;
|
BBOX.h = SCRIPTFACTOR*(obox.h+obox.d+(acc||0)) + bbox.h;
|
||||||
BBOX.d = bbox.d + SCRIPTFACTOR*(ubox.h+ubox.d);
|
BBOX.d = bbox.d + SCRIPTFACTOR*(ubox.h+ubox.d);
|
||||||
return span;
|
return node;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
MML.msubsup.Augment({
|
MML.msubsup.Augment({
|
||||||
toCommonHTML: function (span) {
|
toCommonHTML: function (node) {
|
||||||
span = this.CHTMLdefaultSpan(span,{noBBox:true});
|
node = this.CHTMLdefaultNode(node,{noBBox:true});
|
||||||
if (!this.data[this.base]) {
|
if (!this.data[this.base]) {
|
||||||
if (span.firstChild) {span.insertBefore(HTML.Element("span"),span.firstChild)}
|
if (node.firstChild) {node.insertBefore(HTML.Element("span"),node.firstChild)}
|
||||||
else {span.appendChild(HTML.Element("span"))}
|
else {node.appendChild(HTML.Element("span"))}
|
||||||
}
|
}
|
||||||
var base = this.data[this.base], sub = this.data[this.sub], sup = this.data[this.sup];
|
var base = this.data[this.base], sub = this.data[this.sub], sup = this.data[this.sup];
|
||||||
if (!base) base = {bbox: {h:.8, d:.2}};
|
if (!base) base = {bbox: {h:.8, d:.2}};
|
||||||
span.firstChild.style.marginRight = ".05em";
|
node.firstChild.style.marginRight = ".05em";
|
||||||
var h = Math.max(.4,base.CHTML.h-.4),
|
var h = Math.max(.4,base.CHTML.h-.4),
|
||||||
d = Math.max(.2,base.CHTML.d+.1);
|
d = Math.max(.2,base.CHTML.d+.1);
|
||||||
var bbox = this.CHTML;
|
var bbox = this.CHTML;
|
||||||
|
@ -995,85 +1011,86 @@
|
||||||
]);
|
]);
|
||||||
sub.CHTMLhandleScriptlevel(box.firstChild);
|
sub.CHTMLhandleScriptlevel(box.firstChild);
|
||||||
sup.CHTMLhandleScriptlevel(box.lastChild);
|
sup.CHTMLhandleScriptlevel(box.lastChild);
|
||||||
box.firstChild.firstChild.firstChild.appendChild(span.lastChild);
|
box.firstChild.firstChild.firstChild.appendChild(node.lastChild);
|
||||||
box.lastChild.firstChild.firstChild.appendChild(span.lastChild);
|
box.lastChild.firstChild.firstChild.appendChild(node.lastChild);
|
||||||
span.appendChild(box);
|
node.appendChild(box);
|
||||||
bbox.h = Math.max(base.CHTML.h,sup.CHTML.h*SCRIPTFACTOR+h);
|
bbox.h = Math.max(base.CHTML.h,sup.CHTML.h*SCRIPTFACTOR+h);
|
||||||
bbox.d = Math.max(base.CHTML.d,sub.CHTML.d*SCRIPTFACTOR+d);
|
bbox.d = Math.max(base.CHTML.d,sub.CHTML.d*SCRIPTFACTOR+d);
|
||||||
bbox.w = base.CHTML.w + Math.max(sup.CHTML.w,sub.CHTML.w) + .07;
|
bbox.w = base.CHTML.w + Math.max(sup.CHTML.w,sub.CHTML.w) + .07;
|
||||||
} else if (sup) {
|
} else if (sup) {
|
||||||
span.lastChild.style.verticalAlign = CHTML.Em(h);
|
node.lastChild.style.verticalAlign = CHTML.Em(h);
|
||||||
sup.CHTMLhandleScriptlevel(span.lastChild);
|
sup.CHTMLhandleScriptlevel(node.lastChild);
|
||||||
bbox.h = Math.max(base.CHTML.h,sup.CHTML.h*SCRIPTFACTOR+h);
|
bbox.h = Math.max(base.CHTML.h,sup.CHTML.h*SCRIPTFACTOR+h);
|
||||||
bbox.d = Math.max(base.CHTML.d,sup.CHTML.d*SCRIPTFACTOR-h);
|
bbox.d = Math.max(base.CHTML.d,sup.CHTML.d*SCRIPTFACTOR-h);
|
||||||
bbox.w = base.CHTML.w + sup.CHTML.w + .07;
|
bbox.w = base.CHTML.w + sup.CHTML.w + .07;
|
||||||
} else if (sub) {
|
} else if (sub) {
|
||||||
span.lastChild.style.verticalAlign = CHTML.Em(-d);
|
node.lastChild.style.verticalAlign = CHTML.Em(-d);
|
||||||
sub.CHTMLhandleScriptlevel(span.lastChild);
|
sub.CHTMLhandleScriptlevel(node.lastChild);
|
||||||
bbox.h = Math.max(base.CHTML.h,sub.CHTML.h*SCRIPTFACTOR-d);
|
bbox.h = Math.max(base.CHTML.h,sub.CHTML.h*SCRIPTFACTOR-d);
|
||||||
bbox.d = Math.max(base.CHTML.d,sub.CHTML.d*SCRIPTFACTOR+d);
|
bbox.d = Math.max(base.CHTML.d,sub.CHTML.d*SCRIPTFACTOR+d);
|
||||||
bbox.w = base.CHTML.w + sub.CHTML.w + .07;
|
bbox.w = base.CHTML.w + sub.CHTML.w + .07;
|
||||||
}
|
}
|
||||||
return span;
|
return node;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
MML.mfrac.Augment({
|
MML.mfrac.Augment({
|
||||||
toCommonHTML: function (span) {
|
toCommonHTML: function (node) {
|
||||||
span = this.CHTMLdefaultSpan(span,{
|
node = this.CHTMLdefaultNode(node,{
|
||||||
childSpans:true, className:"MJXc-mfrac-cell", forceChild:true, noBBox:true
|
childNodes:"mjx-cell", forceChild:true, noBBox:true
|
||||||
});
|
});
|
||||||
var values = this.getValues("linethickness","displaystyle","scriptlevel");
|
var values = this.getValues("linethickness","displaystyle","scriptlevel");
|
||||||
var sscale = 1, scale = (values.scriptlevel > 0 ? SCRIPTFACTOR : 1);
|
var sscale = 1, scale = (values.scriptlevel > 0 ? SCRIPTFACTOR : 1);
|
||||||
if (!values.displaystyle && values.scriptlevel < 2) {
|
if (!values.displaystyle && values.scriptlevel < 2) {
|
||||||
sscale = SCRIPTFACTOR;
|
sscale = SCRIPTFACTOR;
|
||||||
if (this.data[0]) this.data[0].CHTMLhandleScriptlevel(span.firstChild);
|
if (this.data[0]) this.data[0].CHTMLhandleScriptlevel(node.firstChild);
|
||||||
if (this.data[1]) this.data[1].CHTMLhandleScriptlevel(span.lastChild);
|
if (this.data[1]) this.data[1].CHTMLhandleScriptlevel(node.lastChild);
|
||||||
}
|
}
|
||||||
var num = HTML.Element("span",{className:"MJXc-num"},[
|
var frac = HTML.addElement(node,"mjx-itable",{},[
|
||||||
["span",{}, // inline-block
|
["mjx-row",{},[
|
||||||
[["span",{},[ // table, 100%
|
["mjx-fbox",{},[
|
||||||
["span",{className:"MJXc-mfrac-row"}], // numerator row, 100%
|
["mjx-ftable",{},[
|
||||||
["span",{className:"MJXc-mfrac-row"},
|
["mjx-row",{className:"mjx-numerator"}],
|
||||||
[["span",{},[["span",{className:"MJXc-rule"}]]]]] // division line
|
["mjx-row",{className:"mjx-division"},[
|
||||||
]]]
|
["mjx-cell",{},[["mjx-line"]]]
|
||||||
]
|
]]
|
||||||
|
]]
|
||||||
|
]]
|
||||||
|
]],
|
||||||
|
["mjx-row",{className:"mjx-denominator"}]
|
||||||
]);
|
]);
|
||||||
num.firstChild.firstChild.firstChild.appendChild(span.firstChild);
|
var num = frac.firstChild.firstChild.firstChild.firstChild, denom = frac.lastChild;
|
||||||
var denom = HTML.Element("span",{className:"MJXc-den"});
|
num.appendChild(node.firstChild);
|
||||||
if (scale !== 1) span.style.margin = "0 "+CHTML.Em(.125/scale);
|
denom.appendChild(node.firstChild);
|
||||||
denom.appendChild(span.firstChild);
|
|
||||||
span.appendChild(num); span.appendChild(denom);
|
|
||||||
|
|
||||||
var nbox = this.CHTMLbboxFor(0), dbox = this.CHTMLbboxFor(1), bbox = this.CHTML;
|
var nbox = this.CHTMLbboxFor(0), dbox = this.CHTMLbboxFor(1), bbox = this.CHTML;
|
||||||
if (nbox.h < .9)
|
var H = sscale*(nbox.h+nbox.d + dbox.h+dbox.d);
|
||||||
num.firstChild.firstChild.style.marginTop = CHTML.Em(sscale*(nbox.h-.9));
|
|
||||||
bbox.w = sscale*Math.max(nbox.w,dbox.w);
|
bbox.w = sscale*Math.max(nbox.w,dbox.w);
|
||||||
bbox.h = sscale*(nbox.h+nbox.d) + AXISHEIGHT;
|
bbox.h = H/2 + AXISHEIGHT;
|
||||||
bbox.d = sscale*(dbox.h+dbox.d) - AXISHEIGHT;
|
bbox.d = H/2 - AXISHEIGHT;
|
||||||
bbox.L = bbox.R = .125/scale;
|
bbox.L = bbox.R = .125/scale;
|
||||||
values.linethickness = Math.max(0,CHTML.length2em(values.linethickness||"0",0));
|
values.linethickness = Math.max(0,CHTML.length2em(values.linethickness||"0",0));
|
||||||
if (values.linethickness) {
|
if (values.linethickness) {
|
||||||
var rule = num.firstChild.firstChild.lastChild.lastChild.lastChild;
|
var rule = num.nextSibling.firstChild.firstChild;
|
||||||
var t = (values.linethickness < .15 ? "1px" : CHTML.Em(values.linethickness));
|
var t = (values.linethickness < .15 ? "1px" : CHTML.Em(values.linethickness));
|
||||||
rule.style.borderTop = t+" solid"; rule.style.margin = t+" 0";
|
rule.style.borderTop = t+" solid"; rule.style.margin = t+" 0";
|
||||||
t = values.linethickness;
|
t = values.linethickness;
|
||||||
span.style.verticalAlign = CHTML.Em(AXISHEIGHT-t);
|
node.style.verticalAlign = CHTML.Em(AXISHEIGHT-t);
|
||||||
bbox.h += 2*t; bbox.d += t;
|
bbox.h += 2*t; bbox.d += t;
|
||||||
}
|
}
|
||||||
return span;
|
return node;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
MML.msqrt.Augment({
|
MML.msqrt.Augment({
|
||||||
toCommonHTML: function (span) {
|
toCommonHTML: function (node) {
|
||||||
span = this.CHTMLdefaultSpan(span,{
|
node = this.CHTMLdefaultNode(node,{
|
||||||
childSpans:true, className:"MJXc-box", forceChild:true, noBBox:true
|
childNodes:"mjx-box", forceChild:true, noBBox:true
|
||||||
});
|
});
|
||||||
this.CHTMLlayoutRoot(span,span.firstChild);
|
this.CHTMLlayoutRoot(node,node.firstChild);
|
||||||
return span;
|
return node;
|
||||||
},
|
},
|
||||||
CHTMLlayoutRoot: function (span,base) {
|
CHTMLlayoutRoot: function (node,base) {
|
||||||
var bbox = this.CHTMLbboxFor(0);
|
var bbox = this.CHTMLbboxFor(0);
|
||||||
var scale = Math.ceil((bbox.h+bbox.d+.14)*100), t = CHTML.Em(14/scale);
|
var scale = Math.ceil((bbox.h+bbox.d+.14)*100), t = CHTML.Em(14/scale);
|
||||||
var surd = HTML.Element("span",{className:"MJXc-surd"},[
|
var surd = HTML.Element("span",{className:"MJXc-surd"},[
|
||||||
|
@ -1091,51 +1108,51 @@
|
||||||
root.firstChild.style.borderTopWidth = CHTML.Em(.08/Math.sqrt(sX/10));
|
root.firstChild.style.borderTopWidth = CHTML.Em(.08/Math.sqrt(sX/10));
|
||||||
}
|
}
|
||||||
root.appendChild(base);
|
root.appendChild(base);
|
||||||
span.appendChild(surd);
|
node.appendChild(surd);
|
||||||
span.appendChild(root);
|
node.appendChild(root);
|
||||||
this.CHTML.h = bbox.h + .18; this.CHTML.d = bbox.d;
|
this.CHTML.h = bbox.h + .18; this.CHTML.d = bbox.d;
|
||||||
this.CHTML.w = bbox.w + W;
|
this.CHTML.w = bbox.w + W;
|
||||||
return span;
|
return node;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
MML.mroot.Augment({
|
MML.mroot.Augment({
|
||||||
toCommonHTML: function (span) {
|
toCommonHTML: function (node) {
|
||||||
span = this.CHTMLdefaultSpan(span,{
|
node = this.CHTMLdefaultNode(node,{
|
||||||
childSpans:true, className:"MJXc-box", forceChild:true, noBBox:true
|
childNodes:"mjx-box", forceChild:true, noBBox:true
|
||||||
});
|
});
|
||||||
var rbox = this.CHTMLbboxFor(1), root = span.removeChild(span.lastChild);
|
var rbox = this.CHTMLbboxFor(1), root = node.removeChild(node.lastChild);
|
||||||
var sqrt = this.CHTMLlayoutRoot(HTML.Element("span"),span.firstChild);
|
var sqrt = this.CHTMLlayoutRoot(HTML.Element("span"),node.firstChild);
|
||||||
root.className = "MJXc-script"; // ### FIXME: should be scriptscript
|
root.className = "MJXc-script"; // ### FIXME: should be scriptscript
|
||||||
var scale = parseInt(sqrt.firstChild.firstChild.style.fontSize);
|
var scale = parseInt(sqrt.firstChild.firstChild.style.fontSize);
|
||||||
var v = .55*(scale/120) + rbox.d*SCRIPTFACTOR, r = -.6*(scale/120);
|
var v = .55*(scale/120) + rbox.d*SCRIPTFACTOR, r = -.6*(scale/120);
|
||||||
if (scale > 150) {r *= .95*Math.ceil(150/scale*10)/10}
|
if (scale > 150) {r *= .95*Math.ceil(150/scale*10)/10}
|
||||||
root.style.marginRight = CHTML.Em(r); root.style.verticalAlign = CHTML.Em(v);
|
root.style.marginRight = CHTML.Em(r); root.style.verticalAlign = CHTML.Em(v);
|
||||||
if (-r > rbox.w*SCRIPTFACTOR) root.style.marginLeft = CHTML.Em(-r-rbox.w*SCRIPTFACTOR); // ### depends on rbox.w
|
if (-r > rbox.w*SCRIPTFACTOR) root.style.marginLeft = CHTML.Em(-r-rbox.w*SCRIPTFACTOR); // ### depends on rbox.w
|
||||||
span.appendChild(root); span.appendChild(sqrt);
|
node.appendChild(root); node.appendChild(sqrt);
|
||||||
this.CHTML.w += Math.max(0,rbox.w*SCRIPTFACTOR+r);
|
this.CHTML.w += Math.max(0,rbox.w*SCRIPTFACTOR+r);
|
||||||
this.CHTML.h = Math.max(this.CHTML.h,rbox.h*SCRIPTFACTOR+v);
|
this.CHTML.h = Math.max(this.CHTML.h,rbox.h*SCRIPTFACTOR+v);
|
||||||
return span;
|
return node;
|
||||||
},
|
},
|
||||||
CHTMLlayoutRoot: MML.msqrt.prototype.CHTMLlayoutRoot
|
CHTMLlayoutRoot: MML.msqrt.prototype.CHTMLlayoutRoot
|
||||||
});
|
});
|
||||||
|
|
||||||
MML.mfenced.Augment({
|
MML.mfenced.Augment({
|
||||||
toCommonHTML: function (span) {
|
toCommonHTML: function (node) {
|
||||||
span = this.CHTMLcreateSpan(span);
|
node = this.CHTMLcreateNode(node);
|
||||||
this.CHTMLhandleSpace(span);
|
this.CHTMLhandleSpace(node);
|
||||||
this.CHTMLhandleStyle(span);
|
this.CHTMLhandleStyle(node);
|
||||||
this.CHTMLhandleColor(span);
|
this.CHTMLhandleColor(node);
|
||||||
//
|
//
|
||||||
// Make row of open, data, sep, ... data, close
|
// Make row of open, data, sep, ... data, close
|
||||||
//
|
//
|
||||||
this.addFakeNodes();
|
this.addFakeNodes();
|
||||||
this.CHTMLaddChild(span,"open",{});
|
this.CHTMLaddChild(node,"open",{});
|
||||||
for (var i = 0, m = this.data.length; i < m; i++) {
|
for (var i = 0, m = this.data.length; i < m; i++) {
|
||||||
this.CHTMLaddChild(span,"sep"+i,{});
|
this.CHTMLaddChild(node,"sep"+i,{});
|
||||||
this.CHTMLaddChild(span,i,{});
|
this.CHTMLaddChild(node,i,{});
|
||||||
}
|
}
|
||||||
this.CHTMLaddChild(span,"close",{});
|
this.CHTMLaddChild(node,"close",{});
|
||||||
//
|
//
|
||||||
// Check for streching the elements
|
// Check for streching the elements
|
||||||
//
|
//
|
||||||
|
@ -1146,45 +1163,45 @@
|
||||||
this.CHTMLstretchChild(i,H,D);
|
this.CHTMLstretchChild(i,H,D);
|
||||||
}
|
}
|
||||||
this.CHTMLstretchChild("close",H,D);
|
this.CHTMLstretchChild("close",H,D);
|
||||||
return span;
|
return node;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
MML.mrow.Augment({
|
MML.mrow.Augment({
|
||||||
toCommonHTML: function (span) {
|
toCommonHTML: function (node) {
|
||||||
span = this.CHTMLdefaultSpan(span);
|
node = this.CHTMLdefaultNode(node);
|
||||||
var H = this.CHTML.h, D = this.CHTML.d;
|
var H = this.CHTML.h, D = this.CHTML.d;
|
||||||
for (var i = 0, m = this.data.length; i < m; i++) this.CHTMLstretchChild(i,H,D);
|
for (var i = 0, m = this.data.length; i < m; i++) this.CHTMLstretchChild(i,H,D);
|
||||||
return span;
|
return node;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
MML.mstyle.Augment({
|
MML.mstyle.Augment({
|
||||||
toCommonHTML: function (span) {
|
toCommonHTML: function (node) {
|
||||||
span = this.CHTMLdefaultSpan(span);
|
node = this.CHTMLdefaultNode(node);
|
||||||
if (this.scriptlevel) {
|
if (this.scriptlevel) {
|
||||||
var dlevel = this.Get("scriptlevel",null,true);
|
var dlevel = this.Get("scriptlevel",null,true);
|
||||||
if (this.scriptlevel !== dlevel) {
|
if (this.scriptlevel !== dlevel) {
|
||||||
this.CHTMLhandleScriptlevel(span,dlevel);
|
this.CHTMLhandleScriptlevel(node,dlevel);
|
||||||
CHTML.scaleBBox(this.CHTML,this.scriptlevel,dlevel);
|
CHTML.scaleBBox(this.CHTML,this.scriptlevel,dlevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return span;
|
return node;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
MML.TeXAtom.Augment({
|
MML.TeXAtom.Augment({
|
||||||
toCommonHTML: function (span) {
|
toCommonHTML: function (node) {
|
||||||
span = this.CHTMLdefaultSpan(span);
|
node = this.CHTMLdefaultNode(node);
|
||||||
// ### FIXME: handle TeX class?
|
// ### FIXME: handle TeX class?
|
||||||
span.className = "MJXc-mrow";
|
node.className = "MJXc-mrow";
|
||||||
return span;
|
return node;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
MML.mtable.Augment({
|
MML.mtable.Augment({
|
||||||
toCommonHTML: function (span) {
|
toCommonHTML: function (node) {
|
||||||
span = this.CHTMLdefaultSpan(span,{noBBox:true});
|
node = this.CHTMLdefaultNode(node,{noBBox:true});
|
||||||
var values = this.getValues("columnalign","rowalign","columnspacing","rowspacing",
|
var values = this.getValues("columnalign","rowalign","columnspacing","rowspacing",
|
||||||
"columnwidth","equalcolumns","equalrows",
|
"columnwidth","equalcolumns","equalrows",
|
||||||
"columnlines","rowlines","frame","framespacing",
|
"columnlines","rowlines","frame","framespacing",
|
||||||
|
@ -1201,25 +1218,25 @@
|
||||||
for (i = 0, m = CSPACE.length; i < m; i++) {CSPACE[i] = CHTML.length2em(CSPACE[i])}
|
for (i = 0, m = CSPACE.length; i < m; i++) {CSPACE[i] = CHTML.length2em(CSPACE[i])}
|
||||||
for (i = 0, m = RSPACE.length; i < m; i++) {RSPACE[i] = CHTML.length2em(RSPACE[i])}
|
for (i = 0, m = RSPACE.length; i < m; i++) {RSPACE[i] = CHTML.length2em(RSPACE[i])}
|
||||||
|
|
||||||
var table = HTML.Element("span");
|
var table = HTML.Element("node");
|
||||||
while (span.firstChild) table.appendChild(span.firstChild);
|
while (node.firstChild) table.appendChild(node.firstChild);
|
||||||
span.appendChild(table);
|
node.appendChild(table);
|
||||||
var H = 0, W = 0;
|
var H = 0, W = 0;
|
||||||
for (i = 0, m = this.data.length; i < m; i++) {
|
for (i = 0, m = this.data.length; i < m; i++) {
|
||||||
var row = this.data[i];
|
var row = this.data[i];
|
||||||
if (row) {
|
if (row) {
|
||||||
var rspace = CHTML.arrayEntry(RSPACE,i-1), ralign = CHTML.arrayEntry(RALIGN,i);
|
var rspace = CHTML.arrayEntry(RSPACE,i-1), ralign = CHTML.arrayEntry(RALIGN,i);
|
||||||
var rbox = row.CHTML, rspan = row.CHTMLspanElement();
|
var rbox = row.CHTML, rnode = row.CHTMLnodeElement();
|
||||||
rspan.style.verticalAlign = ralign;
|
rnode.style.verticalAlign = ralign;
|
||||||
var k = (row.type === "mlabeledtr" ? 1 : 0);
|
var k = (row.type === "mlabeledtr" ? 1 : 0);
|
||||||
for (j = 0, n = row.data.length; j < n-k; j++) {
|
for (j = 0, n = row.data.length; j < n-k; j++) {
|
||||||
var cell = row.data[j+k];
|
var cell = row.data[j+k];
|
||||||
if (cell) {
|
if (cell) {
|
||||||
var cspace = CHTML.arrayEntry(CSPACE,j-1), calign = CHTML.arrayEntry(CALIGN,j);
|
var cspace = CHTML.arrayEntry(CSPACE,j-1), calign = CHTML.arrayEntry(CALIGN,j);
|
||||||
var /*cbox = cell.CHTML,*/ cspan = cell.CHTMLspanElement();
|
var /*cbox = cell.CHTML,*/ cnode = cell.CHTMLnodeElement();
|
||||||
if (j) {rbox.w += cspace; cspan.style.paddingLeft = CHTML.Em(cspace)}
|
if (j) {rbox.w += cspace; cnode.style.paddingLeft = CHTML.Em(cspace)}
|
||||||
if (i) cspan.style.paddingTop = CHTML.Em(rspace);
|
if (i) cnode.style.paddingTop = CHTML.Em(rspace);
|
||||||
cspan.style.textAlign = calign;
|
cnode.style.textAlign = calign;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
H += rbox.h + rbox.d; if (i) {H += rspace}
|
H += rbox.h + rbox.d; if (i) {H += rspace}
|
||||||
|
@ -1229,33 +1246,33 @@
|
||||||
var bbox = this.CHTML;
|
var bbox = this.CHTML;
|
||||||
bbox.w = W; bbox.h = H/2 + AXISHEIGHT; bbox.d = H/2 - AXISHEIGHT;
|
bbox.w = W; bbox.h = H/2 + AXISHEIGHT; bbox.d = H/2 - AXISHEIGHT;
|
||||||
bbox.L = bbox.R = .125;
|
bbox.L = bbox.R = .125;
|
||||||
return span;
|
return node;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
MML.mlabeledtr.Augment({
|
MML.mlabeledtr.Augment({
|
||||||
CHTMLdefaultSpan: function (span,options) {
|
CHTMLdefaultNode: function (node,options) {
|
||||||
if (!options) options = {};
|
if (!options) options = {};
|
||||||
span = this.CHTMLcreateSpan(span);
|
node = this.CHTMLcreateNode(node);
|
||||||
this.CHTMLhandleStyle(span);
|
this.CHTMLhandleStyle(node);
|
||||||
this.CHTMLhandleColor(span);
|
this.CHTMLhandleColor(node);
|
||||||
// skip label for now
|
// skip label for now
|
||||||
for (var i = 1, m = this.data.length; i < m; i++) this.CHTMLaddChild(span,i,options);
|
for (var i = 1, m = this.data.length; i < m; i++) this.CHTMLaddChild(node,i,options);
|
||||||
return span;
|
return node;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
MML.semantics.Augment({
|
MML.semantics.Augment({
|
||||||
toCommonHTML: function (span) {
|
toCommonHTML: function (node) {
|
||||||
span = this.CHTMLcreateSpan(span);
|
node = this.CHTMLcreateNode(node);
|
||||||
if (this.data[0]) {
|
if (this.data[0]) {
|
||||||
this.data[0].toCommonHTML(span);
|
this.data[0].toCommonHTML(node);
|
||||||
MathJax.Hub.Insert(this.data[0].CHTML||{},this.CHTML);
|
MathJax.Hub.Insert(this.data[0].CHTML||{},this.CHTML);
|
||||||
}
|
}
|
||||||
return span;
|
return node;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
MML.annotation.Augment({toCommonHTML: function(span) {}});
|
MML.annotation.Augment({toCommonHTML: function(node) {}});
|
||||||
MML["annotation-xml"].Augment({toCommonHTML: function(span) {}});
|
MML["annotation-xml"].Augment({toCommonHTML: function(node) {}});
|
||||||
|
|
||||||
//
|
//
|
||||||
// Loading isn't complete until the element jax is modified,
|
// Loading isn't complete until the element jax is modified,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user