Skip to content

Commit 0c3342a

Browse files
committed
Move createMo() from msqrt to Wrapper, since it is needed for bevelled fractions, and will be needed for mfenced as well.
1 parent a29aa45 commit 0c3342a

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

mathjax3-ts/output/chtml/Wrapper.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
import {AbstractWrapper} from '../../core/Tree/Wrapper.js';
2525
import {Node, PropertyList} from '../../core/Tree/Node.js';
26-
import {MmlNode, TextNode, AbstractMmlNode} from '../../core/MmlTree/MmlNode.js';
26+
import {MmlNode, TextNode, AbstractMmlNode, AttributeList} from '../../core/MmlTree/MmlNode.js';
2727
import {Property} from '../../core/Tree/Node.js';
2828
import {OptionList} from '../../util/Options.js';
2929
import {unicodeChars} from '../../util/string.js';
@@ -772,6 +772,29 @@ export class CHTMLWrapper<N, T, D> extends AbstractWrapper<MmlNode, CHTMLWrapper
772772
return (this.node as AbstractMmlNode).factory.create(kind, properties, children);
773773
}
774774

775+
/*
776+
* Create an mo wrapper with the given text,
777+
* link it in, and give it the right defaults.
778+
*
779+
* @param{string} text The text for the wrapped element
780+
* @return{CHTMLWrapper} The wrapped MmlMo node
781+
*/
782+
protected createMo(text: string): CHTMLmo<N, T, D> {
783+
const mmlFactory = (this.node as AbstractMmlNode).factory;
784+
const textNode = (mmlFactory.create('text') as TextNode).setText(text);
785+
const mml = mmlFactory.create('mo', {stretchy: true}, [textNode]);
786+
const attributes = this.node.attributes;
787+
const display = attributes.get('display') as boolean;
788+
const scriptlevel = attributes.get('scriptlevel') as number;
789+
const defaults: AttributeList = {
790+
mathsize: ['math', attributes.get('mathsize')]
791+
};
792+
mml.setInheritedAttributes(defaults, display, scriptlevel, false);
793+
const node = this.wrap(mml) as CHTMLmo<N, T, D>;
794+
node.parent = this;
795+
return node;
796+
}
797+
775798
}
776799

777800
/*

mathjax3-ts/output/chtml/Wrappers/msqrt.ts

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {CHTMLWrapperFactory} from '../WrapperFactory.js';
2626
import {CHTMLmo} from './mo.js';
2727
import {BBox} from '../BBox.js';
2828
import {MmlMsqrt} from '../../../core/MmlTree/MmlNodes/msqrt.js';
29-
import {MmlNode, AbstractMmlNode, TextNode, AttributeList} from '../../../core/MmlTree/MmlNode.js';
29+
import {MmlNode, AbstractMmlNode, TextNode} from '../../../core/MmlTree/MmlNode.js';
3030
import {StyleList} from '../CssStyles.js';
3131
import {DIRECTION} from '../FontData.js';
3232

@@ -106,25 +106,10 @@ export class CHTMLmsqrt<N, T, D> extends CHTMLWrapper<N, T, D> {
106106
}
107107

108108
/*
109-
* Create an mo wrapper with the given text,
110-
* link it in, and give it the right defaults.
111-
*
112-
* @param{string} text The text for the wrapped element
113-
* @return{CHTMLWrapper} The wrapped MmlMo node
109+
* @override
114110
*/
115111
protected createMo(text: string) {
116-
const mmlFactory = (this.node as AbstractMmlNode).factory;
117-
const textNode = (mmlFactory.create('text') as TextNode).setText(text);
118-
const mml = mmlFactory.create('mo', {stretchy: true}, [textNode]);
119-
const attributes = this.node.attributes;
120-
const display = attributes.get('display') as boolean;
121-
const scriptlevel = attributes.get('scriptlevel') as number;
122-
const defaults: AttributeList = {
123-
mathsize: ['math', attributes.get('mathsize')]
124-
};
125-
mml.setInheritedAttributes(defaults, display, scriptlevel, false);
126-
const node = this.wrap(mml) as CHTMLmo<N, T, D>;
127-
node.parent = this;
112+
const node = super.createMo(text);
128113
this.childNodes.push(node);
129114
return node;
130115
}

0 commit comments

Comments
 (0)