Skip to content

Commit 4f87ff1

Browse files
authored
Merge pull request #1530 from dpvc/issue1478
Fix problem with Safari inserting line breaks before in-line math. #1478
2 parents 4120eb1 + 94f2f20 commit 4f87ff1

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

unpacked/jax/output/CommonHTML/jax.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@
180180
position: "absolute",
181181
width:"1px", height:"60ex"
182182
},
183-
".mjx-line-box-test": {
183+
".mjx-line-box-test": {display: "table!important"},
184+
".mjx-line-box-test span": {
184185
display: "table-cell!important",
185186
width: "10000em!important",
186187
"min-width":0, "max-width":"none",
@@ -251,7 +252,7 @@
251252
//
252253
// Used in preTranslate to get linebreak width
253254
//
254-
this.linebreakSpan = HTML.Element("span",{className:"mjx-line-box-test"});
255+
this.linebreakSpan = HTML.Element("span",{className:"mjx-line-box-test"},[["span"]]);
255256

256257
//
257258
// Set up styles and preload web fonts
@@ -284,7 +285,7 @@
284285
document.body.appendChild(this.linebreakSpan);
285286
this.defaultEm = this.getFontSize(this.TestSpan);
286287
this.defaultEx = this.TestSpan.firstChild.offsetHeight/60;
287-
this.defaultWidth = this.linebreakSpan.offsetWidth;
288+
this.defaultWidth = this.linebreakSpan.firstChild.offsetWidth;
288289
document.body.removeChild(this.linebreakSpan);
289290
document.body.removeChild(this.TestSpan);
290291
},
@@ -453,7 +454,7 @@
453454
jax = script.MathJax.elementJax; if (!jax) continue;
454455
em = CHTML.getFontSize(test);
455456
ex = test.firstChild.offsetHeight/60;
456-
cwidth = Math.max(0,test.previousSibling.offsetWidth-2);
457+
cwidth = Math.max(0,test.previousSibling.firstChild.offsetWidth-2);
457458
if (ex === 0 || ex === "NaN") {
458459
ex = this.defaultEx;
459460
cwidth = this.defaultWidth;

unpacked/jax/output/HTML-CSS/jax.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,9 @@
339339
"min-height": 0, "max-height":"none"
340340
},
341341
".MathJax_LineBox": {
342+
display: (oldIE ? "block" : "table") + "!important"
343+
},
344+
".MathJax_LineBox span": {
342345
display: (oldIE ? "block" : "table-cell") + "!important",
343346
width: (oldIE ? "100%" : "10000em") + "!important",
344347
"min-width":0, "max-width":"none",
@@ -495,7 +498,7 @@
495498
);
496499

497500
// Used in preTranslate to get linebreak width
498-
this.linebreakSpan = MathJax.HTML.Element("span",{className:"MathJax_LineBox"});
501+
this.linebreakSpan = MathJax.HTML.Element("span",{className:"MathJax_LineBox"},[["span"]]);
499502

500503
// Set up styles and preload web fonts
501504
return AJAX.Styles(this.config.styles,["InitializeHTML",this]);
@@ -551,7 +554,7 @@
551554
document.body.appendChild(this.linebreakSpan);
552555
this.defaultEx = this.EmExSpan.firstChild.offsetHeight/60;
553556
this.defaultEm = this.EmExSpan.lastChild.firstChild.offsetHeight/60;
554-
this.defaultWidth = this.linebreakSpan.offsetWidth;
557+
this.defaultWidth = this.linebreakSpan.firstChild.offsetWidth;
555558
document.body.removeChild(this.linebreakSpan);
556559
document.body.removeChild(this.EmExSpan);
557560
},
@@ -621,7 +624,7 @@
621624
jax = script.MathJax.elementJax; if (!jax) continue;
622625
ex = test.firstChild.offsetHeight/60;
623626
em = test.lastChild.firstChild.offsetHeight/60;
624-
cwidth = Math.max(0,div.previousSibling.offsetWidth - 2);
627+
cwidth = Math.max(0,div.previousSibling.firstChild.offsetWidth - 2);
625628
if (relwidth) {maxwidth = cwidth}
626629
if (ex === 0 || ex === "NaN") {
627630
// can't read width, so move to hidden div for processing

unpacked/jax/output/SVG/jax.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@
100100
"min-height": 0, "max-height":"none",
101101
padding:0, border: 0, margin: 0
102102
},
103-
".MathJax_SVG_LineBox": {
103+
".MathJax_SVG_LineBox": {display: "table!important"},
104+
".MathJax_SVG_LineBox span": {
104105
display: "table-cell!important",
105106
width: "10000em!important",
106107
"min-width":0, "max-width":"none",
@@ -179,7 +180,7 @@
179180
);
180181

181182
// Used in preTranslate to get linebreak width
182-
this.linebreakSpan = HTML.Element("span",{className:"MathJax_SVG_LineBox"});
183+
this.linebreakSpan = HTML.Element("span",{className:"MathJax_SVG_LineBox"},[["span"]]);
183184

184185
// Set up styles
185186
return AJAX.Styles(this.config.styles,["InitializeSVG",this]);
@@ -195,7 +196,7 @@
195196
document.body.appendChild(this.ExSpan);
196197
document.body.appendChild(this.linebreakSpan);
197198
this.defaultEx = this.ExSpan.firstChild.offsetHeight/60;
198-
this.defaultWidth = this.linebreakSpan.offsetWidth;
199+
this.defaultWidth = this.linebreakSpan.firstChild.offsetWidth;
199200
document.body.removeChild(this.linebreakSpan);
200201
document.body.removeChild(this.ExSpan);
201202
},
@@ -261,7 +262,7 @@
261262
test = script.previousSibling; div = test.previousSibling;
262263
jax = script.MathJax.elementJax; if (!jax) continue;
263264
ex = test.firstChild.offsetHeight/60;
264-
cwidth = Math.max(0,(div.previousSibling.offsetWidth-2) / this.config.scale * 100);
265+
cwidth = Math.max(0,(div.previousSibling.firstChild.offsetWidth-2) / this.config.scale * 100);
265266
if (ex === 0 || ex === "NaN") {
266267
// can't read width, so move to hidden div for processing
267268
// (this will cause a reflow for each math element that is hidden)

0 commit comments

Comments
 (0)