Upgrade Katex to v0.16.10

This commit is contained in:
Will Faught
2024-04-06 17:58:45 -07:00
parent d0a44bcda1
commit 0e0df96c29
32 changed files with 3806 additions and 3525 deletions

View File

@@ -245,6 +245,18 @@ export default class MacroExpander implements MacroContextInterface {
return args;
}
/**
* Increment `expansionCount` by the specified amount.
* Throw an error if it exceeds `maxExpand`.
*/
countExpansion(amount: number): void {
this.expansionCount += amount;
if (this.expansionCount > this.settings.maxExpand) {
throw new ParseError("Too many expansions: infinite loop or " +
"need to increase maxExpand setting");
}
}
/**
* Expand the next token only once if possible.
*
@@ -276,11 +288,7 @@ export default class MacroExpander implements MacroContextInterface {
this.pushToken(topToken);
return false;
}
this.expansionCount++;
if (this.expansionCount > this.settings.maxExpand) {
throw new ParseError("Too many expansions: infinite loop or " +
"need to increase maxExpand setting");
}
this.countExpansion(1);
let tokens = expansion.tokens;
const args = this.consumeArgs(expansion.numArgs, expansion.delimiters);
if (expansion.numArgs) {
@@ -375,6 +383,9 @@ export default class MacroExpander implements MacroContextInterface {
output.push(token);
}
}
// Count all of these tokens as additional expansions, to prevent
// exponential blowup from linearly many \edef's.
this.countExpansion(output.length);
return output;
}