Skip to content

Commit

Permalink
Update svg output to properly handle token elements with multiple chi…
Browse files Browse the repository at this point in the history
…ld nodes. (mathjax/MathJax#2836)
  • Loading branch information
dpvc committed Apr 20, 2022
1 parent d671f3e commit 503a28b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions ts/output/chtml/Wrappers/TextNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ CommonTextNodeMixin<CHTMLConstructor<any, any, any>>(CHTMLWrapper) {
const adaptor = this.adaptor;
const variant = this.parent.variant;
const text = (this.node as TextNode).getText();
if (text.length === 0) return;
if (variant === '-explicitFont') {
adaptor.append(parent, this.jax.unknownText(text, variant, this.getBBox().w));
} else {
Expand Down
7 changes: 5 additions & 2 deletions ts/output/svg/Wrappers/TextNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,19 @@ CommonTextNodeMixin<SVGConstructor<any, any, any>>(SVGWrapper) {
public toSVG(parent: N) {
const text = (this.node as TextNode).getText();
const variant = this.parent.variant;
if (text.length === 0) return;
if (variant === '-explicitFont') {
this.adaptor.append(parent, this.jax.unknownText(text, variant));
this.element = this.adaptor.append(parent, this.jax.unknownText(text, variant));
} else {
const chars = this.remappedText(text, variant);
if (this.parent.childNodes.length > 1) {
parent = this.element = this.adaptor.append(parent, this.svg('g', {'data-mml-node': 'text'}));
}
let x = 0;
for (const n of chars) {
x += this.placeChar(n, x, 0, parent, variant);
}
}
this.element = this.adaptor.lastChild(parent);
}

}
2 changes: 1 addition & 1 deletion ts/output/svg/Wrappers/mtext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class SVGmtext<N, T, D> extends
CommonMtextMixin<SVGConstructor<any, any, any>>(SVGWrapper) {

/**
* The mtet wrapper
* The mtext wrapper
*/
public static kind = MmlMtext.prototype.kind;

Expand Down

0 comments on commit 503a28b

Please sign in to comment.