Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix problem with \rightarrow being converted to \vec in some cases. (mathjax/MathJax#2380) #468

Merged
merged 1 commit into from
Apr 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions ts/core/MmlTree/MmlNodes/mo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,14 @@ export class MmlMo extends AbstractMmlTokenNode {
* with this node as its core
*/
public coreParent() {
let parent: MmlNode = this;
let embellished = this as MmlNode;
let parent = this as MmlNode;
let math = this.factory.getNodeClass('math');
while (parent && parent.isEmbellished && parent.coreMO() === this && !(parent instanceof math)) {
embellished = parent;
parent = (parent as MmlNode).Parent;
}
return parent;
return embellished;
}

/**
Expand Down Expand Up @@ -170,7 +172,7 @@ export class MmlMo extends AbstractMmlTokenNode {
*/
get isAccent() {
let accent = false;
const node = this.coreParent();
const node = this.coreParent().parent;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure this always exists?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The coreParent() call always returns an element (in the code for coreParent() just above this, the embellished operator starts as this, which is non-null, and only gets updated within the loop, where it is set to parent, which is known to be non-null by the condition of the while loop).

While its parent attribute may be null, the next line (just below these comments) checks for that.

if (node) {
const key = (node.isKind('mover') ?
((node.childNodes[(node as MmlMover).over] as MmlNode).coreMO() ?
Expand Down
1 change: 0 additions & 1 deletion ts/output/common/Wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,6 @@ export class CommonWrapper<
protected getMathMLSpacing() {
const node = this.node.coreMO() as MmlMo;
const attributes = node.attributes;
const parent = this.jax.nodeMap.get(node.coreParent());
const isScript = (attributes.get('scriptlevel') > 0);
this.bbox.L = (attributes.isSet('lspace') ?
Math.max(0, this.length2em(attributes.get('lspace'))) :
Expand Down
5 changes: 2 additions & 3 deletions ts/output/common/Wrappers/mo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,8 @@ export function CommonMoMixin<T extends WrapperConstructor>(Base: T): MoConstruc
*/
public remapChars(chars: number[]) {
if (chars.length === 1) {
const parent = this.node.parent;
const isAccent = this.isAccent &&
(parent === (this.node as MmlMo).coreParent() || parent.isEmbellished);
const parent = (this.node as MmlMo).coreParent().parent;
const isAccent = this.isAccent && !parent.isKind('mrow');
const map = (isAccent ? 'accent' : 'mo');
const text = this.font.getRemappedChar(map, chars[0]);
if (text) {
Expand Down