From 68369285fdde9aa582bb308bab69572b3c7db8e5 Mon Sep 17 00:00:00 2001
From: "Davide P. Cervone" <dpvc@union.edu>
Date: Mon, 4 Jul 2016 12:50:10 -0400
Subject: [PATCH 1/3] Make fractions with linebreaks center the elements based
 on the natural width (not 100%) in HTML-CSS and CHTML, just as in SVG. 
 Resolves issue #1539.

---
 unpacked/jax/output/CommonHTML/jax.js | 4 +++-
 unpacked/jax/output/HTML-CSS/jax.js   | 8 ++++----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js
index 0b48f9ae2..ac199540a 100644
--- a/unpacked/jax/output/CommonHTML/jax.js
+++ b/unpacked/jax/output/CommonHTML/jax.js
@@ -2413,6 +2413,7 @@
       toCommonHTML: function (node) {
         node = this.CHTMLdefaultNode(node,{
           childNodes:["mjx-numerator","mjx-denominator"],
+          childOptions: {autowidth: true},
           forceChild:true, noBBox:true, minChildren:2
         });
         var values = this.getValues("linethickness","displaystyle",
@@ -2600,7 +2601,7 @@
     /********************************************************/
     
     MML.mrow.Augment({
-      toCommonHTML: function (node) {
+      toCommonHTML: function (node,options) {
         node = this.CHTMLdefaultNode(node);
         var bbox = this.CHTML, H = bbox.h, D = bbox.d, hasNegative;
         for (var i = 0, m = this.data.length; i < m; i++) {
@@ -2609,6 +2610,7 @@
         }
         if (this.CHTMLlineBreaks()) {
           this.CHTMLmultiline(node);
+          if (options.autowidth) node.style.width = "";
         } else {
           if (hasNegative && bbox.w) node.style.width = CHTML.Em(Math.max(0,bbox.w));
           if (bbox.w < 0) node.style.marginRight = CHTML.Em(bbox.w);
diff --git a/unpacked/jax/output/HTML-CSS/jax.js b/unpacked/jax/output/HTML-CSS/jax.js
index 8dad7d6aa..191e14f96 100644
--- a/unpacked/jax/output/HTML-CSS/jax.js
+++ b/unpacked/jax/output/HTML-CSS/jax.js
@@ -1291,7 +1291,7 @@
         if (bbox.tw) {BBOX.tw = bbox.tw}
       }
     },
-    alignBox: function (span,align,y,dx) {
+    alignBox: function (span,align,y,dx,noskip) {
       if (dx == null) {dx = 0}
       this.placeBox(span,dx,y); // set y position (and left aligned)
       if (this.msiePlaceBoxBug) {
@@ -1302,7 +1302,7 @@
         while (node && node.nodeName !== "#text") {node = node.previousSibling}
         if (node) {span.removeChild(node)}
       }
-      var bbox = span.bbox; if (bbox.isMultiline) return;
+      var bbox = span.bbox; if (bbox.isMultiline && !noskip) return;
       var isRelative = bbox.width != null && !bbox.isFixed;
       var r = 0, c = dx-bbox.w/2, l = "50%";
       if (this.initialSkipBug) {r = bbox.w-bbox.rw-.1; c += bbox.lw}
@@ -2581,8 +2581,8 @@
 	    HTMLCSS.createRule(rule,t,0,W+2*t);
 	    HTMLCSS.placeBox(rule,0,a-t/2);
 	  }
-	  HTMLCSS.alignBox(num,values.numalign,u);
-	  HTMLCSS.alignBox(den,values.denomalign,-v);
+	  HTMLCSS.alignBox(num,values.numalign,u,0,true);
+	  HTMLCSS.alignBox(den,values.denomalign,-v,0,true);
 	}
 	this.HTMLhandleSpace(span);
 	this.HTMLhandleColor(span);
-- 
GitLab


From ba2216639956591c763959e8a7b3686a2e0aa3fd Mon Sep 17 00:00:00 2001
From: "Davide P. Cervone" <dpvc@union.edu>
Date: Mon, 4 Jul 2016 12:56:53 -0400
Subject: [PATCH 2/3] handle case where options are not passed.

---
 unpacked/jax/output/CommonHTML/jax.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js
index ac199540a..a2a9dc153 100644
--- a/unpacked/jax/output/CommonHTML/jax.js
+++ b/unpacked/jax/output/CommonHTML/jax.js
@@ -2610,7 +2610,7 @@
         }
         if (this.CHTMLlineBreaks()) {
           this.CHTMLmultiline(node);
-          if (options.autowidth) node.style.width = "";
+          if ((options||{}).autowidth) node.style.width = "";
         } else {
           if (hasNegative && bbox.w) node.style.width = CHTML.Em(Math.max(0,bbox.w));
           if (bbox.w < 0) node.style.marginRight = CHTML.Em(bbox.w);
-- 
GitLab


From 38a9a12dcf16d6e193e57c65e258b4a144f8a1e6 Mon Sep 17 00:00:00 2001
From: "Davide P. Cervone" <dpvc@union.edu>
Date: Tue, 26 Jul 2016 14:59:41 -0400
Subject: [PATCH 3/3] Adjust how options are handled, as per Volker's comments.

---
 unpacked/jax/output/CommonHTML/jax.js | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js
index a2a9dc153..13d0f6de3 100644
--- a/unpacked/jax/output/CommonHTML/jax.js
+++ b/unpacked/jax/output/CommonHTML/jax.js
@@ -2602,6 +2602,7 @@
     
     MML.mrow.Augment({
       toCommonHTML: function (node,options) {
+        options = options || {};
         node = this.CHTMLdefaultNode(node);
         var bbox = this.CHTML, H = bbox.h, D = bbox.d, hasNegative;
         for (var i = 0, m = this.data.length; i < m; i++) {
@@ -2610,7 +2611,7 @@
         }
         if (this.CHTMLlineBreaks()) {
           this.CHTMLmultiline(node);
-          if ((options||{}).autowidth) node.style.width = "";
+          if (options.autowidth) node.style.width = "";
         } else {
           if (hasNegative && bbox.w) node.style.width = CHTML.Em(Math.max(0,bbox.w));
           if (bbox.w < 0) node.style.marginRight = CHTML.Em(bbox.w);
-- 
GitLab