Skip to content

Commit

Permalink
Fix problem with handling of multiple classes being added to the outp…
Browse files Browse the repository at this point in the history
…ut, and fix problem with multiple classes being added to TeXAtom output during serialization of the internal MathML. Resolves mathjax/MathJax#2185
  • Loading branch information
dpvc committed Sep 11, 2019
1 parent f73c0c7 commit f4ce2ab
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
21 changes: 10 additions & 11 deletions ts/core/MmlTree/SerializedMmlVisitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,15 @@ export class SerializedMmlVisitor extends MmlVisitor {
* @return {string} The serialized contents of the mrow, properly indented.
*/
public visitTeXAtomNode(node: MmlNode, space: string) {
let texclass = node.texClass < 0 ? 'NONE' : TEXCLASSNAMES[node.texClass];
let mml = space + '<mrow class="MJX-TeXAtom-' + texclass + '"' +
this.getAttributes(node) + '>\n';
const endspace = space;
space += ' ';
for (const child of node.childNodes) {
mml += this.visitNode(child, space);
}
mml += '\n' + endspace + '</mrow>';
return mml;
let texclass = node.texClass < 0 ? 'NONE' : TEXCLASSNAMES[node.texClass];
let children = this.childNodeMml(node, space + ' ', '\n');
let attributes = node.attributes;
let names = attributes.getExplicit('class');
attributes.set('class', 'MJX-TeXAtom-' + texclass + (names ? ' ' + names : ''));
let mml = space + '<mrow' + this.getAttributes(node) + '>' +
(children.match(/\S/) ? '\n' + children + space : '') + '</mrow>';
attributes.set('class', names);
return mml;
}

/**
Expand All @@ -111,7 +110,7 @@ export class SerializedMmlVisitor extends MmlVisitor {

/**
* The generic visiting function:
* Make the string versino of the open tag, properly indented, with it attributes
* Make the string version of the open tag, properly indented, with it attributes
* Increate the indentation level
* Add the childnodes
* Add the end tag with proper spacing (empty tags have the close tag following directly)
Expand Down
5 changes: 4 additions & 1 deletion ts/output/chtml/Wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,10 @@ CommonWrapper<
}
}
if (attributes.get('class')) {
this.adaptor.addClass(this.chtml, attributes.get('class') as string);
const names = (attributes.get('class') as string).split(/ /);
for (const name of names) {
this.adaptor.addClass(this.chtml, name);
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion ts/output/svg/Wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,10 @@ CommonWrapper<
}
}
if (attributes.get('class')) {
this.adaptor.addClass(this.element, attributes.get('class') as string);
const names = (attributes.get('class') as string).split(/ /);
for (const name of names) {
this.adaptor.addClass(this.element, name);
}
}
}

Expand Down

0 comments on commit f4ce2ab

Please sign in to comment.