Skip to content

Commit 064e053

Browse files
committed
Fix problem with potential infinite loop when an mspace is an embellished operator that causes a linebreak to occur. Also fix alignment problem in msubsup where svg.y wasn't taken into account (after a removeable group is removed). Might need similar treatment in moverunder and perhaps others as well. Issue #305.
1 parent 3802fa3 commit 064e053

File tree

3 files changed

+20
-29
lines changed

3 files changed

+20
-29
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
478478
//
479479
if (!broken) {this.HTMLaddWidth(this.base,info,scanW)}
480480
info.scanW += this.HTMLdw; info.W = info.scanW;
481-
info.index = index; if (better) {info.W = W; info.w = w}
481+
info.index = []; if (better) {info.W = W; info.w = w; info.index = index}
482482
return better;
483483
},
484484

@@ -504,8 +504,8 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
504504
if (s) {
505505
var box = s.HTMLspanElement().parentNode, stack = box.parentNode;
506506
if (this.data[this.base]) {stack.removeChild(stack.firstChild)}
507-
for (box = stack.firstChild; box; box = box.nextSibling)
508-
{box.style.left = HTMLCSS.Em(HTMLCSS.unEm(box.style.left)-this.HTMLbaseW)}
507+
for (box = stack.firstChild; box; box = box.nextSibling)
508+
{box.style.left = HTMLCSS.Em(HTMLCSS.unEm(box.style.left)-this.HTMLbaseW)}
509509
stack.bbox.w -= this.HTMLbaseW; stack.style.width = HTMLCSS.Em(stack.bbox.w);
510510
this.HTMLcombineBBoxes(stack,span.bbox);
511511
span.appendChild(stack);
@@ -522,6 +522,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
522522
// Override the method for checking line breaks to properly handle <mo>
523523
//
524524
HTMLbetterBreak: function (info,state) {
525+
if (info.values && info.values.id === this.spanID) {return false}
525526
var values = this.getValues(
526527
"linebreak","linebreakstyle","lineleading","linebreakmultchar",
527528
"indentalign","indentshift",
@@ -577,6 +578,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
577578
if (penalty >= info.penalty) {return false}
578579
info.penalty = penalty; info.values = values; info.W = W; info.w = w;
579580
values.lineleading = HTMLCSS.length2em(values.lineleading,state.VALUES.lineleading);
581+
values.id = this.spanID;
580582
return true;
581583
}
582584
});
@@ -588,6 +590,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
588590
// Override the method for checking line breaks to properly handle <mspace>
589591
//
590592
HTMLbetterBreak: function (info,state) {
593+
if (info.values && info.values.id === this.spanID) {return false}
591594
var values = this.getValues("linebreak");
592595
//
593596
// Get the default penalty for this location
@@ -617,7 +620,8 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
617620
//
618621
if (penalty >= info.penalty) {return false}
619622
info.penalty = penalty; info.values = values; info.W = W; info.w = w;
620-
values.lineleading = state.VALUES.lineleading; values.linebreakstyle = "before";
623+
values.lineleading = state.VALUES.lineleading;
624+
values.linebreakstyle = "before"; values.id = this.spanID;
621625
return true;
622626
}
623627
});

unpacked/jax/output/SVG/autoload/multiline.js

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
219219
//
220220
// Save the values needed for the future
221221
//
222-
state.d = line.d; state.values = values; state.n++;
222+
state.d = line.d-(line.y||0);
223+
state.values = values; state.n++;
223224
},
224225

225226
/****************************************************************/
@@ -433,7 +434,7 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
433434
//
434435
if (!broken) {this.SVGaddWidth(this.base,info,scanW)}
435436
info.scanW += this.SVGdata.dw; info.W = info.scanW;
436-
info.index = index; if (better) {info.W = W; info.w = w}
437+
info.index = []; if (better) {info.W = W; info.w = w; info.index = index}
437438
return better;
438439
},
439440

