feat: add msubsup single command use case
This commit is contained in:
parent
720dde60e3
commit
d8776ec34a
@ -16,6 +16,7 @@ import {
|
||||
MPhantom,
|
||||
MSup,
|
||||
MSub,
|
||||
MSubsup,
|
||||
} from './mathml-tags';
|
||||
|
||||
export class Dispatcher {
|
||||
@ -63,6 +64,8 @@ export class Dispatcher {
|
||||
return new MSup(this._value, this._attributes, this._children);
|
||||
case 'msub':
|
||||
return new MSub(this._value, this._attributes, this._children);
|
||||
case 'msubsup':
|
||||
return new MSubsup(this._value, this._attributes, this._children);
|
||||
case 'mrow':
|
||||
case 'mpadded':
|
||||
return new GenericContentWrapperTag(this._name, this._value, this._attributes, this._children);
|
||||
|
22
src/converters/mathml-interfaces-to-latex/mathml-tag-to-latex/mathml-tags/MSubsup.ts
Executable file
22
src/converters/mathml-interfaces-to-latex/mathml-tag-to-latex/mathml-tags/MSubsup.ts
Executable file
@ -0,0 +1,22 @@
|
||||
import { MathMLTag } from './MathMLTag';
|
||||
import { BracketWrapper } from '../../../../utils/wrappers';
|
||||
import { InvalidNumberOfChild } from '../../../../errors';
|
||||
|
||||
export class MSubsup extends MathMLTag {
|
||||
constructor(value: string, attributes: Record<string, string>, children: MathMLTag[]) {
|
||||
super('msubsup', value, attributes, children);
|
||||
}
|
||||
|
||||
convert(): string {
|
||||
if (this._children.length !== 3) throw new InvalidNumberOfChild(this._name, 2, this._children.length);
|
||||
|
||||
const base = this._children[0].convert();
|
||||
const sub = this._children[1].convert();
|
||||
const sup = this._children[2].convert();
|
||||
|
||||
const wrappedSub = new BracketWrapper().wrap(sub);
|
||||
const wrappedSup = new BracketWrapper().wrap(sup);
|
||||
|
||||
return `${base}_${wrappedSub}^${wrappedSup}`;
|
||||
}
|
||||
}
|
@ -15,3 +15,4 @@ export { MOver } from './MOver';
|
||||
export { MPhantom } from './MPhantom';
|
||||
export { MSup } from './MSup';
|
||||
export { MSub } from './MSub';
|
||||
export { MSubsup } from './MSubsup';
|
||||
|
Loading…
Reference in New Issue
Block a user