Turn math component into array

This commit is contained in:
Dolan Miu
2020-10-13 02:06:27 +01:00
parent e36e9e1cf4
commit 5be195fd91
39 changed files with 208 additions and 157 deletions

View File

@ -33,8 +33,8 @@ doc.addSection({
children: [ children: [
new MathRun("2+2"), new MathRun("2+2"),
new MathFraction({ new MathFraction({
numerator: new MathRun("hi"), numerator: [new MathRun("hi")],
denominator: new MathRun("2"), denominator: [new MathRun("2")],
}), }),
], ],
}), }),
@ -44,26 +44,43 @@ doc.addSection({
}), }),
], ],
}), }),
// new Paragraph({
// children: [
// new MathFraction({
// numerator: [
// new MathRun("1"),
// new MathRadical({
// children: [new MathRun("2")],
// }),
// ],
// denominator: [new MathRun("2")],
// }),
// ],
// }),
new Paragraph({ new Paragraph({
children: [ children: [
new Math({ new Math({
children: [ children: [
new MathSum({ new MathSum({
child: new MathRun("test"), children: [new MathRun("test")],
}), }),
new MathSum({ new MathSum({
child: new MathSuperScript({ children: [
child: new MathRun("e"), new MathSuperScript({
superScript: new MathRun("2"), children: [new MathRun("e")],
}), superScript: [new MathRun("2")],
subScript: new MathRun("i"), }),
],
subScript: [new MathRun("i")],
}), }),
new MathSum({ new MathSum({
child: new MathRadical({ children: [
child: new MathRun("i"), new MathRadical({
}), children: [new MathRun("i")],
subScript: new MathRun("i"), }),
superScript: new MathRun("10"), ],
subScript: [new MathRun("i")],
superScript: [new MathRun("10")],
}), }),
], ],
}), }),
@ -74,8 +91,8 @@ doc.addSection({
new Math({ new Math({
children: [ children: [
new MathSuperScript({ new MathSuperScript({
child: new MathRun("test"), children: [new MathRun("test")],
superScript: new MathRun("hello"), superScript: [new MathRun("hello")],
}), }),
], ],
}), }),
@ -86,8 +103,8 @@ doc.addSection({
new Math({ new Math({
children: [ children: [
new MathSubScript({ new MathSubScript({
child: new MathRun("test"), children: [new MathRun("test")],
subScript: new MathRun("hello"), subScript: [new MathRun("hello")],
}), }),
], ],
}), }),
@ -98,11 +115,13 @@ doc.addSection({
new Math({ new Math({
children: [ children: [
new MathSubScript({ new MathSubScript({
child: new MathRun("x"), children: [new MathRun("x")],
subScript: new MathSuperScript({ subScript: [
child: new MathRun("y"), new MathSuperScript({
superScript: new MathRun("2"), children: [new MathRun("y")],
}), superScript: [new MathRun("2")],
}),
],
}), }),
], ],
}), }),
@ -113,9 +132,9 @@ doc.addSection({
new Math({ new Math({
children: [ children: [
new MathSubSuperScript({ new MathSubSuperScript({
child: new MathRun("test"), children: [new MathRun("test")],
superScript: new MathRun("hello"), superScript: [new MathRun("hello")],
subScript: new MathRun("world"), subScript: [new MathRun("world")],
}), }),
], ],
}), }),
@ -126,9 +145,9 @@ doc.addSection({
new Math({ new Math({
children: [ children: [
new MathPreSubSuperScript({ new MathPreSubSuperScript({
child: new MathRun("test"), children: [new MathRun("test")],
superScript: new MathRun("hello"), superScript: [new MathRun("hello")],
subScript: new MathRun("world"), subScript: [new MathRun("world")],
}), }),
], ],
}), }),
@ -139,29 +158,35 @@ doc.addSection({
new Math({ new Math({
children: [ children: [
new MathSubScript({ new MathSubScript({
child: new MathFraction({ children: [
numerator: new MathRun("1"), new MathFraction({
denominator: new MathRun("2"), numerator: [new MathRun("1")],
}), denominator: [new MathRun("2")],
subScript: new MathRun("4"),
}),
],
}),
],
}),
new Paragraph({
children: [
new Math({
children: [
new MathSubScript({
child: new MathRadical({
child: new MathFraction({
numerator: new MathRun("1"),
denominator: new MathRun("2"),
}), }),
degree: new MathRun("4"), ],
}), subScript: [new MathRun("4")],
subScript: new MathRun("x"), }),
],
}),
],
}),
new Paragraph({
children: [
new Math({
children: [
new MathSubScript({
children: [
new MathRadical({
children: [
new MathFraction({
numerator: [new MathRun("1")],
denominator: [new MathRun("2")],
}),
],
degree: [new MathRun("4")],
}),
],
subScript: [new MathRun("x")],
}), }),
], ],
}), }),
@ -172,7 +197,7 @@ doc.addSection({
new Math({ new Math({
children: [ children: [
new MathRadical({ new MathRadical({
child: new MathRun("4"), children: [new MathRun("4")],
}), }),
], ],
}), }),
@ -183,16 +208,18 @@ doc.addSection({
new Math({ new Math({
children: [ children: [
new MathFunction({ new MathFunction({
name: new MathSuperScript({ name: [
child: new MathRun("cos"), new MathSuperScript({
superScript: new MathRun("-1"), children: [new MathRun("cos")],
}), superScript: [new MathRun("-1")],
child: new MathRun("100"), }),
],
children: [new MathRun("100")],
}), }),
new MathRun("×"), new MathRun("×"),
new MathFunction({ new MathFunction({
name: new MathRun("sin"), name: [new MathRun("sin")],
child: new MathRun("360"), children: [new MathRun("360")],
}), }),
new MathRun("= x"), new MathRun("= x"),
], ],
@ -204,28 +231,36 @@ doc.addSection({
new Math({ new Math({
children: [ children: [
new MathRoundBrackets({ new MathRoundBrackets({
child: new MathFraction({ children: [
numerator: new MathRun("1"), new MathFraction({
denominator: new MathRun("2"), numerator: [new MathRun("1")],
}), denominator: [new MathRun("2")],
}),
],
}), }),
new MathSquareBrackets({ new MathSquareBrackets({
child: new MathFraction({ children: [
numerator: new MathRun("1"), new MathFraction({
denominator: new MathRun("2"), numerator: [new MathRun("1")],
}), denominator: [new MathRun("2")],
}),
],
}), }),
new MathCurlyBrackets({ new MathCurlyBrackets({
child: new MathFraction({ children: [
numerator: new MathRun("1"), new MathFraction({
denominator: new MathRun("2"), numerator: [new MathRun("1")],
}), denominator: [new MathRun("2")],
}),
],
}), }),
new MathAngledBrackets({ new MathAngledBrackets({
child: new MathFraction({ children: [
numerator: new MathRun("1"), new MathFraction({
denominator: new MathRun("2"), numerator: [new MathRun("1")],
}), denominator: [new MathRun("2")],
}),
],
}), }),
], ],
}), }),
@ -236,10 +271,12 @@ doc.addSection({
new Math({ new Math({
children: [ children: [
new MathFraction({ new MathFraction({
numerator: new MathRadical({ numerator: [
child: new MathRun("4"), new MathRadical({
}), children: [new MathRun("4")],
denominator: new MathRun("2a"), }),
],
denominator: [new MathRun("2a")],
}), }),
], ],
}), }),

View File

@ -9,7 +9,7 @@ describe("MathAngledBrackets", () => {
describe("#constructor()", () => { describe("#constructor()", () => {
it("should create a MathAngledBrackets with correct root key", () => { it("should create a MathAngledBrackets with correct root key", () => {
const mathAngledBrackets = new MathAngledBrackets({ const mathAngledBrackets = new MathAngledBrackets({
child: new MathRun("60"), children: [new MathRun("60")],
}); });
const tree = new Formatter().format(mathAngledBrackets); const tree = new Formatter().format(mathAngledBrackets);

View File

@ -6,7 +6,7 @@ import { MathBase } from "../n-ary";
import { MathBracketProperties } from "./math-bracket-properties"; import { MathBracketProperties } from "./math-bracket-properties";
export class MathAngledBrackets extends XmlComponent { export class MathAngledBrackets extends XmlComponent {
constructor(options: { readonly child: MathComponent }) { constructor(options: { readonly children: MathComponent[] }) {
super("m:d"); super("m:d");
this.root.push( this.root.push(
@ -15,6 +15,6 @@ export class MathAngledBrackets extends XmlComponent {
endingCharacter: "〉", endingCharacter: "〉",
}), }),
); );
this.root.push(new MathBase(options.child)); this.root.push(new MathBase(options.children));
} }
} }

View File

@ -9,7 +9,7 @@ describe("MathCurlyBrackets", () => {
describe("#constructor()", () => { describe("#constructor()", () => {
it("should create a MathCurlyBrackets with correct root key", () => { it("should create a MathCurlyBrackets with correct root key", () => {
const mathCurlyBrackets = new MathCurlyBrackets({ const mathCurlyBrackets = new MathCurlyBrackets({
child: new MathRun("60"), children: [new MathRun("60")],
}); });
const tree = new Formatter().format(mathCurlyBrackets); const tree = new Formatter().format(mathCurlyBrackets);

View File

@ -6,7 +6,7 @@ import { MathBase } from "../n-ary";
import { MathBracketProperties } from "./math-bracket-properties"; import { MathBracketProperties } from "./math-bracket-properties";
export class MathCurlyBrackets extends XmlComponent { export class MathCurlyBrackets extends XmlComponent {
constructor(options: { readonly child: MathComponent }) { constructor(options: { readonly children: MathComponent[] }) {
super("m:d"); super("m:d");
this.root.push( this.root.push(
@ -15,6 +15,6 @@ export class MathCurlyBrackets extends XmlComponent {
endingCharacter: "}", endingCharacter: "}",
}), }),
); );
this.root.push(new MathBase(options.child)); this.root.push(new MathBase(options.children));
} }
} }

View File

@ -9,7 +9,7 @@ describe("MathRoundBrackets", () => {
describe("#constructor()", () => { describe("#constructor()", () => {
it("should create a MathRoundBrackets with correct root key", () => { it("should create a MathRoundBrackets with correct root key", () => {
const mathRoundBrackets = new MathRoundBrackets({ const mathRoundBrackets = new MathRoundBrackets({
child: new MathRun("60"), children: [new MathRun("60")],
}); });
const tree = new Formatter().format(mathRoundBrackets); const tree = new Formatter().format(mathRoundBrackets);

View File

@ -6,10 +6,10 @@ import { MathBase } from "../n-ary";
import { MathBracketProperties } from "./math-bracket-properties"; import { MathBracketProperties } from "./math-bracket-properties";
export class MathRoundBrackets extends XmlComponent { export class MathRoundBrackets extends XmlComponent {
constructor(options: { readonly child: MathComponent }) { constructor(options: { readonly children: MathComponent[] }) {
super("m:d"); super("m:d");
this.root.push(new MathBracketProperties()); this.root.push(new MathBracketProperties());
this.root.push(new MathBase(options.child)); this.root.push(new MathBase(options.children));
} }
} }

View File

@ -9,7 +9,7 @@ describe("MathSquareBrackets", () => {
describe("#constructor()", () => { describe("#constructor()", () => {
it("should create a MathSquareBrackets with correct root key", () => { it("should create a MathSquareBrackets with correct root key", () => {
const mathSquareBrackets = new MathSquareBrackets({ const mathSquareBrackets = new MathSquareBrackets({
child: new MathRun("60"), children: [new MathRun("60")],
}); });
const tree = new Formatter().format(mathSquareBrackets); const tree = new Formatter().format(mathSquareBrackets);

View File

@ -6,7 +6,7 @@ import { MathBase } from "../n-ary";
import { MathBracketProperties } from "./math-bracket-properties"; import { MathBracketProperties } from "./math-bracket-properties";
export class MathSquareBrackets extends XmlComponent { export class MathSquareBrackets extends XmlComponent {
constructor(options: { readonly child: MathComponent }) { constructor(options: { readonly children: MathComponent[] }) {
super("m:d"); super("m:d");
this.root.push( this.root.push(
@ -15,6 +15,6 @@ export class MathSquareBrackets extends XmlComponent {
endingCharacter: "]", endingCharacter: "]",
}), }),
); );
this.root.push(new MathBase(options.child)); this.root.push(new MathBase(options.children));
} }
} }

View File

@ -8,7 +8,7 @@ import { MathDenominator } from "./math-denominator";
describe("MathDenominator", () => { describe("MathDenominator", () => {
describe("#constructor()", () => { describe("#constructor()", () => {
it("should create a MathDenominator with correct root key", () => { it("should create a MathDenominator with correct root key", () => {
const mathDenominator = new MathDenominator(new MathRun("2+2")); const mathDenominator = new MathDenominator([new MathRun("2+2")]);
const tree = new Formatter().format(mathDenominator); const tree = new Formatter().format(mathDenominator);
expect(tree).to.deep.equal({ expect(tree).to.deep.equal({
"m:den": [ "m:den": [

View File

@ -3,9 +3,11 @@ import { XmlComponent } from "file/xml-components";
import { MathComponent } from "../math-component"; import { MathComponent } from "../math-component";
export class MathDenominator extends XmlComponent { export class MathDenominator extends XmlComponent {
constructor(child: MathComponent) { constructor(children: MathComponent[]) {
super("m:den"); super("m:den");
this.root.push(child); for (const child of children) {
this.root.push(child);
}
} }
} }

View File

@ -9,8 +9,8 @@ describe("MathFraction", () => {
describe("#constructor()", () => { describe("#constructor()", () => {
it("should create a MathFraction with correct root key", () => { it("should create a MathFraction with correct root key", () => {
const mathFraction = new MathFraction({ const mathFraction = new MathFraction({
numerator: new MathRun("2"), numerator: [new MathRun("2")],
denominator: new MathRun("2"), denominator: [new MathRun("2")],
}); });
const tree = new Formatter().format(mathFraction); const tree = new Formatter().format(mathFraction);
expect(tree).to.deep.equal({ expect(tree).to.deep.equal({

View File

@ -5,8 +5,8 @@ import { MathDenominator } from "./math-denominator";
import { MathNumerator } from "./math-numerator"; import { MathNumerator } from "./math-numerator";
export interface IMathFractionOptions { export interface IMathFractionOptions {
readonly numerator: MathComponent; readonly numerator: MathComponent[];
readonly denominator: MathComponent; readonly denominator: MathComponent[];
} }
export class MathFraction extends XmlComponent { export class MathFraction extends XmlComponent {

View File

@ -8,7 +8,7 @@ import { MathNumerator } from "./math-numerator";
describe("MathNumerator", () => { describe("MathNumerator", () => {
describe("#constructor()", () => { describe("#constructor()", () => {
it("should create a MathNumerator with correct root key", () => { it("should create a MathNumerator with correct root key", () => {
const mathNumerator = new MathNumerator(new MathRun("2+2")); const mathNumerator = new MathNumerator([new MathRun("2+2")]);
const tree = new Formatter().format(mathNumerator); const tree = new Formatter().format(mathNumerator);
expect(tree).to.deep.equal({ expect(tree).to.deep.equal({
"m:num": [ "m:num": [

View File

@ -3,9 +3,11 @@ import { XmlComponent } from "file/xml-components";
import { MathComponent } from "../math-component"; import { MathComponent } from "../math-component";
export class MathNumerator extends XmlComponent { export class MathNumerator extends XmlComponent {
constructor(child: MathComponent) { constructor(children: MathComponent[]) {
super("m:num"); super("m:num");
this.root.push(child); for (const child of children) {
this.root.push(child);
}
} }
} }

View File

@ -8,7 +8,7 @@ import { MathFunctionName } from "./math-function-name";
describe("MathFunctionName", () => { describe("MathFunctionName", () => {
describe("#constructor()", () => { describe("#constructor()", () => {
it("should create a MathFunctionName with correct root key", () => { it("should create a MathFunctionName with correct root key", () => {
const mathFunctionName = new MathFunctionName(new MathRun("2")); const mathFunctionName = new MathFunctionName([new MathRun("2")]);
const tree = new Formatter().format(mathFunctionName); const tree = new Formatter().format(mathFunctionName);
expect(tree).to.deep.equal({ expect(tree).to.deep.equal({

View File

@ -3,9 +3,11 @@ import { XmlComponent } from "file/xml-components";
import { MathComponent } from "../math-component"; import { MathComponent } from "../math-component";
export class MathFunctionName extends XmlComponent { export class MathFunctionName extends XmlComponent {
constructor(child: MathComponent) { constructor(children: MathComponent[]) {
super("m:fName"); super("m:fName");
this.root.push(child); for (const child of children) {
this.root.push(child);
}
} }
} }

View File

@ -9,8 +9,8 @@ describe("MathFunction", () => {
describe("#constructor()", () => { describe("#constructor()", () => {
it("should create a MathFunction with correct root key", () => { it("should create a MathFunction with correct root key", () => {
const mathFunction = new MathFunction({ const mathFunction = new MathFunction({
name: new MathRun("sin"), name: [new MathRun("sin")],
child: new MathRun("60"), children: [new MathRun("60")],
}); });
const tree = new Formatter().format(mathFunction); const tree = new Formatter().format(mathFunction);

View File

@ -7,8 +7,8 @@ import { MathFunctionName } from "./math-function-name";
import { MathFunctionProperties } from "./math-function-properties"; import { MathFunctionProperties } from "./math-function-properties";
export interface IMathFunctionOptions { export interface IMathFunctionOptions {
readonly child: MathComponent; readonly children: MathComponent[];
readonly name: MathComponent; readonly name: MathComponent[];
} }
export class MathFunction extends XmlComponent { export class MathFunction extends XmlComponent {
@ -17,6 +17,6 @@ export class MathFunction extends XmlComponent {
this.root.push(new MathFunctionProperties()); this.root.push(new MathFunctionProperties());
this.root.push(new MathFunctionName(options.name)); this.root.push(new MathFunctionName(options.name));
this.root.push(new MathBase(options.child)); this.root.push(new MathBase(options.children));
} }
} }

View File

@ -8,7 +8,7 @@ import { MathBase } from "./math-base";
describe("MathBase", () => { describe("MathBase", () => {
describe("#constructor()", () => { describe("#constructor()", () => {
it("should create a MathBase with correct root key", () => { it("should create a MathBase with correct root key", () => {
const mathBase = new MathBase(new MathRun("2+2")); const mathBase = new MathBase([new MathRun("2+2")]);
const tree = new Formatter().format(mathBase); const tree = new Formatter().format(mathBase);
expect(tree).to.deep.equal({ expect(tree).to.deep.equal({

View File

@ -4,9 +4,11 @@ import { XmlComponent } from "file/xml-components";
import { MathComponent } from "../math-component"; import { MathComponent } from "../math-component";
export class MathBase extends XmlComponent { export class MathBase extends XmlComponent {
constructor(run: MathComponent) { constructor(children: MathComponent[]) {
super("m:e"); super("m:e");
this.root.push(run); for (const child of children) {
this.root.push(child);
}
} }
} }

View File

@ -8,7 +8,7 @@ import { MathSubScriptElement } from "./math-sub-script";
describe("MathSubScriptElement", () => { describe("MathSubScriptElement", () => {
describe("#constructor()", () => { describe("#constructor()", () => {
it("should create a MathSubScriptElement with correct root key", () => { it("should create a MathSubScriptElement with correct root key", () => {
const mathSubScriptElement = new MathSubScriptElement(new MathRun("2+2")); const mathSubScriptElement = new MathSubScriptElement([new MathRun("2+2")]);
const tree = new Formatter().format(mathSubScriptElement); const tree = new Formatter().format(mathSubScriptElement);
expect(tree).to.deep.equal({ expect(tree).to.deep.equal({

View File

@ -4,9 +4,11 @@ import { XmlComponent } from "file/xml-components";
import { MathComponent } from "../math-component"; import { MathComponent } from "../math-component";
export class MathSubScriptElement extends XmlComponent { export class MathSubScriptElement extends XmlComponent {
constructor(child: MathComponent) { constructor(children: MathComponent[]) {
super("m:sub"); super("m:sub");
this.root.push(child); for (const child of children) {
this.root.push(child);
}
} }
} }

View File

@ -9,9 +9,9 @@ describe("MathSum", () => {
describe("#constructor()", () => { describe("#constructor()", () => {
it("should create a MathSum with correct root key", () => { it("should create a MathSum with correct root key", () => {
const mathSum = new MathSum({ const mathSum = new MathSum({
child: new MathRun("1"), children: [new MathRun("1")],
subScript: new MathRun("2"), subScript: [new MathRun("2")],
superScript: new MathRun("3"), superScript: [new MathRun("3")],
}); });
const tree = new Formatter().format(mathSum); const tree = new Formatter().format(mathSum);

View File

@ -8,9 +8,9 @@ import { MathSubScriptElement } from "./math-sub-script";
import { MathSuperScriptElement } from "./math-super-script"; import { MathSuperScriptElement } from "./math-super-script";
export interface IMathSumOptions { export interface IMathSumOptions {
readonly child: MathComponent; readonly children: MathComponent[];
readonly subScript?: MathComponent; readonly subScript?: MathComponent[];
readonly superScript?: MathComponent; readonly superScript?: MathComponent[];
} }
export class MathSum extends XmlComponent { export class MathSum extends XmlComponent {
@ -27,6 +27,6 @@ export class MathSum extends XmlComponent {
this.root.push(new MathSuperScriptElement(options.superScript)); this.root.push(new MathSuperScriptElement(options.superScript));
} }
this.root.push(new MathBase(options.child)); this.root.push(new MathBase(options.children));
} }
} }

View File

@ -8,7 +8,7 @@ import { MathSuperScriptElement } from "./math-super-script";
describe("MathSuperScriptElement", () => { describe("MathSuperScriptElement", () => {
describe("#constructor()", () => { describe("#constructor()", () => {
it("should create a MathSuperScriptElement with correct root key", () => { it("should create a MathSuperScriptElement with correct root key", () => {
const mathSuperScriptElement = new MathSuperScriptElement(new MathRun("2+2")); const mathSuperScriptElement = new MathSuperScriptElement([new MathRun("2+2")]);
const tree = new Formatter().format(mathSuperScriptElement); const tree = new Formatter().format(mathSuperScriptElement);
expect(tree).to.deep.equal({ expect(tree).to.deep.equal({

View File

@ -4,9 +4,11 @@ import { XmlComponent } from "file/xml-components";
import { MathComponent } from "../math-component"; import { MathComponent } from "../math-component";
export class MathSuperScriptElement extends XmlComponent { export class MathSuperScriptElement extends XmlComponent {
constructor(child: MathComponent) { constructor(children: MathComponent[]) {
super("m:sup"); super("m:sup");
this.root.push(child); for (const child of children) {
this.root.push(child);
}
} }
} }

View File

@ -17,7 +17,7 @@ describe("MathDegree", () => {
}); });
it("should create a MathDegree with correct root key with child", () => { it("should create a MathDegree with correct root key with child", () => {
const mathDegree = new MathDegree(new MathRun("2")); const mathDegree = new MathDegree([new MathRun("2")]);
const tree = new Formatter().format(mathDegree); const tree = new Formatter().format(mathDegree);
expect(tree).to.deep.equal({ expect(tree).to.deep.equal({

View File

@ -3,11 +3,13 @@ import { XmlComponent } from "file/xml-components";
import { MathComponent } from "../math-component"; import { MathComponent } from "../math-component";
export class MathDegree extends XmlComponent { export class MathDegree extends XmlComponent {
constructor(child?: MathComponent) { constructor(children?: MathComponent[]) {
super("m:deg"); super("m:deg");
if (!!child) { if (!!children) {
this.root.push(child); for (const child of children) {
this.root.push(child);
}
} }
} }
} }

View File

@ -9,8 +9,8 @@ describe("MathRadical", () => {
describe("#constructor()", () => { describe("#constructor()", () => {
it("should create a MathRadical with correct root key", () => { it("should create a MathRadical with correct root key", () => {
const mathRadical = new MathRadical({ const mathRadical = new MathRadical({
child: new MathRun("e"), children: [new MathRun("e")],
degree: new MathRun("2"), degree: [new MathRun("2")],
}); });
const tree = new Formatter().format(mathRadical); const tree = new Formatter().format(mathRadical);

View File

@ -7,8 +7,8 @@ import { MathDegree } from "./math-degree";
import { MathRadicalProperties } from "./math-radical-properties"; import { MathRadicalProperties } from "./math-radical-properties";
export interface IMathRadicalOptions { export interface IMathRadicalOptions {
readonly child: MathComponent; readonly children: MathComponent[];
readonly degree?: MathComponent; readonly degree?: MathComponent[];
} }
export class MathRadical extends XmlComponent { export class MathRadical extends XmlComponent {
@ -17,6 +17,6 @@ export class MathRadical extends XmlComponent {
this.root.push(new MathRadicalProperties(!!options.degree)); this.root.push(new MathRadicalProperties(!!options.degree));
this.root.push(new MathDegree(options.degree)); this.root.push(new MathDegree(options.degree));
this.root.push(new MathBase(options.child)); this.root.push(new MathBase(options.children));
} }
} }

View File

@ -9,9 +9,9 @@ describe("MathPreSubScript", () => {
describe("#constructor()", () => { describe("#constructor()", () => {
it("should create a MathPreSubScript with correct root key", () => { it("should create a MathPreSubScript with correct root key", () => {
const mathPreSubScript = new MathPreSubSuperScript({ const mathPreSubScript = new MathPreSubSuperScript({
child: new MathRun("e"), children: [new MathRun("e")],
subScript: new MathRun("2"), subScript: [new MathRun("2")],
superScript: new MathRun("5"), superScript: [new MathRun("5")],
}); });
const tree = new Formatter().format(mathPreSubScript); const tree = new Formatter().format(mathPreSubScript);

View File

@ -6,9 +6,9 @@ import { MathBase, MathSubScriptElement, MathSuperScriptElement } from "../../n-
import { MathPreSubSuperScriptProperties } from "./math-pre-sub-super-script-function-properties"; import { MathPreSubSuperScriptProperties } from "./math-pre-sub-super-script-function-properties";
export interface IMathPreSubSuperScriptOptions { export interface IMathPreSubSuperScriptOptions {
readonly child: MathComponent; readonly children: MathComponent[];
readonly subScript: MathComponent; readonly subScript: MathComponent[];
readonly superScript: MathComponent; readonly superScript: MathComponent[];
} }
export class MathPreSubSuperScript extends XmlComponent { export class MathPreSubSuperScript extends XmlComponent {
@ -16,7 +16,7 @@ export class MathPreSubSuperScript extends XmlComponent {
super("m:sPre"); super("m:sPre");
this.root.push(new MathPreSubSuperScriptProperties()); this.root.push(new MathPreSubSuperScriptProperties());
this.root.push(new MathBase(options.child)); this.root.push(new MathBase(options.children));
this.root.push(new MathSubScriptElement(options.subScript)); this.root.push(new MathSubScriptElement(options.subScript));
this.root.push(new MathSuperScriptElement(options.superScript)); this.root.push(new MathSuperScriptElement(options.superScript));
} }

View File

@ -9,8 +9,8 @@ describe("MathSubScript", () => {
describe("#constructor()", () => { describe("#constructor()", () => {
it("should create a MathSubScript with correct root key", () => { it("should create a MathSubScript with correct root key", () => {
const mathSubScript = new MathSubScript({ const mathSubScript = new MathSubScript({
child: new MathRun("e"), children: [new MathRun("e")],
subScript: new MathRun("2"), subScript: [new MathRun("2")],
}); });
const tree = new Formatter().format(mathSubScript); const tree = new Formatter().format(mathSubScript);

View File

@ -6,8 +6,8 @@ import { MathBase, MathSubScriptElement } from "../../n-ary";
import { MathSubScriptProperties } from "./math-sub-script-function-properties"; import { MathSubScriptProperties } from "./math-sub-script-function-properties";
export interface IMathSubScriptOptions { export interface IMathSubScriptOptions {
readonly child: MathComponent; readonly children: MathComponent[];
readonly subScript: MathComponent; readonly subScript: MathComponent[];
} }
export class MathSubScript extends XmlComponent { export class MathSubScript extends XmlComponent {
@ -15,7 +15,7 @@ export class MathSubScript extends XmlComponent {
super("m:sSub"); super("m:sSub");
this.root.push(new MathSubScriptProperties()); this.root.push(new MathSubScriptProperties());
this.root.push(new MathBase(options.child)); this.root.push(new MathBase(options.children));
this.root.push(new MathSubScriptElement(options.subScript)); this.root.push(new MathSubScriptElement(options.subScript));
} }
} }

View File

@ -9,9 +9,9 @@ describe("MathSubScript", () => {
describe("#constructor()", () => { describe("#constructor()", () => {
it("should create a MathSubScript with correct root key", () => { it("should create a MathSubScript with correct root key", () => {
const mathSubScript = new MathSubSuperScript({ const mathSubScript = new MathSubSuperScript({
child: new MathRun("e"), children: [new MathRun("e")],
subScript: new MathRun("2"), subScript: [new MathRun("2")],
superScript: new MathRun("5"), superScript: [new MathRun("5")],
}); });
const tree = new Formatter().format(mathSubScript); const tree = new Formatter().format(mathSubScript);

View File

@ -6,9 +6,9 @@ import { MathBase, MathSubScriptElement, MathSuperScriptElement } from "../../n-
import { MathSubSuperScriptProperties } from "./math-sub-super-script-function-properties"; import { MathSubSuperScriptProperties } from "./math-sub-super-script-function-properties";
export interface IMathSubSuperScriptOptions { export interface IMathSubSuperScriptOptions {
readonly child: MathComponent; readonly children: MathComponent[];
readonly subScript: MathComponent; readonly subScript: MathComponent[];
readonly superScript: MathComponent; readonly superScript: MathComponent[];
} }
export class MathSubSuperScript extends XmlComponent { export class MathSubSuperScript extends XmlComponent {
@ -16,7 +16,7 @@ export class MathSubSuperScript extends XmlComponent {
super("m:sSubSup"); super("m:sSubSup");
this.root.push(new MathSubSuperScriptProperties()); this.root.push(new MathSubSuperScriptProperties());
this.root.push(new MathBase(options.child)); this.root.push(new MathBase(options.children));
this.root.push(new MathSubScriptElement(options.subScript)); this.root.push(new MathSubScriptElement(options.subScript));
this.root.push(new MathSuperScriptElement(options.superScript)); this.root.push(new MathSuperScriptElement(options.superScript));
} }

View File

@ -9,8 +9,8 @@ describe("MathSuperScript", () => {
describe("#constructor()", () => { describe("#constructor()", () => {
it("should create a MathSuperScript with correct root key", () => { it("should create a MathSuperScript with correct root key", () => {
const mathSuperScript = new MathSuperScript({ const mathSuperScript = new MathSuperScript({
child: new MathRun("e"), children: [new MathRun("e")],
superScript: new MathRun("2"), superScript: [new MathRun("2")],
}); });
const tree = new Formatter().format(mathSuperScript); const tree = new Formatter().format(mathSuperScript);

View File

@ -6,8 +6,8 @@ import { MathBase, MathSuperScriptElement } from "../../n-ary";
import { MathSuperScriptProperties } from "./math-super-script-function-properties"; import { MathSuperScriptProperties } from "./math-super-script-function-properties";
export interface IMathSuperScriptOptions { export interface IMathSuperScriptOptions {
readonly child: MathComponent; readonly children: MathComponent[];
readonly superScript: MathComponent; readonly superScript: MathComponent[];
} }
export class MathSuperScript extends XmlComponent { export class MathSuperScript extends XmlComponent {
@ -15,7 +15,7 @@ export class MathSuperScript extends XmlComponent {
super("m:sSup"); super("m:sSup");
this.root.push(new MathSuperScriptProperties()); this.root.push(new MathSuperScriptProperties());
this.root.push(new MathBase(options.child)); this.root.push(new MathBase(options.children));
this.root.push(new MathSuperScriptElement(options.superScript)); this.root.push(new MathSuperScriptElement(options.superScript));
} }
} }