Support \genfrac and \above (#1458)

* Support \genfrac and \above

* Accommodate delimiters inside groups

* Update screenshots take one`

* Update screenshots take two

* Fix flow error

* Fix lint error
This commit is contained in:
Ron Kok
2018-07-07 17:01:37 -07:00
committed by Kevin Barabash
parent 0fb71c8bf8
commit db585fae54
7 changed files with 207 additions and 7 deletions

View File

@@ -428,6 +428,8 @@ describe("A frac parser", function() {
const dfracExpression = "\\dfrac{x}{y}";
const tfracExpression = "\\tfrac{x}{y}";
const cfracExpression = "\\cfrac{x}{y}";
const genfrac1 = "\\genfrac ( ] {0.06em}{0}{a}{b+c}";
const genfrac2 = "\\genfrac ( ] {0.8pt}{}{a}{b+c}";
it("should not fail", function() {
expect(expression).toParse();
@@ -441,13 +443,15 @@ describe("A frac parser", function() {
expect(parse.value.denom).toBeDefined();
});
it("should also parse dfrac and tfrac", function() {
it("should also parse cfrac, dfrac, tfrac, and genfrac", function() {
expect(cfracExpression).toParse();
expect(dfracExpression).toParse();
expect(tfracExpression).toParse();
expect(genfrac1).toParse();
expect(genfrac2).toParse();
});
it("should parse dfrac and tfrac as fracs", function() {
it("should parse cfrac, dfrac, tfrac, and genfrac as fracs", function() {
const dfracParse = getParsed(dfracExpression)[0];
expect(dfracParse.type).toEqual("genfrac");
@@ -465,6 +469,24 @@ describe("A frac parser", function() {
expect(cfracParse.type).toEqual("genfrac");
expect(cfracParse.value.numer).toBeDefined();
expect(cfracParse.value.denom).toBeDefined();
const genfracParse = getParsed(genfrac1)[0];
expect(genfracParse.type).toEqual("genfrac");
expect(genfracParse.value.numer).toBeDefined();
expect(genfracParse.value.denom).toBeDefined();
expect(genfracParse.value.leftDelim).toBeDefined();
expect(genfracParse.value.rightDelim).toBeDefined();
});
it("should fail, given math as a line thickness to genfrac", function() {
const badGenFrac = "\\genfrac ( ] {b+c}{0}{a}{b+c}";
expect(badGenFrac).toNotParse();
});
it("should fail if genfrac is given less than 6 arguments", function() {
const badGenFrac = "\\genfrac ( ] {0.06em}{0}{a}";
expect(badGenFrac).toNotParse();
});
it("should parse atop", function() {
@@ -587,6 +609,17 @@ describe("An over/brace/brack parser", function() {
});
});
describe("A genfrac builder", function() {
it("should not fail", function() {
expect("\\frac{x}{y}").toBuild();
expect("\\dfrac{x}{y}").toBuild();
expect("\\tfrac{x}{y}").toBuild();
expect("\\cfrac{x}{y}").toBuild();
expect("\\genfrac ( ] {0.06em}{0}{a}{b+c}").toBuild();
expect("\\genfrac ( ] {0.8pt}{}{a}{b+c}").toBuild();
});
});
describe("A infix builder", function() {
it("should not fail", function() {
expect("a \\over b").toBuild();