Skip to content

Commit

Permalink
Fix issues with linebreaks and spacing in SVG output. (mathjax/MathJa…
Browse files Browse the repository at this point in the history
  • Loading branch information
dpvc committed Jan 26, 2024
1 parent 4cbd125 commit 5f64bbb
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 5f64bbb

Please sign in to comment.