Rename declareFunction to defineFunction
https://github.com/Khan/KaTeX/pull/262#issuecomment-113981142 indicated a preference for define over declare.
This commit is contained in:
parent
3e055f84e9
commit
acfdc9f698
|
@ -74,7 +74,7 @@ var ParseError = require("./ParseError");
|
||||||
* in to the function in buildHTML/buildMathML as `group.value`.
|
* in to the function in buildHTML/buildMathML as `group.value`.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function declareFunction(names, props, handler) {
|
function defineFunction(names, props, handler) {
|
||||||
if (typeof names === "string") {
|
if (typeof names === "string") {
|
||||||
names = [names];
|
names = [names];
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ function declareFunction(names, props, handler) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// A normal square root
|
// A normal square root
|
||||||
declareFunction("\\sqrt", {
|
defineFunction("\\sqrt", {
|
||||||
numArgs: 1,
|
numArgs: 1,
|
||||||
numOptionalArgs: 1
|
numOptionalArgs: 1
|
||||||
}, function(func, index, body, positions) {
|
}, function(func, index, body, positions) {
|
||||||
|
@ -108,7 +108,7 @@ declareFunction("\\sqrt", {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Some non-mathy text
|
// Some non-mathy text
|
||||||
declareFunction("\\text", {
|
defineFunction("\\text", {
|
||||||
numArgs: 1,
|
numArgs: 1,
|
||||||
argTypes: ["text"],
|
argTypes: ["text"],
|
||||||
greediness: 2
|
greediness: 2
|
||||||
|
@ -130,7 +130,7 @@ declareFunction("\\text", {
|
||||||
});
|
});
|
||||||
|
|
||||||
// A two-argument custom color
|
// A two-argument custom color
|
||||||
declareFunction("\\color", {
|
defineFunction("\\color", {
|
||||||
numArgs: 2,
|
numArgs: 2,
|
||||||
allowedInText: true,
|
allowedInText: true,
|
||||||
greediness: 3,
|
greediness: 3,
|
||||||
|
@ -152,7 +152,7 @@ declareFunction("\\color", {
|
||||||
});
|
});
|
||||||
|
|
||||||
// An overline
|
// An overline
|
||||||
declareFunction("\\overline", {
|
defineFunction("\\overline", {
|
||||||
numArgs: 1
|
numArgs: 1
|
||||||
}, function(func, body) {
|
}, function(func, body) {
|
||||||
return {
|
return {
|
||||||
|
@ -162,7 +162,7 @@ declareFunction("\\overline", {
|
||||||
});
|
});
|
||||||
|
|
||||||
// A box of the width and height
|
// A box of the width and height
|
||||||
declareFunction("\\rule", {
|
defineFunction("\\rule", {
|
||||||
numArgs: 2,
|
numArgs: 2,
|
||||||
numOptionalArgs: 1,
|
numOptionalArgs: 1,
|
||||||
argTypes: ["size", "size", "size"]
|
argTypes: ["size", "size", "size"]
|
||||||
|
@ -176,7 +176,7 @@ declareFunction("\\rule", {
|
||||||
});
|
});
|
||||||
|
|
||||||
// A KaTeX logo
|
// A KaTeX logo
|
||||||
declareFunction("\\KaTeX", {
|
defineFunction("\\KaTeX", {
|
||||||
numArgs: 0
|
numArgs: 0
|
||||||
}, function(func) {
|
}, function(func) {
|
||||||
return {
|
return {
|
||||||
|
@ -184,7 +184,7 @@ declareFunction("\\KaTeX", {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
declareFunction("\\phantom", {
|
defineFunction("\\phantom", {
|
||||||
numArgs: 1
|
numArgs: 1
|
||||||
}, function(func, body) {
|
}, function(func, body) {
|
||||||
var inner;
|
var inner;
|
||||||
|
@ -242,7 +242,7 @@ var fontAliases = {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Single-argument color functions
|
// Single-argument color functions
|
||||||
declareFunction([
|
defineFunction([
|
||||||
"\\blue", "\\orange", "\\pink", "\\red",
|
"\\blue", "\\orange", "\\pink", "\\red",
|
||||||
"\\green", "\\gray", "\\purple",
|
"\\green", "\\gray", "\\purple",
|
||||||
"\\blueA", "\\blueB", "\\blueC", "\\blueD", "\\blueE",
|
"\\blueA", "\\blueB", "\\blueC", "\\blueD", "\\blueE",
|
||||||
|
@ -280,7 +280,7 @@ declareFunction([
|
||||||
// displaystyle. These four groups cover the four possible choices.
|
// displaystyle. These four groups cover the four possible choices.
|
||||||
|
|
||||||
// No limits, not symbols
|
// No limits, not symbols
|
||||||
declareFunction([
|
defineFunction([
|
||||||
"\\arcsin", "\\arccos", "\\arctan", "\\arg", "\\cos", "\\cosh",
|
"\\arcsin", "\\arccos", "\\arctan", "\\arg", "\\cos", "\\cosh",
|
||||||
"\\cot", "\\coth", "\\csc", "\\deg", "\\dim", "\\exp", "\\hom",
|
"\\cot", "\\coth", "\\csc", "\\deg", "\\dim", "\\exp", "\\hom",
|
||||||
"\\ker", "\\lg", "\\ln", "\\log", "\\sec", "\\sin", "\\sinh",
|
"\\ker", "\\lg", "\\ln", "\\log", "\\sec", "\\sin", "\\sinh",
|
||||||
|
@ -297,7 +297,7 @@ declareFunction([
|
||||||
});
|
});
|
||||||
|
|
||||||
// Limits, not symbols
|
// Limits, not symbols
|
||||||
declareFunction([
|
defineFunction([
|
||||||
"\\det", "\\gcd", "\\inf", "\\lim", "\\liminf", "\\limsup", "\\max",
|
"\\det", "\\gcd", "\\inf", "\\lim", "\\liminf", "\\limsup", "\\max",
|
||||||
"\\min", "\\Pr", "\\sup"
|
"\\min", "\\Pr", "\\sup"
|
||||||
], {
|
], {
|
||||||
|
@ -312,7 +312,7 @@ declareFunction([
|
||||||
});
|
});
|
||||||
|
|
||||||
// No limits, symbols
|
// No limits, symbols
|
||||||
declareFunction([
|
defineFunction([
|
||||||
"\\int", "\\iint", "\\iiint", "\\oint"
|
"\\int", "\\iint", "\\iiint", "\\oint"
|
||||||
], {
|
], {
|
||||||
numArgs: 0
|
numArgs: 0
|
||||||
|
@ -326,7 +326,7 @@ declareFunction([
|
||||||
});
|
});
|
||||||
|
|
||||||
// Limits, symbols
|
// Limits, symbols
|
||||||
declareFunction([
|
defineFunction([
|
||||||
"\\coprod", "\\bigvee", "\\bigwedge", "\\biguplus", "\\bigcap",
|
"\\coprod", "\\bigvee", "\\bigwedge", "\\biguplus", "\\bigcap",
|
||||||
"\\bigcup", "\\intop", "\\prod", "\\sum", "\\bigotimes",
|
"\\bigcup", "\\intop", "\\prod", "\\sum", "\\bigotimes",
|
||||||
"\\bigoplus", "\\bigodot", "\\bigsqcup", "\\smallint"
|
"\\bigoplus", "\\bigodot", "\\bigsqcup", "\\smallint"
|
||||||
|
@ -342,7 +342,7 @@ declareFunction([
|
||||||
});
|
});
|
||||||
|
|
||||||
// Fractions
|
// Fractions
|
||||||
declareFunction([
|
defineFunction([
|
||||||
"\\dfrac", "\\frac", "\\tfrac",
|
"\\dfrac", "\\frac", "\\tfrac",
|
||||||
"\\dbinom", "\\binom", "\\tbinom"
|
"\\dbinom", "\\binom", "\\tbinom"
|
||||||
], {
|
], {
|
||||||
|
@ -394,7 +394,7 @@ declareFunction([
|
||||||
});
|
});
|
||||||
|
|
||||||
// Left and right overlap functions
|
// Left and right overlap functions
|
||||||
declareFunction(["\\llap", "\\rlap"], {
|
defineFunction(["\\llap", "\\rlap"], {
|
||||||
numArgs: 1,
|
numArgs: 1,
|
||||||
allowedInText: true
|
allowedInText: true
|
||||||
}, function(func, body) {
|
}, function(func, body) {
|
||||||
|
@ -405,7 +405,7 @@ declareFunction(["\\llap", "\\rlap"], {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Delimiter functions
|
// Delimiter functions
|
||||||
declareFunction([
|
defineFunction([
|
||||||
"\\bigl", "\\Bigl", "\\biggl", "\\Biggl",
|
"\\bigl", "\\Bigl", "\\biggl", "\\Biggl",
|
||||||
"\\bigr", "\\Bigr", "\\biggr", "\\Biggr",
|
"\\bigr", "\\Bigr", "\\biggr", "\\Biggr",
|
||||||
"\\bigm", "\\Bigm", "\\biggm", "\\Biggm",
|
"\\bigm", "\\Bigm", "\\biggm", "\\Biggm",
|
||||||
|
@ -439,19 +439,19 @@ declareFunction([
|
||||||
});
|
});
|
||||||
|
|
||||||
// Sizing functions (handled in Parser.js explicitly, hence no handler)
|
// Sizing functions (handled in Parser.js explicitly, hence no handler)
|
||||||
declareFunction([
|
defineFunction([
|
||||||
"\\tiny", "\\scriptsize", "\\footnotesize", "\\small",
|
"\\tiny", "\\scriptsize", "\\footnotesize", "\\small",
|
||||||
"\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"
|
"\\normalsize", "\\large", "\\Large", "\\LARGE", "\\huge", "\\Huge"
|
||||||
], 0, null);
|
], 0, null);
|
||||||
|
|
||||||
// Style changing functions (handled in Parser.js explicitly, hence no
|
// Style changing functions (handled in Parser.js explicitly, hence no
|
||||||
// handler)
|
// handler)
|
||||||
declareFunction([
|
defineFunction([
|
||||||
"\\displaystyle", "\\textstyle", "\\scriptstyle",
|
"\\displaystyle", "\\textstyle", "\\scriptstyle",
|
||||||
"\\scriptscriptstyle"
|
"\\scriptscriptstyle"
|
||||||
], 0, null);
|
], 0, null);
|
||||||
|
|
||||||
declareFunction([
|
defineFunction([
|
||||||
// styles
|
// styles
|
||||||
"\\mathrm", "\\mathit", "\\mathbf",
|
"\\mathrm", "\\mathit", "\\mathbf",
|
||||||
|
|
||||||
|
@ -475,7 +475,7 @@ declareFunction([
|
||||||
});
|
});
|
||||||
|
|
||||||
// Accents
|
// Accents
|
||||||
declareFunction([
|
defineFunction([
|
||||||
"\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve",
|
"\\acute", "\\grave", "\\ddot", "\\tilde", "\\bar", "\\breve",
|
||||||
"\\check", "\\hat", "\\vec", "\\dot"
|
"\\check", "\\hat", "\\vec", "\\dot"
|
||||||
// We don't support expanding accents yet
|
// We don't support expanding accents yet
|
||||||
|
@ -491,7 +491,7 @@ declareFunction([
|
||||||
});
|
});
|
||||||
|
|
||||||
// Infix generalized fractions
|
// Infix generalized fractions
|
||||||
declareFunction(["\\over", "\\choose"], {
|
defineFunction(["\\over", "\\choose"], {
|
||||||
numArgs: 0
|
numArgs: 0
|
||||||
}, function (func) {
|
}, function (func) {
|
||||||
var replaceWith;
|
var replaceWith;
|
||||||
|
@ -512,7 +512,7 @@ declareFunction(["\\over", "\\choose"], {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Row breaks for aligned data
|
// Row breaks for aligned data
|
||||||
declareFunction(["\\\\", "\\cr"], {
|
defineFunction(["\\\\", "\\cr"], {
|
||||||
numArgs: 0,
|
numArgs: 0,
|
||||||
numOptionalArgs: 1,
|
numOptionalArgs: 1,
|
||||||
argTypes: ["size"]
|
argTypes: ["size"]
|
||||||
|
@ -524,7 +524,7 @@ declareFunction(["\\\\", "\\cr"], {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Environment delimiters
|
// Environment delimiters
|
||||||
declareFunction(["\\begin", "\\end"], {
|
defineFunction(["\\begin", "\\end"], {
|
||||||
numArgs: 1,
|
numArgs: 1,
|
||||||
argTypes: ["text"]
|
argTypes: ["text"]
|
||||||
}, function(func, nameGroup, positions) {
|
}, function(func, nameGroup, positions) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user