Move the rest of the ops from functions.js to functions/ops.js. (#1323)

This commit is contained in:
Ashish Myles
2018-05-18 09:59:03 -04:00
committed by GitHub
parent 7b22eeb64a
commit 73e0c13d10
2 changed files with 102 additions and 62 deletions

View File

@@ -118,68 +118,6 @@ defineFunction("mclass", ["\\stackrel", "\\overset", "\\underset"], {
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/operatorname";

View File

@@ -285,3 +285,105 @@ defineFunction({
htmlBuilder,
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,
});