Add \choose support
Test Plan: Looked at `1 + 2\choose {3 \over 4}`, npm tested. Reviewers: emily Reviewed By: emily Differential Revision: http://phabricator.khanacademy.org/D13903
This commit is contained in:
parent
006a0a761c
commit
2cbee18010
|
@ -164,16 +164,6 @@ var functions = {
|
|||
type: "katex"
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
"\\over": {
|
||||
numArgs: 0,
|
||||
handler: function (func) {
|
||||
return {
|
||||
type: "infix",
|
||||
replaceWith: "\\frac"
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -477,6 +467,31 @@ var duplicatedFunctions = [
|
|||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Infix generalized fractions
|
||||
{
|
||||
funcs: ["\\over", "\\choose"],
|
||||
data: {
|
||||
numArgs: 0,
|
||||
handler: function (func) {
|
||||
var replaceWith;
|
||||
switch (func) {
|
||||
case "\\over":
|
||||
replaceWith = "\\frac";
|
||||
break;
|
||||
case "\\choose":
|
||||
replaceWith = "\\binom";
|
||||
break;
|
||||
default:
|
||||
throw new Error("Unrecognized infix genfrac command");
|
||||
}
|
||||
return {
|
||||
type: "infix",
|
||||
replaceWith: replaceWith
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
|
|
|
@ -559,6 +559,9 @@ describe("An over parser", function() {
|
|||
it("should fail with multiple overs in the same group", function () {
|
||||
var badMultipleOvers = "1 \\over 2 + 3 \\over 4";
|
||||
expect(badMultipleOvers).toNotParse();
|
||||
|
||||
var badOverChoose = "1 \\over 2 \\choose 3";
|
||||
expect(badOverChoose).toNotParse();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user