From f54a8ebaaa4b5cd89c1153cb9944f6a7c3f571f4 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Mon, 21 Apr 2014 09:52:59 -0400 Subject: [PATCH] Fix problem where forced linebreaks could cause lines to disappear (due to recent changes to the linebreaking algorithm). --- unpacked/jax/output/HTML-CSS/autoload/multiline.js | 9 +++++---- unpacked/jax/output/SVG/autoload/multiline.js | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/unpacked/jax/output/HTML-CSS/autoload/multiline.js b/unpacked/jax/output/HTML-CSS/autoload/multiline.js index cfed822f6..2f7802542 100644 --- a/unpacked/jax/output/HTML-CSS/autoload/multiline.js +++ b/unpacked/jax/output/HTML-CSS/autoload/multiline.js @@ -92,7 +92,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () { var stack = HTMLCSS.createStack(span); var state = { n: 0, Y: 0, - scale: this.scale, + scale: this.scale || 1, isTop: isTop, values: {}, VALUES: VALUES @@ -108,7 +108,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () { broken = false; while (this.HTMLbetterBreak(end,state) && - (end.scanW >= HTMLCSS.linebreakWidth || end.penalty == PENALTY.newline)) { + (end.scanW >= HTMLCSS.linebreakWidth || end.penalty === PENALTY.newline)) { this.HTMLaddLine(stack,start,end.index,state,end.values,broken); start = end.index.slice(0); broken = true; align = this.HTMLgetAlign(state,end.values); @@ -252,7 +252,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () { else if (state.isLast) {shift = prev.indentshiftlast || def.indentshiftlast} else {shift = prev.indentshift || def.indentshift} if (shift === MML.INDENTSHIFT.INDENTSHIFT) {shift = prev.indentshift || def.indentshift} - if (shift === "auto" || shift === "") {shift = (state.isTSop ? this.displayIndent : "0")} + if (shift === MML.INDENTSHIFT.AUTO || shift === "") {shift = (state.isTSop ? this.displayIndent : "0")} return HTMLCSS.length2em(shift,0); }, @@ -655,7 +655,8 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () { var span = mo.HTMLspanElement(), w = span.bbox.w; if (span.style.paddingLeft) {w += HTMLCSS.unEm(span.style.paddingLeft)} if (values.linebreakstyle === MML.LINEBREAKSTYLE.AFTER) {W += w; w = 0} - if (W - info.shift === 0) {return false} // don't break at zero width (FIXME?) + if (W - info.shift === 0 && values.linebreak !== MML.LINEBREAK.NEWLINE) + {return false} // don't break at zero width (FIXME?) var offset = HTMLCSS.linebreakWidth - W; // Adjust offest for explicit first-line indent and align if (state.n === 0 && (values.indentshiftfirst !== state.VALUES.indentshiftfirst || diff --git a/unpacked/jax/output/SVG/autoload/multiline.js b/unpacked/jax/output/SVG/autoload/multiline.js index 5511ccaa0..f3b5c90b1 100644 --- a/unpacked/jax/output/SVG/autoload/multiline.js +++ b/unpacked/jax/output/SVG/autoload/multiline.js @@ -96,7 +96,7 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () { var state = { n: 0, Y: 0, - scale: this.scale, + scale: this.scale || 1, isTop: isTop, values: {}, VALUES: VALUES @@ -115,7 +115,7 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () { // Break the expression at its best line breaks // while (this.SVGbetterBreak(end,state) && - (end.scanW >= SVG.linebreakWidth || end.penalty == PENALTY.newline)) { + (end.scanW >= SVG.linebreakWidth || end.penalty === PENALTY.newline)) { this.SVGaddLine(svg,start,end.index,state,end.values,broken); start = end.index.slice(0); broken = true; align = this.SVGgetAlign(state,end.values); @@ -255,7 +255,7 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () { else if (state.isLast) {shift = prev.indentshiftlast || def.indentshiftlast} else {shift = prev.indentshift || def.indentshift} if (shift === MML.INDENTSHIFT.INDENTSHIFT) {shift = prev.indentshift || def.indentshift} - if (shift === "auto" || shift === "") {shift = (state.isTSop ? this.displayIndent : "0")} + if (shift === MML.INDENTSHIFT.AUTO || shift === "") {shift = (state.isTSop ? this.displayIndent : "0")} return SVG.length2em(shift,0); }, @@ -584,7 +584,8 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () { if (!mo || !mo.SVGdata) {mo = this} var svg = mo.SVGdata, w = svg.w + svg.x; if (values.linebreakstyle === MML.LINEBREAKSTYLE.AFTER) {W += w; w = 0} - if (W - info.shift === 0) {return false} // don't break at zero width (FIXME?) + if (W - info.shift === 0 && values.linebreak !== MML.LINEBREAK.NEWLINE) + {return false} // don't break at zero width (FIXME?) var offset = SVG.linebreakWidth - W; // adjust offest for explicit first-line indent and align if (state.n === 0 && (values.indentshiftfirst !== state.VALUES.indentshiftfirst ||