mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-10 13:38:39 +00:00
fix: Avoid crash when \operatorname has \limits (#2979)
This commit is contained in:
@@ -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",
|
||||||
|
@@ -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();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user