@@ -455,9 +456,9 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
455456
// base that has been removed. Remove the empty base box from the stack.
456457
//
457458
if (end.length === 0) {
458-
var sup = this.data[this.sup], sub = this.data[this.sub], w = svg.w;
459-
if (sup) {svg.Add(sup.toSVG(),w+(sup.SVGdata.dx||0),sup.SVGdata.dy)}
460-
if (sub) {svg.Add(sub.toSVG(),w+(sub.SVGdata.dx||0),sub.SVGdata.dy)}
459+
var sup = this.data[this.sup], sub = this.data[this.sub], w = svg.w, data;
460+
if (sup) {data = sup.SVGdata; svg.Add(sup.toSVG(),w+(data.dx||0),data.dy)}
461+
if (sub) {data = sub.SVGdata; svg.Add(sub.toSVG(),w+(data.dx||0),data.dy)}
461462
}
462463
}
463464

@@ -470,6 +471,7 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
470471
// Override the method for checking line breaks to properly handle <mo>
471472
//
472473
SVGbetterBreak: function (info,state) {
474+
if (info.values && info.values.last === this) {return false}
473475
var values = this.getValues(
474476
"linebreak","linebreakstyle","lineleading","linebreakmultchar",
475477
"indentalign","indentshift",
@@ -524,6 +526,7 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
524526
if (penalty >= info.penalty) {return false}
525527
info.penalty = penalty; info.values = values; info.W = W; info.w = w;
526528
values.lineleading = SVG.length2em(values.lineleading,state.VALUES.lineleading);
529+
values.last = this;
527530
return true;
528531
}
529532
});
@@ -535,6 +538,7 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
535538
// Override the method for checking line breaks to properly handle <mspace>
536539
//
537540
SVGbetterBreak: function (info,state) {
541+
if (info.values && info.values.last === this) {return false}
538542
var values = this.getValues("linebreak");
539543
//
540544
// Get the default penalty for this location
@@ -563,7 +567,8 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
563567
//
564568
if (penalty >= info.penalty) {return false}
565569
info.penalty = penalty; info.values = values; info.W = W; info.w = w;
566-
values.lineleading = state.VALUES.lineleading; values.linebreakstyle = "before";
570+
values.lineleading = state.VALUES.lineleading;
571+
values.linebreakstyle = "before"; values.last = this;
567572
return true;
568573
}
569574
});
@@ -592,24 +597,6 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
592597
SVGmoveLine: function (start,end,svg,state,values) {
593598
return this.Core().SVGmoveSlice(start,end,svg,state,values);
594599
},
595-
/*
596-
* //
597-
* // Split and move the hit boxes as well
598-
* //
599-
* SVGmoveSlice: function (start,end,svg,state,values,padding) {
600-
* var hitbox = document.getElementById("MathJax-HitBox-"+this.spanID+SVG.idPostfix);
601-
* if (hitbox) {hitbox.parentNode.removeChild(hitbox)}
602-
* var slice = this.SUPER(arguments).SVGmoveSlice.apply(this,arguments);
603-
* if (end.length === 0) {
604-
* span = this.SVGspanElement(); var n = 0;
605-
* while (span) {
606-
* hitbox = this.SVGhandleHitBox(span,"-Continue-"+n);
607-
* span = span.nextMathJaxSpan; n++;
608-
* }
609-
* }
610-
* return slice;
611-
* }
612-
*/
613600
});
614601

615602
//

unpacked/jax/output/SVG/jax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1811,7 +1811,7 @@
18111811
sub.w += s; sub.r = Math.max(sub.w,sub.r);
18121812
}
18131813
var q = SVG.TeX.sup_drop * sscale, r = SVG.TeX.sub_drop * sscale;
1814-
var u = base.h - q, v = base.d + r, delta = 0, p;
1814+
var u = base.h+(base.y||0) - q, v = base.d-(base.y||0) + r, delta = 0, p;
18151815
if (base.ic) {
18161816
base.w -= base.ic; // remove IC (added by mo and mi)
18171817
delta = 1.3*base.ic+.05; // adjust faked IC to be more in line with expeted results

0 commit comments

Comments
 (0)