From 1763ac7188cc4ff70faacab8133c9821c1988543 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Sun, 22 Feb 2015 10:59:35 -0500 Subject: [PATCH] Handle propagation of bounding box sizes better. --- unpacked/jax/output/CommonHTML/jax.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js index 6b9e78516..e62afc7de 100644 --- a/unpacked/jax/output/CommonHTML/jax.js +++ b/unpacked/jax/output/CommonHTML/jax.js @@ -539,6 +539,7 @@ this.CHTMLhandleColor(span); if (this.isToken) this.CHTMLhandleToken(span); for (var i = 0, m = this.data.length; i < m; i++) this.CHTMLaddChild(span,i,options); + if (!options.noMargins && !options.noBBox) this.CHTMLhandleMargins(span); return span; }, CHTMLaddChild: function (span,i,options) { @@ -613,6 +614,20 @@ } }, + CHTMLhandleMargins: function (span,box) { + var bbox = this.CHTML; + // ### FIXME: should these be FONTDATA values? + if (bbox.h < .9 || bbox.d < .25) { + if (box == null) { + box = HTML.Element("span",{className:"MJXc-box"}); + while (span.firstChild) box.appendChild(span.firstChild); + span.appendChild(box); + } + if (bbox.h < .9) box.style.marginTop = CHTML.Em(bbox.h-.9); + if (bbox.d < .25) box.style.marginBottom = CHTML.Em(bbox.d-.25); + } + }, + CHTMLhandleText: function (span,text,variant) { var c, n; var H = 0, D = 0, W = 0;