fix: Avoid crash when \operatorname has \limits (#2979)

This commit is contained in:
Ron Kok
2021-05-02 12:47:22 -07:00
committed by GitHub
parent 19e0b66639
commit fbda0b1136
2 changed files with 6 additions and 4 deletions

View File

@@ -326,10 +326,10 @@ export default class Parser {
const limits = lex.text === "\\limits"; const limits = lex.text === "\\limits";
base.limits = limits; base.limits = limits;
base.alwaysHandleSupSub = true; base.alwaysHandleSupSub = true;
} else if (base && base.type === "operatorname" } else if (base && base.type === "operatorname") {
&& base.alwaysHandleSupSub) { if (base.alwaysHandleSupSub) {
const limits = lex.text === "\\limits"; base.limits = lex.text === "\\limits";
base.limits = limits; }
} else { } else {
throw new ParseError( throw new ParseError(
"Limit controls must follow a math operator", "Limit controls must follow a math operator",

View File

@@ -2852,6 +2852,8 @@ describe("operatorname support", function() {
expect("\\operatorname*{x*Π∑\\Pi\\sum\\frac a b}").toBuild(); expect("\\operatorname*{x*Π∑\\Pi\\sum\\frac a b}").toBuild();
expect("\\operatorname*{x*Π∑\\Pi\\sum\\frac a b}_y x").toBuild(); expect("\\operatorname*{x*Π∑\\Pi\\sum\\frac a b}_y x").toBuild();
expect("\\operatorname*{x*Π∑\\Pi\\sum\\frac a b}\\limits_y x").toBuild(); expect("\\operatorname*{x*Π∑\\Pi\\sum\\frac a b}\\limits_y x").toBuild();
// The following does not actually render with limits. But it does not crash either.
expect("\\operatorname{sn}\\limits_{b>c}(b+c)").toBuild();
}); });
}); });