Skip to content

Commit

Permalink
Merge pull request #1043 from mathjax/issue3166
Browse files Browse the repository at this point in the history
Fix issues with line breaks and spacing in SVG output. (mathjax/MathJax#3166)
  • Loading branch information
dpvc committed Feb 1, 2024
2 parents 2beae4f + 5f64bbb commit 3894352
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ts/output/common/LineBBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class LineBBox extends BBox {
*/
public append(cbox: LineBBox) {
if (this.isFirst) {
cbox.originalL = cbox.L;
cbox.originalL += cbox.L;
cbox.L = 0; // remove spacing after an operator with a linebreak after it
}
if (cbox.indentData) {
Expand Down
3 changes: 2 additions & 1 deletion ts/output/common/Wrappers/mspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ export function CommonMspaceMixin<
const bbox = LineBBox.from(BBox.zero(), leading);
if (i === 1) {
bbox.getIndentData(this.node);
bbox.isFirst = true;
bbox.w = this.getBBox().w;
bbox.isFirst = (bbox.w === 0);
}
return bbox;
}
Expand Down
4 changes: 2 additions & 2 deletions ts/output/svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,12 +397,12 @@ CommonOutputJax<
if (forced && mo.node.attributes.get('linebreakstyle') === 'after') {
const k = mml.parent.node.childIndex(mml.node) + 1;
const next = mml.parent.childNodes[k];
const dimen = (next ? next.getLineBBox(0).originalL : 0) * scale;
const dimen = (next ? next.getLineBBox(0).originalL * scale : 0);
if (dimen) {
this.addInlineBreak(nsvg, dimen, forced);
}
} else if (forced || i) {
const dimen = (mml && i ? mml.getLineBBox(0).originalL : 0) * scale;
const dimen = (mml && i ? mml.getLineBBox(0).originalL * scale : 0);
if (dimen || !forced) {
this.addInlineBreak(nsvg, dimen, forced || !!mml.node.getProperty('forcebreak'));
}
Expand Down

0 comments on commit 3894352

Please sign in to comment.