mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-05 19:28:39 +00:00
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:
BIN
test/huxley/DelimiterSizing.hux/firefox-1.png
Normal file
BIN
test/huxley/DelimiterSizing.hux/firefox-1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
5
test/huxley/DelimiterSizing.hux/record.json
Normal file
5
test/huxley/DelimiterSizing.hux/record.json
Normal file
@@ -0,0 +1,5 @@
|
||||
[
|
||||
{
|
||||
"action": "screenshot"
|
||||
}
|
||||
]
|
@@ -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"
|
||||
}
|
||||
]
|
||||
|
@@ -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);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user