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";
base.limits = limits;
base.alwaysHandleSupSub = true;
} else if (base && base.type === "operatorname"
&& base.alwaysHandleSupSub) {
const limits = lex.text === "\\limits";
base.limits = limits;
} else if (base && base.type === "operatorname") {
if (base.alwaysHandleSupSub) {
base.limits = lex.text === "\\limits";
}
} else {
throw new ParseError(
"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}_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();
});
});