Rename variable used for displayIndent so it doesn't conflict with previous usage. Also, handle '0em' and similar values as '0'. Resolves issue #1000.

This commit is contained in:
Davide P. Cervone 2015-01-11 09:20:30 -05:00
parent ae48c34e64
commit 2431a90a9f
6 changed files with 15 additions and 11 deletions

View File

@ -174,7 +174,7 @@ MathJax.Hub.Config({
// or left (negative is left).
//
displayAlign: "center",
displayIndent: "0em",
displayIndent: "0",
//
// Normally MathJax will perform its starup commands (loading of

View File

@ -582,13 +582,13 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
};
if (mml.displayAlign === MML.INDENTALIGN.LEFT) {
def.width = "100%";
if (mml.displayIndent && !String(mml.displayIndent).match(/^0+(\.0*)?($|[a-z%])/)) {
if (mml.displayIndent !== "0") {
def.columnwidth = mml.displayIndent + " fit"; def.columnspacing = "0"
row = [row[0],MML.mtd(),row[1]];
}
} else if (mml.displayAlign === MML.INDENTALIGN.RIGHT) {
def.width = "100%";
if (mml.displayIndent && !String(mml.displayIndent).match(/^0+(\.0*)?($|[a-z%])/)) {
if (mml.displayIndent !== "0") {
def.columnwidth = "fit "+mml.displayIndent; def.columnspacing = "0"
row[2] = MML.mtd();
}

View File

@ -430,8 +430,8 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
var shift = HTMLCSS.length2em(indent.indentshift,mu,HTMLCSS.cwidth);
var labelshift = HTMLCSS.length2em(values.minlabelspacing,mu,HTMLCSS.cwidth);
if (this.displayIndent !== "0") {
var indent = HTMLCSS.length2em(this.displayIndent,mu,HTMLCSS.cwidth);
shift += (indent.indentAlign === MML.INDENTALIGN.RIGHT ? -indent: indent);
var dIndent = HTMLCSS.length2em(this.displayIndent,mu,HTMLCSS.cwidth);
shift += (indent.indentAlign === MML.INDENTALIGN.RIGHT ? -dIndent: dIndent);
}
var eqn = HTMLCSS.createStack(span,false,"100%");
HTMLCSS.addBox(eqn,stack); HTMLCSS.alignBox(stack,indent.indentalign,0,shift);

View File

@ -2838,6 +2838,8 @@
}
MML.mbase.prototype.displayAlign = HUB.config.displayAlign;
MML.mbase.prototype.displayIndent = HUB.config.displayIndent;
if (String(HUB.config.displayIndent).match(/^0($|[a-z%])/i))
MML.mbase.prototype.displayIndent = "0";
var html = this.data[0].toHTML(box); html.bbox.exactW = false; // force remeasure just to be sure
math = HTMLCSS.Measured(html,box);
}
@ -2881,10 +2883,10 @@
if (values.indentshiftfirst !== MML.INDENTSHIFT.INDENTSHIFT) {values.indentshift = values.indentshiftfirst}
if (values.indentshift === "auto") {values.indentshift = "0"}
var shift = HTMLCSS.length2em(values.indentshift,1,HTMLCSS.cwidth);
if (this.displayIndent !== "0") {
var indent = HTMLCSS.length2em(this.displayIndent,1,HTMLCSS.cwidth);
shift += (values.indentalign === MML.INDENTALIGN.RIGHT ? -indent : indent);
}
if (this.displayIndent !== "0") {
var indent = HTMLCSS.length2em(this.displayIndent,1,HTMLCSS.cwidth);
shift += (values.indentalign === MML.INDENTALIGN.RIGHT ? -indent : indent);
}
node.style.textAlign = values.indentalign;
// ### FIXME: make percentage widths respond to changes in container
if (shift) {

View File

@ -333,8 +333,8 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
var shift = SVG.length2em(indent.indentshift,mu,SVG.cwidth);
var labelshift = SVG.length2em(values.minlabelspacing,mu,SVG.cwidth);
if (this.displayIndent !== "0") {
var indent = SVG.length2em(this.displayIndent,mu,SVG.cwidth);
shift += (indent.indentAlign === MML.INDENTALIGN.RIGHT ? -indent: indent);
var dIndent = SVG.length2em(this.displayIndent,mu,SVG.cwidth);
shift += (indent.indentAlign === MML.INDENTALIGN.RIGHT ? -dIndent: dIndent);
}
var eqn = svg; svg = this.SVG();
svg.w = svg.r = SVG.cwidth; svg.hasIndent = true;

View File

@ -2027,6 +2027,8 @@
this.SVGgetStyles();
MML.mbase.prototype.displayAlign = HUB.config.displayAlign;
MML.mbase.prototype.displayIndent = HUB.config.displayIndent;
if (String(HUB.config.displayIndent).match(/^0($|[a-z%])/i))
MML.mbase.prototype.displayIndent = "0";
//
// Put content in a <g> with defaults and matrix that flips y axis.
// Put that in an <svg> with xlink defined.