Skip to content

Commit 3894352

Browse files
authored
Merge pull request #1043 from mathjax/issue3166
Fix issues with line breaks and spacing in SVG output. (mathjax/MathJax#3166)
2 parents 2beae4f + 5f64bbb commit 3894352

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

ts/output/common/LineBBox.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export class LineBBox extends BBox {
9999
*/
100100
public append(cbox: LineBBox) {
101101
if (this.isFirst) {
102-
cbox.originalL = cbox.L;
102+
cbox.originalL += cbox.L;
103103
cbox.L = 0; // remove spacing after an operator with a linebreak after it
104104
}
105105
if (cbox.indentData) {

ts/output/common/Wrappers/mspace.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ export function CommonMspaceMixin<
201201
const bbox = LineBBox.from(BBox.zero(), leading);
202202
if (i === 1) {
203203
bbox.getIndentData(this.node);
204-
bbox.isFirst = true;
204+
bbox.w = this.getBBox().w;
205+
bbox.isFirst = (bbox.w === 0);
205206
}
206207
return bbox;
207208
}

ts/output/svg.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,12 +397,12 @@ CommonOutputJax<
397397
if (forced && mo.node.attributes.get('linebreakstyle') === 'after') {
398398
const k = mml.parent.node.childIndex(mml.node) + 1;
399399
const next = mml.parent.childNodes[k];
400-
const dimen = (next ? next.getLineBBox(0).originalL : 0) * scale;
400+
const dimen = (next ? next.getLineBBox(0).originalL * scale : 0);
401401
if (dimen) {
402402
this.addInlineBreak(nsvg, dimen, forced);
403403
}
404404
} else if (forced || i) {
405-
const dimen = (mml && i ? mml.getLineBBox(0).originalL : 0) * scale;
405+
const dimen = (mml && i ? mml.getLineBBox(0).originalL * scale : 0);
406406
if (dimen || !forced) {
407407
this.addInlineBreak(nsvg, dimen, forced || !!mml.node.getProperty('forcebreak'));
408408
}

0 commit comments

Comments
 (0)