feat: add mmultiscripts prescript default case
This commit is contained in:
parent
169d6271b3
commit
e74def23e7
@ -8,7 +8,7 @@ export class MMultiscripts extends MathMLTag {
|
||||
}
|
||||
|
||||
convert(): string {
|
||||
if (this._children.length < 3) throw new InvalidNumberOfChild(this.name, 2, this._children.length, 'at least');
|
||||
if (this._children.length < 3) throw new InvalidNumberOfChild(this.name, 3, this._children.length, 'at least');
|
||||
|
||||
const base = this._children[0];
|
||||
const sub = this._children[1];
|
||||
@ -20,7 +20,29 @@ export class MMultiscripts extends MathMLTag {
|
||||
const wrappedSub = new BracketWrapper().wrap(sub.convert());
|
||||
const wrappedSup = new BracketWrapper().wrap(sup.convert());
|
||||
|
||||
return `${this._wrapInParenthesisIfThereIsSpace(base.convert())}_${wrappedSub}^${wrappedSup}`;
|
||||
return this._prescriptLatex() + this._wrapInParenthesisIfThereIsSpace(base.convert()) + this._postscriptLatex();
|
||||
}
|
||||
|
||||
private _prescriptLatex(): string {
|
||||
if (this._children[3]?.name !== 'mprescripts') return '';
|
||||
|
||||
const sub = this._children[4];
|
||||
const sup = this._children[5];
|
||||
|
||||
const subLatex = sub ? sub.convert() : '';
|
||||
const supLatex = sup ? sup.convert() : '';
|
||||
|
||||
return `\\_{${subLatex}}^{${supLatex}}`;
|
||||
}
|
||||
|
||||
private _postscriptLatex(): string {
|
||||
const sub = this._children[1];
|
||||
const sup = this._children[2];
|
||||
|
||||
const subLatex = sub ? sub.convert() : '';
|
||||
const supLatex = sup ? sup.convert() : '';
|
||||
|
||||
return `_{${subLatex}}^{${supLatex}}`;
|
||||
}
|
||||
|
||||
private _wrapInParenthesisIfThereIsSpace(str: string): string {
|
||||
|
Loading…
Reference in New Issue
Block a user