From ec105af4312058abcd185446c1f9c5e1ec663530 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Wang?= Date: Tue, 25 Dec 2012 15:46:35 +0100 Subject: [PATCH 1/5] mmultiscripts/menclose: ensure that HTMLgetScale is not called before HTMLcreateSpan. Fix Math Processing errors described in issue 362. --- unpacked/jax/output/HTML-CSS/autoload/menclose.js | 5 ++++- unpacked/jax/output/HTML-CSS/autoload/mmultiscripts.js | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/unpacked/jax/output/HTML-CSS/autoload/menclose.js b/unpacked/jax/output/HTML-CSS/autoload/menclose.js index 961efb385..0a06dd5c2 100644 --- a/unpacked/jax/output/HTML-CSS/autoload/menclose.js +++ b/unpacked/jax/output/HTML-CSS/autoload/menclose.js @@ -1,3 +1,5 @@ +/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ /************************************************************* * * MathJax/jax/output/HTML-CSS/autoload/menclose.js @@ -36,12 +38,13 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () { if (values.color && !this.mathcolor) {values.mathcolor = values.color} if (values.thickness == null) {values.thickness = ".075em"} if (values.padding == null) {values.padding = ".2em"} - var mu = this.HTMLgetMu(span), scale = this.HTMLgetScale(); + var mu = this.HTMLgetMu(span); var p = HTMLCSS.length2em(values.padding,mu,1/HTMLCSS.em) * scale; var t = HTMLCSS.length2em(values.thickness,mu,1/HTMLCSS.em) * scale; var SOLID = HTMLCSS.Em(t)+" solid"; span = this.HTMLcreateSpan(span); + var scale = this.HTMLgetScale(); var stack = HTMLCSS.createStack(span); var base = HTMLCSS.createBox(stack); this.HTMLmeasureChild(0,base); diff --git a/unpacked/jax/output/HTML-CSS/autoload/mmultiscripts.js b/unpacked/jax/output/HTML-CSS/autoload/mmultiscripts.js index 3c3bd4587..a4ce5ec8c 100644 --- a/unpacked/jax/output/HTML-CSS/autoload/mmultiscripts.js +++ b/unpacked/jax/output/HTML-CSS/autoload/mmultiscripts.js @@ -1,3 +1,5 @@ +/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ /************************************************************* * * MathJax/jax/output/HTML-CSS/autoload/mmultiscripts.js @@ -43,7 +45,12 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () { var BOX = this.HTMLgetScripts(stack,s); var sub = BOX[0], sup = BOX[1], presub = BOX[2], presup = BOX[3]; - var sscale = (this.data[1]||this).HTMLgetScale(); + var sscale; + if (this.data[1] && this.data[1].type !== "mprescripts") { + sscale = this.data[1].HTMLgetScale(); + } else { + sscale = this.HTMLgetScale(); + } var q = HTMLCSS.TeX.sup_drop * sscale, r = HTMLCSS.TeX.sub_drop * sscale; var u = base.bbox.h - q, v = base.bbox.d + r, delta = 0, p; if (base.bbox.ic) {delta = base.bbox.ic} From d3be78023d758aa164404db9b047efe83f2ccdef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Wang?= Date: Wed, 26 Dec 2012 15:27:55 +0100 Subject: [PATCH 2/5] Fix Math Processing Error for msubsup/msub/msup element. --- unpacked/jax/output/HTML-CSS/jax.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/unpacked/jax/output/HTML-CSS/jax.js b/unpacked/jax/output/HTML-CSS/jax.js index 4517dc3f2..2a6036fe4 100644 --- a/unpacked/jax/output/HTML-CSS/jax.js +++ b/unpacked/jax/output/HTML-CSS/jax.js @@ -2531,7 +2531,14 @@ if (sup) {sup.bbox.w += s; sup.bbox.rw = Math.max(sup.bbox.w,sup.bbox.rw)} if (sub) {sub.bbox.w += s; sub.bbox.rw = Math.max(sub.bbox.w,sub.bbox.rw)} HTMLCSS.placeBox(base,0,0); - var sscale = (this.data[this.sup] || this.data[this.sub] || this).HTMLgetScale(); + var sscale; + if (sup) { + sscale = this.data[this.sup].HTMLgetScale(); + } else if (sub) { + sscale = this.data[this.sub].HTMLgetScale(); + } else { + sscale = this.HTMLgetScale(); + } var q = HTMLCSS.TeX.sup_drop * sscale, r = HTMLCSS.TeX.sub_drop * sscale; var u = base.bbox.h - q, v = base.bbox.d + r, delta = 0, p; if (base.bbox.ic) { From a84763522d22bb41ed377bc3321a70361bacd875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Wang?= Date: Wed, 26 Dec 2012 19:41:10 +0100 Subject: [PATCH 3/5] mmultiscripts: take into account the case (probably need a better selection of sscale) --- unpacked/jax/output/HTML-CSS/autoload/mmultiscripts.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/unpacked/jax/output/HTML-CSS/autoload/mmultiscripts.js b/unpacked/jax/output/HTML-CSS/autoload/mmultiscripts.js index a4ce5ec8c..6078a1957 100644 --- a/unpacked/jax/output/HTML-CSS/autoload/mmultiscripts.js +++ b/unpacked/jax/output/HTML-CSS/autoload/mmultiscripts.js @@ -46,7 +46,8 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () { var sub = BOX[0], sup = BOX[1], presub = BOX[2], presup = BOX[3]; var sscale; - if (this.data[1] && this.data[1].type !== "mprescripts") { + if (this.data[1] && this.data[1].type != "mprescripts" && + this.data[1].type != "none") { sscale = this.data[1].HTMLgetScale(); } else { sscale = this.HTMLgetScale(); From 24f7626290a7d208ac3bdaf57ae57d9b064e8ded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Wang?= Date: Tue, 15 Jan 2013 17:19:02 +0100 Subject: [PATCH 4/5] change the order again in menclose.js --- unpacked/jax/output/HTML-CSS/autoload/menclose.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unpacked/jax/output/HTML-CSS/autoload/menclose.js b/unpacked/jax/output/HTML-CSS/autoload/menclose.js index 0a06dd5c2..61303bfae 100644 --- a/unpacked/jax/output/HTML-CSS/autoload/menclose.js +++ b/unpacked/jax/output/HTML-CSS/autoload/menclose.js @@ -38,13 +38,13 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () { if (values.color && !this.mathcolor) {values.mathcolor = values.color} if (values.thickness == null) {values.thickness = ".075em"} if (values.padding == null) {values.padding = ".2em"} + span = this.HTMLcreateSpan(span); var mu = this.HTMLgetMu(span); + var scale = this.HTMLgetScale(); var p = HTMLCSS.length2em(values.padding,mu,1/HTMLCSS.em) * scale; var t = HTMLCSS.length2em(values.thickness,mu,1/HTMLCSS.em) * scale; var SOLID = HTMLCSS.Em(t)+" solid"; - span = this.HTMLcreateSpan(span); - var scale = this.HTMLgetScale(); var stack = HTMLCSS.createStack(span); var base = HTMLCSS.createBox(stack); this.HTMLmeasureChild(0,base); From 9ae93062644e315e88a63c47fe38ffc270bc0569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Wang?= Date: Mon, 28 Jan 2013 08:36:00 +0100 Subject: [PATCH 5/5] Scan mmultiscripts children to find the first element with a spanID, as suggested by Davide. --- .../jax/output/HTML-CSS/autoload/menclose.js | 3 +-- .../output/HTML-CSS/autoload/mmultiscripts.js | 16 ++++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/unpacked/jax/output/HTML-CSS/autoload/menclose.js b/unpacked/jax/output/HTML-CSS/autoload/menclose.js index 61303bfae..30147538a 100644 --- a/unpacked/jax/output/HTML-CSS/autoload/menclose.js +++ b/unpacked/jax/output/HTML-CSS/autoload/menclose.js @@ -39,8 +39,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () { if (values.thickness == null) {values.thickness = ".075em"} if (values.padding == null) {values.padding = ".2em"} span = this.HTMLcreateSpan(span); - var mu = this.HTMLgetMu(span); - var scale = this.HTMLgetScale(); + var mu = this.HTMLgetMu(span), scale = this.HTMLgetScale(); var p = HTMLCSS.length2em(values.padding,mu,1/HTMLCSS.em) * scale; var t = HTMLCSS.length2em(values.thickness,mu,1/HTMLCSS.em) * scale; var SOLID = HTMLCSS.Em(t)+" solid"; diff --git a/unpacked/jax/output/HTML-CSS/autoload/mmultiscripts.js b/unpacked/jax/output/HTML-CSS/autoload/mmultiscripts.js index 6078a1957..41c39c3fd 100644 --- a/unpacked/jax/output/HTML-CSS/autoload/mmultiscripts.js +++ b/unpacked/jax/output/HTML-CSS/autoload/mmultiscripts.js @@ -45,13 +45,17 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () { var BOX = this.HTMLgetScripts(stack,s); var sub = BOX[0], sup = BOX[1], presub = BOX[2], presup = BOX[3]; - var sscale; - if (this.data[1] && this.data[1].type != "mprescripts" && - this.data[1].type != "none") { - sscale = this.data[1].HTMLgetScale(); - } else { - sscale = this.HTMLgetScale(); + // children other than the base can be , + // , etc so try to get HTMLgetScale from the + // first element with a spanID. See issue 362. + var sscale = this.HTMLgetScale(); + for (var i = 1; i < this.data.length; i++) { + if (this.data[i] && this.data[i].spanID) { + sscale = this.data[i].HTMLgetScale(); + break; + } } + var q = HTMLCSS.TeX.sup_drop * sscale, r = HTMLCSS.TeX.sub_drop * sscale; var u = base.bbox.h - q, v = base.bbox.d + r, delta = 0, p; if (base.bbox.ic) {delta = base.bbox.ic}