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:
Xuming Zeng
2017-08-31 05:39:28 -05:00
committed by Kevin Barabash
parent b27d7011d1
commit 211c86d39b
6 changed files with 28 additions and 1 deletions

View File

@@ -51,6 +51,7 @@ class Options {
this.phantom = data.phantom;
this.font = data.font;
this.sizeMultiplier = sizeMultipliers[this.size - 1];
this.maxSize = data.maxSize;
this._fontMetrics = null;
}
@@ -66,6 +67,7 @@ class Options {
color: this.color,
phantom: this.phantom,
font: this.font,
maxSize: this.maxSize,
};
for (const key in extension) {

View File

@@ -24,6 +24,7 @@ class Settings {
this.errorColor = utils.deflt(options.errorColor, "#cc0000");
this.macros = options.macros || {};
this.colorIsTextColor = utils.deflt(options.colorIsTextColor, false);
this.maxSize = Math.max(0, utils.deflt(options.maxSize, Infinity));
}
}

View File

@@ -16,6 +16,7 @@ const buildTree = function(tree, expression, settings) {
// Setup the default options
const options = new Options({
style: startStyle,
maxSize: settings.maxSize,
});
// `buildHTML` sometimes messes with the parse tree (like turning bins ->

View File

@@ -90,7 +90,7 @@ const calculateSize = function(sizeValue, options) {
scale *= unitOptions.sizeMultiplier / options.sizeMultiplier;
}
}
return sizeValue.number * scale;
return Math.min(sizeValue.number * scale, options.maxSize);
};
module.exports = {