diff --git a/unpacked/jax/output/HTML-CSS/jax.js b/unpacked/jax/output/HTML-CSS/jax.js index 144320234..f7269b2a8 100644 --- a/unpacked/jax/output/HTML-CSS/jax.js +++ b/unpacked/jax/output/HTML-CSS/jax.js @@ -606,6 +606,7 @@ } else if (this.msieDisappearingBug) {span.style.display = "inline-block"} div.className += " MathJax_Processing"; script.parentNode.insertBefore(div,script); + jax.HTMLCSS.span = span; jax.HTMLCSS.div = div; // save for use in Translate() // // Add the test span for determining scales and linebreak widths // @@ -626,14 +627,13 @@ ex = test.firstChild.offsetHeight/60; em = test.lastChild.firstChild.offsetHeight/60; cwidth = Math.max(0,div.previousSibling.firstChild.offsetWidth - 2); - if (relwidth) {maxwidth = cwidth} if (ex === 0 || ex === "NaN") { // can't read width, so move to hidden div for processing hidden.push(div); jax.HTMLCSS.isHidden = true; ex = this.defaultEx; em = this.defaultEm; cwidth = this.defaultWidth; - if (relwidth) {maxwidth = cwidth} } + if (relwidth) {maxwidth = cwidth} scale = (this.config.matchFontHeight ? ex/this.TeX.x_height/em : 1); scale = Math.floor(Math.max(this.config.minScaleAdjust/100,scale)*this.config.scale); jax.HTMLCSS.scale = scale/100; jax.HTMLCSS.fontSize = scale+"%"; @@ -683,8 +683,7 @@ // Get the data about the math // var jax = script.MathJax.elementJax, math = jax.root, - div = script.previousSibling; - span = (jax.HTMLCSS.display ? (div||{}).firstChild||div : div); + div = jax.HTMLCSS.div, span = jax.HTMLCSS.div; if (!div) return; // // Set the font metrics @@ -699,7 +698,6 @@ this.savePreview(script); try { math.setTeXclass(); - jax.HTMLCSS.span = span; jax.HTMLCSS.div = div; // save for phase II and III math.toHTML(span,div,this.PHASE.I); } catch (err) { if (err.restart) {while (span.firstChild) {span.removeChild(span.firstChild)}} diff --git a/unpacked/jax/output/SVG/jax.js b/unpacked/jax/output/SVG/jax.js index 65101a412..08cbe0a8c 100644 --- a/unpacked/jax/output/SVG/jax.js +++ b/unpacked/jax/output/SVG/jax.js @@ -261,6 +261,7 @@ // Determine the scaling factors for each script // (this only requires one reflow rather than a reflow for each equation) // + var hidden = []; for (i = 0; i < m; i++) { script = scripts[i]; if (!script.parentNode) continue; test = script.previousSibling; div = test.previousSibling; @@ -269,8 +270,7 @@ cwidth = Math.max(0,(div.previousSibling.firstChild.offsetWidth-2) / this.config.scale * 100); if (ex === 0 || ex === "NaN") { // can't read width, so move to hidden div for processing - // (this will cause a reflow for each math element that is hidden) - this.hiddenDiv.appendChild(div); + hidden.push(div); jax.SVG.isHidden = true; ex = this.defaultEx; cwidth = this.defaultWidth; } @@ -280,6 +280,10 @@ jax.SVG.cwidth = cwidth/em * 1000; jax.SVG.lineWidth = (linebreak ? this.length2em(width,1,maxwidth/em*1000) : SVG.BIGDIMEN); } + for (i = 0, n = hidden.length; i < n; i++) { + this.hiddenDiv.appendChild(hidden[i]); + this.addElement(this.hiddenDiv,"br"); + } // // Remove the test spans used for determining scales and linebreak widths // @@ -314,10 +318,15 @@ // // Get the data about the math // - var jax = script.MathJax.elementJax, math = jax.root, - div = script.previousSibling; - span = (jax.SVG.display ? (div||{}).firstChild||div : div), + var jax = script.MathJax.elementJax, math = jax.root, div, span, localCache = (SVG.config.useFontCache && !SVG.config.useGlobalCache); + if (jax.SVG.isHidden) { + span = document.getElementById(jax.inputID+"-Frame"); + div = (jax.SVG.display ? span.parentElement : span); + } else { + div = script.previousSibling; + span = (jax.SVG.display ? (div||{}).firstChild||div : div); + } if (!div) return; // // Set the font metrics