mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-06 11:48:41 +00:00
Move the rest of the ops from functions.js to functions/ops.js. (#1323)
This commit is contained in:
@@ -118,68 +118,6 @@ defineFunction("mclass", ["\\stackrel", "\\overset", "\\underset"], {
|
|||||||
|
|
||||||
import "./functions/mod";
|
import "./functions/mod";
|
||||||
|
|
||||||
const singleCharIntegrals: {[string]: string} = {
|
|
||||||
"\u222b": "\\int",
|
|
||||||
"\u222c": "\\iint",
|
|
||||||
"\u222d": "\\iiint",
|
|
||||||
"\u222e": "\\oint",
|
|
||||||
};
|
|
||||||
|
|
||||||
// There are 2 flags for operators; whether they produce limits in
|
|
||||||
// displaystyle, and whether they are symbols and should grow in
|
|
||||||
// displaystyle. These four groups cover the four possible choices.
|
|
||||||
|
|
||||||
// No limits, not symbols
|
|
||||||
defineFunction("op", [
|
|
||||||
"\\arcsin", "\\arccos", "\\arctan", "\\arctg", "\\arcctg",
|
|
||||||
"\\arg", "\\ch", "\\cos", "\\cosec", "\\cosh", "\\cot", "\\cotg",
|
|
||||||
"\\coth", "\\csc", "\\ctg", "\\cth", "\\deg", "\\dim", "\\exp",
|
|
||||||
"\\hom", "\\ker", "\\lg", "\\ln", "\\log", "\\sec", "\\sin",
|
|
||||||
"\\sinh", "\\sh", "\\tan", "\\tanh", "\\tg", "\\th",
|
|
||||||
], {
|
|
||||||
numArgs: 0,
|
|
||||||
}, function(context) {
|
|
||||||
return {
|
|
||||||
type: "op",
|
|
||||||
limits: false,
|
|
||||||
symbol: false,
|
|
||||||
body: context.funcName,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
// Limits, not symbols
|
|
||||||
defineFunction("op", [
|
|
||||||
"\\det", "\\gcd", "\\inf", "\\lim", "\\max", "\\min", "\\Pr", "\\sup",
|
|
||||||
], {
|
|
||||||
numArgs: 0,
|
|
||||||
}, function(context) {
|
|
||||||
return {
|
|
||||||
type: "op",
|
|
||||||
limits: true,
|
|
||||||
symbol: false,
|
|
||||||
body: context.funcName,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
// No limits, symbols
|
|
||||||
defineFunction("op", [
|
|
||||||
"\\int", "\\iint", "\\iiint", "\\oint", "\u222b", "\u222c",
|
|
||||||
"\u222d", "\u222e",
|
|
||||||
], {
|
|
||||||
numArgs: 0,
|
|
||||||
}, function(context) {
|
|
||||||
let fName = context.funcName;
|
|
||||||
if (fName.length === 1) {
|
|
||||||
fName = singleCharIntegrals[fName];
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
type: "op",
|
|
||||||
limits: false,
|
|
||||||
symbol: true,
|
|
||||||
body: fName,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
import "./functions/op";
|
import "./functions/op";
|
||||||
|
|
||||||
import "./functions/operatorname";
|
import "./functions/operatorname";
|
||||||
|
@@ -285,3 +285,105 @@ defineFunction({
|
|||||||
htmlBuilder,
|
htmlBuilder,
|
||||||
mathmlBuilder,
|
mathmlBuilder,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// There are 2 flags for operators; whether they produce limits in
|
||||||
|
// displaystyle, and whether they are symbols and should grow in
|
||||||
|
// displaystyle. These four groups cover the four possible choices.
|
||||||
|
|
||||||
|
const singleCharIntegrals: {[string]: string} = {
|
||||||
|
"\u222b": "\\int",
|
||||||
|
"\u222c": "\\iint",
|
||||||
|
"\u222d": "\\iiint",
|
||||||
|
"\u222e": "\\oint",
|
||||||
|
};
|
||||||
|
|
||||||
|
defineFunction({
|
||||||
|
type: "op",
|
||||||
|
names: ["\\mathop"],
|
||||||
|
props: {
|
||||||
|
numArgs: 1,
|
||||||
|
},
|
||||||
|
handler: (context, args) => {
|
||||||
|
const body = args[0];
|
||||||
|
return {
|
||||||
|
type: "op",
|
||||||
|
limits: false,
|
||||||
|
symbol: false,
|
||||||
|
value: ordargument(body),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
htmlBuilder,
|
||||||
|
mathmlBuilder,
|
||||||
|
});
|
||||||
|
|
||||||
|
// No limits, not symbols
|
||||||
|
defineFunction({
|
||||||
|
type: "op",
|
||||||
|
names: [
|
||||||
|
"\\arcsin", "\\arccos", "\\arctan", "\\arctg", "\\arcctg",
|
||||||
|
"\\arg", "\\ch", "\\cos", "\\cosec", "\\cosh", "\\cot", "\\cotg",
|
||||||
|
"\\coth", "\\csc", "\\ctg", "\\cth", "\\deg", "\\dim", "\\exp",
|
||||||
|
"\\hom", "\\ker", "\\lg", "\\ln", "\\log", "\\sec", "\\sin",
|
||||||
|
"\\sinh", "\\sh", "\\tan", "\\tanh", "\\tg", "\\th",
|
||||||
|
],
|
||||||
|
props: {
|
||||||
|
numArgs: 0,
|
||||||
|
},
|
||||||
|
handler(context) {
|
||||||
|
return {
|
||||||
|
type: "op",
|
||||||
|
limits: false,
|
||||||
|
symbol: false,
|
||||||
|
body: context.funcName,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
htmlBuilder,
|
||||||
|
mathmlBuilder,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Limits, not symbols
|
||||||
|
defineFunction({
|
||||||
|
type: "op",
|
||||||
|
names: [
|
||||||
|
"\\det", "\\gcd", "\\inf", "\\lim", "\\max", "\\min", "\\Pr", "\\sup",
|
||||||
|
],
|
||||||
|
props: {
|
||||||
|
numArgs: 0,
|
||||||
|
},
|
||||||
|
handler(context) {
|
||||||
|
return {
|
||||||
|
type: "op",
|
||||||
|
limits: true,
|
||||||
|
symbol: false,
|
||||||
|
body: context.funcName,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
htmlBuilder,
|
||||||
|
mathmlBuilder,
|
||||||
|
});
|
||||||
|
|
||||||
|
// No limits, symbols
|
||||||
|
defineFunction({
|
||||||
|
type: "op",
|
||||||
|
names: [
|
||||||
|
"\\int", "\\iint", "\\iiint", "\\oint", "\u222b", "\u222c",
|
||||||
|
"\u222d", "\u222e",
|
||||||
|
],
|
||||||
|
props: {
|
||||||
|
numArgs: 0,
|
||||||
|
},
|
||||||
|
handler(context) {
|
||||||
|
let fName = context.funcName;
|
||||||
|
if (fName.length === 1) {
|
||||||
|
fName = singleCharIntegrals[fName];
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
type: "op",
|
||||||
|
limits: false,
|
||||||
|
symbol: true,
|
||||||
|
body: fName,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
htmlBuilder,
|
||||||
|
mathmlBuilder,
|
||||||
|
});
|
||||||
|
Reference in New Issue
Block a user