Skip to content

Commit

Permalink
Merge pull request #394 from mathjax/issue383
Browse files Browse the repository at this point in the history
Handle texClass for mo's before inheritance.  #383
  • Loading branch information
dpvc authored Dec 16, 2019
2 parents f945b0d + 8723350 commit d7a81f2
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions ts/core/MmlTree/MmlNodes/mo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,32 @@ export class MmlMo extends AbstractMmlTokenNode {
public static OPTABLE: {[form: string]: OperatorList} = OPTABLE;

/**
* The TeX class of the node is set to REL for MathML, but TeX sets it explicitly in setTeXclass()
* The internal TeX class of the node (for use with getter/setter below)
*/
public texClass = TEXCLASS.REL;
public _texClass: number = null;

/**
* Use a getter to look up the TeX class from the operator table if it hasn't
* been set yet (but don't save it in case the form changes when it is in its
* location).
*/
public get texClass() {
if (this._texClass === null) {
let mo = this.getText();
let [form1, form2, form3] = this.handleExplicitForm(this.getForms());
let OPTABLE = (this.constructor as typeof MmlMo).OPTABLE;
let def = OPTABLE[form1][mo] || OPTABLE[form2][mo] || OPTABLE[form3][mo];
return def ? def[2] : TEXCLASS.REL;
}
return this._texClass;
}

/**
* Use a setter to store the actual value in _texClass;
*/
public set texClass(value: number) {
this._texClass = value;
}

/**
* The default MathML spacing on the left and right
Expand Down

0 comments on commit d7a81f2

Please sign in to comment.