mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-08 12:38:39 +00:00
Move infix operator handling into functions/genfrac.js. (#1328)
This commit is contained in:
committed by
Kevin Barabash
parent
5aad11eff3
commit
fabae7c658
@@ -118,32 +118,6 @@ defineFunction("xArrow", [
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
// Infix generalized fractions
|
|
||||||
defineFunction("infix", ["\\over", "\\choose", "\\atop"], {
|
|
||||||
numArgs: 0,
|
|
||||||
infix: true,
|
|
||||||
}, function(context) {
|
|
||||||
let replaceWith;
|
|
||||||
switch (context.funcName) {
|
|
||||||
case "\\over":
|
|
||||||
replaceWith = "\\frac";
|
|
||||||
break;
|
|
||||||
case "\\choose":
|
|
||||||
replaceWith = "\\binom";
|
|
||||||
break;
|
|
||||||
case "\\atop":
|
|
||||||
replaceWith = "\\\\atopfrac";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error("Unrecognized infix genfrac command");
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
type: "infix",
|
|
||||||
replaceWith: replaceWith,
|
|
||||||
token: context.token,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
// Row and line breaks
|
// Row and line breaks
|
||||||
import "./functions/cr";
|
import "./functions/cr";
|
||||||
|
|
||||||
|
@@ -251,3 +251,36 @@ defineFunction({
|
|||||||
return node;
|
return node;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Infix generalized fractions -- these are not rendered directly, but replaced
|
||||||
|
// immediately by one of the variants above.
|
||||||
|
defineFunction({
|
||||||
|
type: "infix",
|
||||||
|
names: ["\\over", "\\choose", "\\atop"],
|
||||||
|
props: {
|
||||||
|
numArgs: 0,
|
||||||
|
infix: true,
|
||||||
|
},
|
||||||
|
handler(context) {
|
||||||
|
let replaceWith;
|
||||||
|
switch (context.funcName) {
|
||||||
|
case "\\over":
|
||||||
|
replaceWith = "\\frac";
|
||||||
|
break;
|
||||||
|
case "\\choose":
|
||||||
|
replaceWith = "\\binom";
|
||||||
|
break;
|
||||||
|
case "\\atop":
|
||||||
|
replaceWith = "\\\\atopfrac";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Error("Unrecognized infix genfrac command");
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
type: "infix",
|
||||||
|
replaceWith: replaceWith,
|
||||||
|
token: context.token,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user