mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-06 11:48:41 +00:00
Add a maxSize option to limit user-specified sizes (#803)
* Fix color support for stretchy, strikethrough, and fbox Summary: Stuff like `\red{\overbrace{AB}}` works now in addition to `\color{red}{\overbrace{AB}}`. Strikethrough now respects color. The Firefox in the screenshotter doesn't seem to support `background-image` + `mask`, but I manually tested that the latest Firefox does. Test plan: Ran `make`, then tested in latest Chrome and Firefox to ensure color support was working, then ran `make screenshots`. * Add a maxSize option to limit user-specified sizes (#109) * Simplify maxSize logic and add unit test * Clamp negative maxSize to zero * Use a default maxSize of infinity to remove branching in calculateSize
This commit is contained in:
committed by
Kevin Barabash
parent
b27d7011d1
commit
211c86d39b
@@ -2308,3 +2308,25 @@ describe("Unicode", function() {
|
||||
expect("ΓΔΘΞΠΣΦΨΩ").toParse();
|
||||
});
|
||||
});
|
||||
|
||||
describe("The maxSize setting", function() {
|
||||
const rule = "\\rule{999em}{999em}";
|
||||
|
||||
it("should clamp size when set", function() {
|
||||
const built = getBuilt(rule, new Settings({maxSize: 5}))[0];
|
||||
expect(built.style.borderRightWidth).toEqual("5em");
|
||||
expect(built.style.borderTopWidth).toEqual("5em");
|
||||
});
|
||||
|
||||
it("should not clamp size when not set", function() {
|
||||
const built = getBuilt(rule)[0];
|
||||
expect(built.style.borderRightWidth).toEqual("999em");
|
||||
expect(built.style.borderTopWidth).toEqual("999em");
|
||||
});
|
||||
|
||||
it("should make zero-width rules if a negative maxSize is passed", function() {
|
||||
const built = getBuilt(rule, new Settings({maxSize: -5}))[0];
|
||||
expect(built.style.borderRightWidth).toEqual("0em");
|
||||
expect(built.style.borderTopWidth).toEqual("0em");
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user