Add delimiter sizing

Summary:
Make delimiter sizing work. This involved
 - Adding the symbols for the remaining delimiters (like `\lfloor` and `\{`)
 - Adding metrics for the size1, size2, size3, and size4 fonts
 - Parsing delimiter sizing functions
 - Using the big fonts when possible, otherwise building large copies of the
   delimiters from scratch

Test Plan:
 - See that
   `\bigl\uparrow\Bigl\downarrow\biggl\updownarrow\Biggl\Uparrow
    \Biggr\Downarrow\biggr\Updownarrow\bigm/\Bigm\backslash\biggm|
    \Biggm|\big\lceil\Big\rceil\bigg\langle\Bigg\rangle\bigl(\Bigl)
    \biggl[\Biggl]\Biggr\{\biggr\}\Bigr\lfloor\bigr\rfloor`
   parses correctly (this contains all of the delimiters, and all of the sizing
   modes)
 - See that the huxley tests didn't change, and the new one looks good
 - See the normal tests work

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D7844
This commit is contained in:
Emily Eisenberg
2014-08-05 16:43:43 -07:00
parent 07e8d468de
commit 100798847b
10 changed files with 446 additions and 38 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -0,0 +1,5 @@
[
{
"action": "screenshot"
}
]

View File

@@ -93,5 +93,11 @@
"name": "Lap",
"screenSize": [1024, 768],
"url": "http://localhost:7936/test/huxley/test.html?m=ab\\llap{f}cd\\rlap{g}h"
},
{
"name": "DelimiterSizing",
"screenSize": [1024, 768],
"url": "http://localhost:7936/test/huxley/test.html?m=\\bigl\\uparrow\\Bigl\\downarrow\\biggl\\updownarrow\\Biggl\\Uparrow\\Biggr\\Downarrow\\biggr\\langle\\Bigr\\}\\bigr\\rfloor"
}
]

View File

@@ -626,3 +626,44 @@ describe("A tie parser", function() {
expect(parse[2].type).toMatch("spacing");
});
});
describe("A delimiter sizing parser", function() {
var normalDelim = "\\bigl |";
var notDelim = "\\bigl x";
var bigDelim = "\\Biggr \\langle";
it("should parse normal delimiters", function() {
expect(function() {
parseTree(normalDelim);
parseTree(bigDelim);
}).not.toThrow();
});
it("should not parse not-delimiters", function() {
expect(function() {
parseTree(notDelim);
}).toThrow();
});
it("should produce a delimsizing", function() {
var parse = parseTree(normalDelim)[0];
expect(parse.type).toMatch("delimsizing");
});
it("should produce the correct direction delimiter", function() {
var leftParse = parseTree(normalDelim)[0];
var rightParse = parseTree(bigDelim)[0];
expect(leftParse.value.type).toMatch("open");
expect(rightParse.value.type).toMatch("close");
});
it("should parse the correct size delimiter", function() {
var smallParse = parseTree(normalDelim)[0];
var bigParse = parseTree(bigDelim)[0];
expect(smallParse.value.size).toEqual(1);
expect(bigParse.value.size).toEqual(4);
});
});