Update katex to v0.16.21

This commit is contained in:
Will Faught
2025-01-19 11:08:41 -08:00
parent d663b8aa90
commit 3ac8d7b9b8
36 changed files with 1044 additions and 409 deletions

View File

@@ -146,7 +146,9 @@ defineMacro("\\char", function(context) {
// \newcommand{\macro}[args]{definition}
// \renewcommand{\macro}[args]{definition}
// TODO: Optional arguments: \newcommand{\macro}[args][default]{definition}
const newcommand = (context, existsOK: boolean, nonexistsOK: boolean) => {
const newcommand = (
context, existsOK: boolean, nonexistsOK: boolean, skipIfExists: boolean
) => {
let arg = context.consumeArg().tokens;
if (arg.length !== 1) {
throw new ParseError(
@@ -181,16 +183,21 @@ const newcommand = (context, existsOK: boolean, nonexistsOK: boolean) => {
arg = context.consumeArg().tokens;
}
// Final arg is the expansion of the macro
context.macros.set(name, {
tokens: arg,
numArgs,
});
if (!(exists && skipIfExists)) {
// Final arg is the expansion of the macro
context.macros.set(name, {
tokens: arg,
numArgs,
});
}
return '';
};
defineMacro("\\newcommand", (context) => newcommand(context, false, true));
defineMacro("\\renewcommand", (context) => newcommand(context, true, false));
defineMacro("\\providecommand", (context) => newcommand(context, true, true));
defineMacro("\\newcommand",
(context) => newcommand(context, false, true, false));
defineMacro("\\renewcommand",
(context) => newcommand(context, true, false, false));
defineMacro("\\providecommand",
(context) => newcommand(context, true, true, true));
// terminal (console) tools
defineMacro("\\message", (context) => {
@@ -341,7 +348,7 @@ defineMacro("\\lrcorner", "\\html@mathml{\\@lrcorner}{\\mathop{\\char\"231f}}");
// \kern6\p@\hbox{.}\hbox{.}\hbox{.}}}
// We'll call \varvdots, which gets a glyph from symbols.js.
// The zero-width rule gets us an equivalent to the vertical 6pt kern.
defineMacro("\\vdots", "\\mathord{\\varvdots\\rule{0pt}{15pt}}");
defineMacro("\\vdots", "{\\varvdots\\rule{0pt}{15pt}}");
defineMacro("\u22ee", "\\vdots");
//////////////////////////////////////////////////////////////////////
@@ -380,6 +387,12 @@ defineMacro("\\iff", "\\DOTSB\\;\\Longleftrightarrow\\;");
defineMacro("\\implies", "\\DOTSB\\;\\Longrightarrow\\;");
defineMacro("\\impliedby", "\\DOTSB\\;\\Longleftarrow\\;");
// \def\dddot#1{{\mathop{#1}\limits^{\vbox to-1.4\ex@{\kern-\tw@\ex@
// \hbox{\normalfont ...}\vss}}}}
// We use \overset which avoids the vertical shift of \mathop.
defineMacro("\\dddot", "{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}");
defineMacro("\\ddddot", "{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}");
// AMSMath's automatic \dots, based on \mdots@@ macro.
const dotsByToken = {
',': '\\dotsc',