katex 0.13.24 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/cli.js +17 -46
- package/contrib/copy-tex/README.md +3 -3
- package/contrib/mathtex-script-type/README.md +5 -5
- package/contrib/mhchem/README.md +1 -1
- package/dist/README.md +3 -3
- package/dist/katex.css +1 -1
- package/dist/katex.js +380 -153
- package/dist/katex.min.css +1 -1
- package/dist/katex.min.js +1 -1
- package/dist/katex.mjs +276 -62
- package/katex.js +5 -1
- package/package.json +28 -1
- package/src/MacroExpander.js +3 -7
- package/src/Namespace.js +9 -4
- package/src/Parser.js +21 -0
- package/src/Settings.js +183 -32
- package/src/environments/array.js +72 -18
- package/src/functions/relax.js +17 -0
- package/src/functions.js +1 -0
- package/src/macros.js +1 -1
- package/src/parseNode.js +2 -1
- package/src/parseTree.js +2 -2
package/dist/katex.js
CHANGED
|
@@ -229,7 +229,136 @@ var protocolFromUrl = function protocolFromUrl(url) {
|
|
|
229
229
|
|
|
230
230
|
|
|
231
231
|
|
|
232
|
+
// TODO: automatically generate documentation
|
|
233
|
+
// TODO: check all properties on Settings exist
|
|
234
|
+
// TODO: check the type of a property on Settings matches
|
|
235
|
+
var SETTINGS_SCHEMA = {
|
|
236
|
+
displayMode: {
|
|
237
|
+
type: "boolean",
|
|
238
|
+
description: "Render math in display mode, which puts the math in " + "display style (so \\int and \\sum are large, for example), and " + "centers the math on the page on its own line.",
|
|
239
|
+
cli: "-d, --display-mode"
|
|
240
|
+
},
|
|
241
|
+
output: {
|
|
242
|
+
type: {
|
|
243
|
+
enum: ["htmlAndMathml", "html", "mathml"]
|
|
244
|
+
},
|
|
245
|
+
description: "Determines the markup language of the output.",
|
|
246
|
+
cli: "-F, --format <type>"
|
|
247
|
+
},
|
|
248
|
+
leqno: {
|
|
249
|
+
type: "boolean",
|
|
250
|
+
description: "Render display math in leqno style (left-justified tags)."
|
|
251
|
+
},
|
|
252
|
+
fleqn: {
|
|
253
|
+
type: "boolean",
|
|
254
|
+
description: "Render display math flush left."
|
|
255
|
+
},
|
|
256
|
+
throwOnError: {
|
|
257
|
+
type: "boolean",
|
|
258
|
+
default: true,
|
|
259
|
+
cli: "-t, --no-throw-on-error",
|
|
260
|
+
cliDescription: "Render errors (in the color given by --error-color) ins" + "tead of throwing a ParseError exception when encountering an error."
|
|
261
|
+
},
|
|
262
|
+
errorColor: {
|
|
263
|
+
type: "string",
|
|
264
|
+
default: "#cc0000",
|
|
265
|
+
cli: "-c, --error-color <color>",
|
|
266
|
+
cliDescription: "A color string given in the format 'rgb' or 'rrggbb' " + "(no #). This option determines the color of errors rendered by the " + "-t option.",
|
|
267
|
+
cliProcessor: function cliProcessor(color) {
|
|
268
|
+
return "#" + color;
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
macros: {
|
|
272
|
+
type: "object",
|
|
273
|
+
cli: "-m, --macro <def>",
|
|
274
|
+
cliDescription: "Define custom macro of the form '\\foo:expansion' (use " + "multiple -m arguments for multiple macros).",
|
|
275
|
+
cliDefault: [],
|
|
276
|
+
cliProcessor: function cliProcessor(def, defs) {
|
|
277
|
+
defs.push(def);
|
|
278
|
+
return defs;
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
minRuleThickness: {
|
|
282
|
+
type: "number",
|
|
283
|
+
description: "Specifies a minimum thickness, in ems, for fraction lines," + " `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, " + "`\\hdashline`, `\\underline`, `\\overline`, and the borders of " + "`\\fbox`, `\\boxed`, and `\\fcolorbox`.",
|
|
284
|
+
processor: function processor(t) {
|
|
285
|
+
return Math.max(0, t);
|
|
286
|
+
},
|
|
287
|
+
cli: "--min-rule-thickness <size>",
|
|
288
|
+
cliProcessor: parseFloat
|
|
289
|
+
},
|
|
290
|
+
colorIsTextColor: {
|
|
291
|
+
type: "boolean",
|
|
292
|
+
description: "Makes \\color behave like LaTeX's 2-argument \\textcolor, " + "instead of LaTeX's one-argument \\color mode change.",
|
|
293
|
+
cli: "-b, --color-is-text-color"
|
|
294
|
+
},
|
|
295
|
+
strict: {
|
|
296
|
+
type: [{
|
|
297
|
+
enum: ["warn", "ignore", "error"]
|
|
298
|
+
}, "boolean", "function"],
|
|
299
|
+
description: "Turn on strict / LaTeX faithfulness mode, which throws an " + "error if the input uses features that are not supported by LaTeX.",
|
|
300
|
+
cli: "-S, --strict",
|
|
301
|
+
cliDefault: false
|
|
302
|
+
},
|
|
303
|
+
trust: {
|
|
304
|
+
type: ["boolean", "function"],
|
|
305
|
+
description: "Trust the input, enabling all HTML features such as \\url.",
|
|
306
|
+
cli: "-T, --trust"
|
|
307
|
+
},
|
|
308
|
+
maxSize: {
|
|
309
|
+
type: "number",
|
|
310
|
+
default: Infinity,
|
|
311
|
+
description: "If non-zero, all user-specified sizes, e.g. in " + "\\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, " + "elements and spaces can be arbitrarily large",
|
|
312
|
+
processor: function processor(s) {
|
|
313
|
+
return Math.max(0, s);
|
|
314
|
+
},
|
|
315
|
+
cli: "-s, --max-size <n>",
|
|
316
|
+
cliProcessor: parseInt
|
|
317
|
+
},
|
|
318
|
+
maxExpand: {
|
|
319
|
+
type: "number",
|
|
320
|
+
default: 1000,
|
|
321
|
+
description: "Limit the number of macro expansions to the specified " + "number, to prevent e.g. infinite macro loops. If set to Infinity, " + "the macro expander will try to fully expand as in LaTeX.",
|
|
322
|
+
processor: function processor(n) {
|
|
323
|
+
return Math.max(0, n);
|
|
324
|
+
},
|
|
325
|
+
cli: "-e, --max-expand <n>",
|
|
326
|
+
cliProcessor: function cliProcessor(n) {
|
|
327
|
+
return n === "Infinity" ? Infinity : parseInt(n);
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
globalGroup: {
|
|
331
|
+
type: "boolean",
|
|
332
|
+
cli: false
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
function getDefaultValue(schema) {
|
|
337
|
+
if (schema.default) {
|
|
338
|
+
return schema.default;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
var type = schema.type;
|
|
342
|
+
var defaultType = Array.isArray(type) ? type[0] : type;
|
|
343
|
+
|
|
344
|
+
if (typeof defaultType !== 'string') {
|
|
345
|
+
return defaultType.enum[0];
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
switch (defaultType) {
|
|
349
|
+
case 'boolean':
|
|
350
|
+
return false;
|
|
232
351
|
|
|
352
|
+
case 'string':
|
|
353
|
+
return '';
|
|
354
|
+
|
|
355
|
+
case 'number':
|
|
356
|
+
return 0;
|
|
357
|
+
|
|
358
|
+
case 'object':
|
|
359
|
+
return {};
|
|
360
|
+
}
|
|
361
|
+
}
|
|
233
362
|
/**
|
|
234
363
|
* The main Settings object
|
|
235
364
|
*
|
|
@@ -240,6 +369,8 @@ var protocolFromUrl = function protocolFromUrl(url) {
|
|
|
240
369
|
* math (true), meaning that the math starts in \displaystyle
|
|
241
370
|
* and is placed in a block with vertical margin.
|
|
242
371
|
*/
|
|
372
|
+
|
|
373
|
+
|
|
243
374
|
var Settings = /*#__PURE__*/function () {
|
|
244
375
|
function Settings(options) {
|
|
245
376
|
this.displayMode = void 0;
|
|
@@ -258,20 +389,16 @@ var Settings = /*#__PURE__*/function () {
|
|
|
258
389
|
this.globalGroup = void 0;
|
|
259
390
|
// allow null options
|
|
260
391
|
options = options || {};
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
this.trust = utils.deflt(options.trust, false);
|
|
272
|
-
this.maxSize = Math.max(0, utils.deflt(options.maxSize, Infinity));
|
|
273
|
-
this.maxExpand = Math.max(0, utils.deflt(options.maxExpand, 1000));
|
|
274
|
-
this.globalGroup = utils.deflt(options.globalGroup, false);
|
|
392
|
+
|
|
393
|
+
for (var prop in SETTINGS_SCHEMA) {
|
|
394
|
+
if (SETTINGS_SCHEMA.hasOwnProperty(prop)) {
|
|
395
|
+
// $FlowFixMe
|
|
396
|
+
var schema = SETTINGS_SCHEMA[prop]; // TODO: validate options
|
|
397
|
+
// $FlowFixMe
|
|
398
|
+
|
|
399
|
+
this[prop] = options[prop] !== undefined ? schema.processor ? schema.processor(options[prop]) : options[prop] : getDefaultValue(schema);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
275
402
|
}
|
|
276
403
|
/**
|
|
277
404
|
* Report nonstrict (non-LaTeX-compatible) input.
|
|
@@ -9980,6 +10107,109 @@ function defineEnvironment(_ref) {
|
|
|
9980
10107
|
_mathmlGroupBuilders[type] = mathmlBuilder;
|
|
9981
10108
|
}
|
|
9982
10109
|
}
|
|
10110
|
+
;// CONCATENATED MODULE: ./src/defineMacro.js
|
|
10111
|
+
|
|
10112
|
+
|
|
10113
|
+
/**
|
|
10114
|
+
* All registered global/built-in macros.
|
|
10115
|
+
* `macros.js` exports this same dictionary again and makes it public.
|
|
10116
|
+
* `Parser.js` requires this dictionary via `macros.js`.
|
|
10117
|
+
*/
|
|
10118
|
+
var _macros = {}; // This function might one day accept an additional argument and do more things.
|
|
10119
|
+
|
|
10120
|
+
function defineMacro(name, body) {
|
|
10121
|
+
_macros[name] = body;
|
|
10122
|
+
}
|
|
10123
|
+
;// CONCATENATED MODULE: ./src/SourceLocation.js
|
|
10124
|
+
/**
|
|
10125
|
+
* Lexing or parsing positional information for error reporting.
|
|
10126
|
+
* This object is immutable.
|
|
10127
|
+
*/
|
|
10128
|
+
var SourceLocation = /*#__PURE__*/function () {
|
|
10129
|
+
// The + prefix indicates that these fields aren't writeable
|
|
10130
|
+
// Lexer holding the input string.
|
|
10131
|
+
// Start offset, zero-based inclusive.
|
|
10132
|
+
// End offset, zero-based exclusive.
|
|
10133
|
+
function SourceLocation(lexer, start, end) {
|
|
10134
|
+
this.lexer = void 0;
|
|
10135
|
+
this.start = void 0;
|
|
10136
|
+
this.end = void 0;
|
|
10137
|
+
this.lexer = lexer;
|
|
10138
|
+
this.start = start;
|
|
10139
|
+
this.end = end;
|
|
10140
|
+
}
|
|
10141
|
+
/**
|
|
10142
|
+
* Merges two `SourceLocation`s from location providers, given they are
|
|
10143
|
+
* provided in order of appearance.
|
|
10144
|
+
* - Returns the first one's location if only the first is provided.
|
|
10145
|
+
* - Returns a merged range of the first and the last if both are provided
|
|
10146
|
+
* and their lexers match.
|
|
10147
|
+
* - Otherwise, returns null.
|
|
10148
|
+
*/
|
|
10149
|
+
|
|
10150
|
+
|
|
10151
|
+
SourceLocation.range = function range(first, second) {
|
|
10152
|
+
if (!second) {
|
|
10153
|
+
return first && first.loc;
|
|
10154
|
+
} else if (!first || !first.loc || !second.loc || first.loc.lexer !== second.loc.lexer) {
|
|
10155
|
+
return null;
|
|
10156
|
+
} else {
|
|
10157
|
+
return new SourceLocation(first.loc.lexer, first.loc.start, second.loc.end);
|
|
10158
|
+
}
|
|
10159
|
+
};
|
|
10160
|
+
|
|
10161
|
+
return SourceLocation;
|
|
10162
|
+
}();
|
|
10163
|
+
|
|
10164
|
+
|
|
10165
|
+
;// CONCATENATED MODULE: ./src/Token.js
|
|
10166
|
+
|
|
10167
|
+
/**
|
|
10168
|
+
* Interface required to break circular dependency between Token, Lexer, and
|
|
10169
|
+
* ParseError.
|
|
10170
|
+
*/
|
|
10171
|
+
|
|
10172
|
+
/**
|
|
10173
|
+
* The resulting token returned from `lex`.
|
|
10174
|
+
*
|
|
10175
|
+
* It consists of the token text plus some position information.
|
|
10176
|
+
* The position information is essentially a range in an input string,
|
|
10177
|
+
* but instead of referencing the bare input string, we refer to the lexer.
|
|
10178
|
+
* That way it is possible to attach extra metadata to the input string,
|
|
10179
|
+
* like for example a file name or similar.
|
|
10180
|
+
*
|
|
10181
|
+
* The position information is optional, so it is OK to construct synthetic
|
|
10182
|
+
* tokens if appropriate. Not providing available position information may
|
|
10183
|
+
* lead to degraded error reporting, though.
|
|
10184
|
+
*/
|
|
10185
|
+
var Token = /*#__PURE__*/function () {
|
|
10186
|
+
// don't expand the token
|
|
10187
|
+
// used in \noexpand
|
|
10188
|
+
function Token(text, // the text of this token
|
|
10189
|
+
loc) {
|
|
10190
|
+
this.text = void 0;
|
|
10191
|
+
this.loc = void 0;
|
|
10192
|
+
this.noexpand = void 0;
|
|
10193
|
+
this.treatAsRelax = void 0;
|
|
10194
|
+
this.text = text;
|
|
10195
|
+
this.loc = loc;
|
|
10196
|
+
}
|
|
10197
|
+
/**
|
|
10198
|
+
* Given a pair of tokens (this and endToken), compute a `Token` encompassing
|
|
10199
|
+
* the whole input range enclosed by these two.
|
|
10200
|
+
*/
|
|
10201
|
+
|
|
10202
|
+
|
|
10203
|
+
var _proto = Token.prototype;
|
|
10204
|
+
|
|
10205
|
+
_proto.range = function range(endToken, // last token of the range, inclusive
|
|
10206
|
+
text // the text of the newly constructed token
|
|
10207
|
+
) {
|
|
10208
|
+
return new Token(text, SourceLocation.range(this, endToken));
|
|
10209
|
+
};
|
|
10210
|
+
|
|
10211
|
+
return Token;
|
|
10212
|
+
}();
|
|
9983
10213
|
;// CONCATENATED MODULE: ./src/environments/array.js
|
|
9984
10214
|
|
|
9985
10215
|
|
|
@@ -9995,6 +10225,8 @@ function defineEnvironment(_ref) {
|
|
|
9995
10225
|
|
|
9996
10226
|
|
|
9997
10227
|
|
|
10228
|
+
|
|
10229
|
+
|
|
9998
10230
|
// Helper functions
|
|
9999
10231
|
function getHLines(parser) {
|
|
10000
10232
|
// Return an array. The array length = number of hlines.
|
|
@@ -10019,7 +10251,19 @@ var validateAmsEnvironmentContext = function validateAmsEnvironmentContext(conte
|
|
|
10019
10251
|
if (!settings.displayMode) {
|
|
10020
10252
|
throw new src_ParseError("{" + context.envName + "} can be used only in" + " display mode.");
|
|
10021
10253
|
}
|
|
10022
|
-
};
|
|
10254
|
+
}; // autoTag (an argument to parseArray) can be one of three values:
|
|
10255
|
+
// * undefined: Regular (not-top-level) array; no tags on each row
|
|
10256
|
+
// * true: Automatic equation numbering, overridable by \tag
|
|
10257
|
+
// * false: Tags allowed on each row, but no automatic numbering
|
|
10258
|
+
// This function *doesn't* work with the "split" environment name.
|
|
10259
|
+
|
|
10260
|
+
|
|
10261
|
+
function getAutoTag(name) {
|
|
10262
|
+
if (name.indexOf("ed") === -1) {
|
|
10263
|
+
return name.indexOf("*") === -1;
|
|
10264
|
+
} // return undefined;
|
|
10265
|
+
|
|
10266
|
+
}
|
|
10023
10267
|
/**
|
|
10024
10268
|
* Parse the body of the environment, with rows delimited by \\ and
|
|
10025
10269
|
* columns delimited by &, and create a nested list in row-major order
|
|
@@ -10034,7 +10278,7 @@ function parseArray(parser, _ref, style) {
|
|
|
10034
10278
|
cols = _ref.cols,
|
|
10035
10279
|
arraystretch = _ref.arraystretch,
|
|
10036
10280
|
colSeparationType = _ref.colSeparationType,
|
|
10037
|
-
|
|
10281
|
+
autoTag = _ref.autoTag,
|
|
10038
10282
|
singleRow = _ref.singleRow,
|
|
10039
10283
|
emptySingleRow = _ref.emptySingleRow,
|
|
10040
10284
|
maxNumCols = _ref.maxNumCols,
|
|
@@ -10068,7 +10312,29 @@ function parseArray(parser, _ref, style) {
|
|
|
10068
10312
|
var row = [];
|
|
10069
10313
|
var body = [row];
|
|
10070
10314
|
var rowGaps = [];
|
|
10071
|
-
var hLinesBeforeRow = [];
|
|
10315
|
+
var hLinesBeforeRow = [];
|
|
10316
|
+
var tags = autoTag != null ? [] : undefined; // amsmath uses \global\@eqnswtrue and \global\@eqnswfalse to represent
|
|
10317
|
+
// whether this row should have an equation number. Simulate this with
|
|
10318
|
+
// a \@eqnsw macro set to 1 or 0.
|
|
10319
|
+
|
|
10320
|
+
function beginRow() {
|
|
10321
|
+
if (autoTag) {
|
|
10322
|
+
parser.gullet.macros.set("\\@eqnsw", "1", true);
|
|
10323
|
+
}
|
|
10324
|
+
}
|
|
10325
|
+
|
|
10326
|
+
function endRow() {
|
|
10327
|
+
if (tags) {
|
|
10328
|
+
if (parser.gullet.macros.get("\\df@tag")) {
|
|
10329
|
+
tags.push(parser.subparse([new Token("\\df@tag")]));
|
|
10330
|
+
parser.gullet.macros.set("\\df@tag", undefined, true);
|
|
10331
|
+
} else {
|
|
10332
|
+
tags.push(Boolean(autoTag) && parser.gullet.macros.get("\\@eqnsw") === "1");
|
|
10333
|
+
}
|
|
10334
|
+
}
|
|
10335
|
+
}
|
|
10336
|
+
|
|
10337
|
+
beginRow(); // Test for \hline at the top of the array.
|
|
10072
10338
|
|
|
10073
10339
|
hLinesBeforeRow.push(getHLines(parser));
|
|
10074
10340
|
|
|
@@ -10109,10 +10375,11 @@ function parseArray(parser, _ref, style) {
|
|
|
10109
10375
|
|
|
10110
10376
|
parser.consume();
|
|
10111
10377
|
} else if (next === "\\end") {
|
|
10112
|
-
// Arrays terminate newlines with `\crcr` which consumes a `\cr` if
|
|
10378
|
+
endRow(); // Arrays terminate newlines with `\crcr` which consumes a `\cr` if
|
|
10113
10379
|
// the last line is empty. However, AMS environments keep the
|
|
10114
10380
|
// empty row if it's the only one.
|
|
10115
10381
|
// NOTE: Currently, `cell` is the last item added into `row`.
|
|
10382
|
+
|
|
10116
10383
|
if (row.length === 1 && cell.type === "styling" && cell.body[0].body.length === 0 && (body.length > 1 || !emptySingleRow)) {
|
|
10117
10384
|
body.pop();
|
|
10118
10385
|
}
|
|
@@ -10134,11 +10401,13 @@ function parseArray(parser, _ref, style) {
|
|
|
10134
10401
|
size = parser.parseSizeGroup(true);
|
|
10135
10402
|
}
|
|
10136
10403
|
|
|
10137
|
-
rowGaps.push(size ? size.value : null);
|
|
10404
|
+
rowGaps.push(size ? size.value : null);
|
|
10405
|
+
endRow(); // check for \hline(s) following the row separator
|
|
10138
10406
|
|
|
10139
10407
|
hLinesBeforeRow.push(getHLines(parser));
|
|
10140
10408
|
row = [];
|
|
10141
10409
|
body.push(row);
|
|
10410
|
+
beginRow();
|
|
10142
10411
|
} else {
|
|
10143
10412
|
throw new src_ParseError("Expected & or \\\\ or \\cr or \\end", parser.nextToken);
|
|
10144
10413
|
}
|
|
@@ -10159,7 +10428,7 @@ function parseArray(parser, _ref, style) {
|
|
|
10159
10428
|
hskipBeforeAndAfter: hskipBeforeAndAfter,
|
|
10160
10429
|
hLinesBeforeRow: hLinesBeforeRow,
|
|
10161
10430
|
colSeparationType: colSeparationType,
|
|
10162
|
-
|
|
10431
|
+
tags: tags,
|
|
10163
10432
|
leqno: leqno
|
|
10164
10433
|
};
|
|
10165
10434
|
} // Decides on a style for cells in an array according to whether the given
|
|
@@ -10297,20 +10566,35 @@ var array_htmlBuilder = function htmlBuilder(group, options) {
|
|
|
10297
10566
|
var cols = [];
|
|
10298
10567
|
var colSep;
|
|
10299
10568
|
var colDescrNum;
|
|
10300
|
-
var
|
|
10569
|
+
var tagSpans = [];
|
|
10301
10570
|
|
|
10302
|
-
if (group.
|
|
10303
|
-
|
|
10304
|
-
|
|
10571
|
+
if (group.tags && group.tags.some(function (tag) {
|
|
10572
|
+
return tag;
|
|
10573
|
+
})) {
|
|
10574
|
+
// An environment with manual tags and/or automatic equation numbers.
|
|
10575
|
+
// Create node(s), the latter of which trigger CSS counter increment.
|
|
10305
10576
|
for (r = 0; r < nr; ++r) {
|
|
10306
10577
|
var rw = body[r];
|
|
10307
10578
|
var shift = rw.pos - offset;
|
|
10308
|
-
var
|
|
10309
|
-
|
|
10310
|
-
|
|
10311
|
-
|
|
10579
|
+
var tag = group.tags[r];
|
|
10580
|
+
var tagSpan = void 0;
|
|
10581
|
+
|
|
10582
|
+
if (tag === true) {
|
|
10583
|
+
// automatic numbering
|
|
10584
|
+
tagSpan = buildCommon.makeSpan(["eqn-num"], [], options);
|
|
10585
|
+
} else if (tag === false) {
|
|
10586
|
+
// \nonumber/\notag or starred environment
|
|
10587
|
+
tagSpan = buildCommon.makeSpan([], [], options);
|
|
10588
|
+
} else {
|
|
10589
|
+
// manual \tag
|
|
10590
|
+
tagSpan = buildCommon.makeSpan([], buildExpression(tag, options, true), options);
|
|
10591
|
+
}
|
|
10592
|
+
|
|
10593
|
+
tagSpan.depth = rw.depth;
|
|
10594
|
+
tagSpan.height = rw.height;
|
|
10595
|
+
tagSpans.push({
|
|
10312
10596
|
type: "elem",
|
|
10313
|
-
elem:
|
|
10597
|
+
elem: tagSpan,
|
|
10314
10598
|
shift: shift
|
|
10315
10599
|
});
|
|
10316
10600
|
}
|
|
@@ -10446,12 +10730,12 @@ var array_htmlBuilder = function htmlBuilder(group, options) {
|
|
|
10446
10730
|
}, options);
|
|
10447
10731
|
}
|
|
10448
10732
|
|
|
10449
|
-
if (
|
|
10733
|
+
if (tagSpans.length === 0) {
|
|
10450
10734
|
return buildCommon.makeSpan(["mord"], [body], options);
|
|
10451
10735
|
} else {
|
|
10452
10736
|
var eqnNumCol = buildCommon.makeVList({
|
|
10453
10737
|
positionType: "individualShift",
|
|
10454
|
-
children:
|
|
10738
|
+
children: tagSpans
|
|
10455
10739
|
}, options);
|
|
10456
10740
|
eqnNumCol = buildCommon.makeSpan(["tag"], [eqnNumCol], options);
|
|
10457
10741
|
return buildCommon.makeFragment([body, eqnNumCol]);
|
|
@@ -10477,7 +10761,7 @@ var array_mathmlBuilder = function mathmlBuilder(group, options) {
|
|
|
10477
10761
|
row.push(new mathMLTree.MathNode("mtd", [buildMathML_buildGroup(rw[j], options)]));
|
|
10478
10762
|
}
|
|
10479
10763
|
|
|
10480
|
-
if (group.
|
|
10764
|
+
if (group.tags && group.tags[i]) {
|
|
10481
10765
|
row.unshift(glue);
|
|
10482
10766
|
row.push(glue);
|
|
10483
10767
|
|
|
@@ -10612,13 +10896,14 @@ var alignedHandler = function alignedHandler(context, args) {
|
|
|
10612
10896
|
|
|
10613
10897
|
var cols = [];
|
|
10614
10898
|
var separationType = context.envName.indexOf("at") > -1 ? "alignat" : "align";
|
|
10899
|
+
var isSplit = context.envName === "split";
|
|
10615
10900
|
var res = parseArray(context.parser, {
|
|
10616
10901
|
cols: cols,
|
|
10617
10902
|
addJot: true,
|
|
10618
|
-
|
|
10903
|
+
autoTag: isSplit ? undefined : getAutoTag(context.envName),
|
|
10619
10904
|
emptySingleRow: true,
|
|
10620
10905
|
colSeparationType: separationType,
|
|
10621
|
-
maxNumCols:
|
|
10906
|
+
maxNumCols: isSplit ? 2 : undefined,
|
|
10622
10907
|
leqno: context.parser.settings.leqno
|
|
10623
10908
|
}, "display"); // Determining number of columns.
|
|
10624
10909
|
// 1. If the first argument is given, we use it as a number of columns,
|
|
@@ -10969,7 +11254,7 @@ defineEnvironment({
|
|
|
10969
11254
|
}],
|
|
10970
11255
|
addJot: true,
|
|
10971
11256
|
colSeparationType: "gather",
|
|
10972
|
-
|
|
11257
|
+
autoTag: getAutoTag(context.envName),
|
|
10973
11258
|
emptySingleRow: true,
|
|
10974
11259
|
leqno: context.parser.settings.leqno
|
|
10975
11260
|
};
|
|
@@ -11000,7 +11285,7 @@ defineEnvironment({
|
|
|
11000
11285
|
handler: function handler(context) {
|
|
11001
11286
|
validateAmsEnvironmentContext(context);
|
|
11002
11287
|
var res = {
|
|
11003
|
-
|
|
11288
|
+
autoTag: getAutoTag(context.envName),
|
|
11004
11289
|
emptySingleRow: true,
|
|
11005
11290
|
singleRow: true,
|
|
11006
11291
|
maxNumCols: 1,
|
|
@@ -11023,7 +11308,9 @@ defineEnvironment({
|
|
|
11023
11308
|
},
|
|
11024
11309
|
htmlBuilder: array_htmlBuilder,
|
|
11025
11310
|
mathmlBuilder: array_mathmlBuilder
|
|
11026
|
-
});
|
|
11311
|
+
});
|
|
11312
|
+
defineMacro("\\nonumber", "\\gdef\\@eqnsw{0}");
|
|
11313
|
+
defineMacro("\\notag", "\\nonumber"); // Catch \hline outside array environment
|
|
11027
11314
|
|
|
11028
11315
|
defineFunction({
|
|
11029
11316
|
type: "text",
|
|
@@ -13155,19 +13442,6 @@ defineFunction({
|
|
|
13155
13442
|
htmlBuilder: op_htmlBuilder,
|
|
13156
13443
|
mathmlBuilder: op_mathmlBuilder
|
|
13157
13444
|
});
|
|
13158
|
-
;// CONCATENATED MODULE: ./src/defineMacro.js
|
|
13159
|
-
|
|
13160
|
-
|
|
13161
|
-
/**
|
|
13162
|
-
* All registered global/built-in macros.
|
|
13163
|
-
* `macros.js` exports this same dictionary again and makes it public.
|
|
13164
|
-
* `Parser.js` requires this dictionary via `macros.js`.
|
|
13165
|
-
*/
|
|
13166
|
-
var _macros = {}; // This function might one day accept an additional argument and do more things.
|
|
13167
|
-
|
|
13168
|
-
function defineMacro(name, body) {
|
|
13169
|
-
_macros[name] = body;
|
|
13170
|
-
}
|
|
13171
13445
|
;// CONCATENATED MODULE: ./src/functions/operatorname.js
|
|
13172
13446
|
|
|
13173
13447
|
|
|
@@ -13559,6 +13833,23 @@ defineFunction({
|
|
|
13559
13833
|
return node;
|
|
13560
13834
|
}
|
|
13561
13835
|
});
|
|
13836
|
+
;// CONCATENATED MODULE: ./src/functions/relax.js
|
|
13837
|
+
|
|
13838
|
+
defineFunction({
|
|
13839
|
+
type: "internal",
|
|
13840
|
+
names: ["\\relax"],
|
|
13841
|
+
props: {
|
|
13842
|
+
numArgs: 0,
|
|
13843
|
+
allowedInText: true
|
|
13844
|
+
},
|
|
13845
|
+
handler: function handler(_ref) {
|
|
13846
|
+
var parser = _ref.parser;
|
|
13847
|
+
return {
|
|
13848
|
+
type: "internal",
|
|
13849
|
+
mode: parser.mode
|
|
13850
|
+
};
|
|
13851
|
+
}
|
|
13852
|
+
});
|
|
13562
13853
|
;// CONCATENATED MODULE: ./src/functions/rule.js
|
|
13563
13854
|
|
|
13564
13855
|
|
|
@@ -14701,97 +14992,8 @@ var functions = _functions;
|
|
|
14701
14992
|
|
|
14702
14993
|
|
|
14703
14994
|
|
|
14704
|
-
|
|
14705
|
-
;// CONCATENATED MODULE: ./src/SourceLocation.js
|
|
14706
|
-
/**
|
|
14707
|
-
* Lexing or parsing positional information for error reporting.
|
|
14708
|
-
* This object is immutable.
|
|
14709
|
-
*/
|
|
14710
|
-
var SourceLocation = /*#__PURE__*/function () {
|
|
14711
|
-
// The + prefix indicates that these fields aren't writeable
|
|
14712
|
-
// Lexer holding the input string.
|
|
14713
|
-
// Start offset, zero-based inclusive.
|
|
14714
|
-
// End offset, zero-based exclusive.
|
|
14715
|
-
function SourceLocation(lexer, start, end) {
|
|
14716
|
-
this.lexer = void 0;
|
|
14717
|
-
this.start = void 0;
|
|
14718
|
-
this.end = void 0;
|
|
14719
|
-
this.lexer = lexer;
|
|
14720
|
-
this.start = start;
|
|
14721
|
-
this.end = end;
|
|
14722
|
-
}
|
|
14723
|
-
/**
|
|
14724
|
-
* Merges two `SourceLocation`s from location providers, given they are
|
|
14725
|
-
* provided in order of appearance.
|
|
14726
|
-
* - Returns the first one's location if only the first is provided.
|
|
14727
|
-
* - Returns a merged range of the first and the last if both are provided
|
|
14728
|
-
* and their lexers match.
|
|
14729
|
-
* - Otherwise, returns null.
|
|
14730
|
-
*/
|
|
14731
14995
|
|
|
14732
14996
|
|
|
14733
|
-
SourceLocation.range = function range(first, second) {
|
|
14734
|
-
if (!second) {
|
|
14735
|
-
return first && first.loc;
|
|
14736
|
-
} else if (!first || !first.loc || !second.loc || first.loc.lexer !== second.loc.lexer) {
|
|
14737
|
-
return null;
|
|
14738
|
-
} else {
|
|
14739
|
-
return new SourceLocation(first.loc.lexer, first.loc.start, second.loc.end);
|
|
14740
|
-
}
|
|
14741
|
-
};
|
|
14742
|
-
|
|
14743
|
-
return SourceLocation;
|
|
14744
|
-
}();
|
|
14745
|
-
|
|
14746
|
-
|
|
14747
|
-
;// CONCATENATED MODULE: ./src/Token.js
|
|
14748
|
-
|
|
14749
|
-
/**
|
|
14750
|
-
* Interface required to break circular dependency between Token, Lexer, and
|
|
14751
|
-
* ParseError.
|
|
14752
|
-
*/
|
|
14753
|
-
|
|
14754
|
-
/**
|
|
14755
|
-
* The resulting token returned from `lex`.
|
|
14756
|
-
*
|
|
14757
|
-
* It consists of the token text plus some position information.
|
|
14758
|
-
* The position information is essentially a range in an input string,
|
|
14759
|
-
* but instead of referencing the bare input string, we refer to the lexer.
|
|
14760
|
-
* That way it is possible to attach extra metadata to the input string,
|
|
14761
|
-
* like for example a file name or similar.
|
|
14762
|
-
*
|
|
14763
|
-
* The position information is optional, so it is OK to construct synthetic
|
|
14764
|
-
* tokens if appropriate. Not providing available position information may
|
|
14765
|
-
* lead to degraded error reporting, though.
|
|
14766
|
-
*/
|
|
14767
|
-
var Token = /*#__PURE__*/function () {
|
|
14768
|
-
// don't expand the token
|
|
14769
|
-
// used in \noexpand
|
|
14770
|
-
function Token(text, // the text of this token
|
|
14771
|
-
loc) {
|
|
14772
|
-
this.text = void 0;
|
|
14773
|
-
this.loc = void 0;
|
|
14774
|
-
this.noexpand = void 0;
|
|
14775
|
-
this.treatAsRelax = void 0;
|
|
14776
|
-
this.text = text;
|
|
14777
|
-
this.loc = loc;
|
|
14778
|
-
}
|
|
14779
|
-
/**
|
|
14780
|
-
* Given a pair of tokens (this and endToken), compute a `Token` encompassing
|
|
14781
|
-
* the whole input range enclosed by these two.
|
|
14782
|
-
*/
|
|
14783
|
-
|
|
14784
|
-
|
|
14785
|
-
var _proto = Token.prototype;
|
|
14786
|
-
|
|
14787
|
-
_proto.range = function range(endToken, // last token of the range, inclusive
|
|
14788
|
-
text // the text of the newly constructed token
|
|
14789
|
-
) {
|
|
14790
|
-
return new Token(text, SourceLocation.range(this, endToken));
|
|
14791
|
-
};
|
|
14792
|
-
|
|
14793
|
-
return Token;
|
|
14794
|
-
}();
|
|
14795
14997
|
;// CONCATENATED MODULE: ./src/Lexer.js
|
|
14796
14998
|
/**
|
|
14797
14999
|
* The Lexer class handles tokenizing the input in various ways. Since our
|
|
@@ -14977,7 +15179,7 @@ var Namespace = /*#__PURE__*/function () {
|
|
|
14977
15179
|
|
|
14978
15180
|
for (var undef in undefs) {
|
|
14979
15181
|
if (undefs.hasOwnProperty(undef)) {
|
|
14980
|
-
if (undefs[undef]
|
|
15182
|
+
if (undefs[undef] == null) {
|
|
14981
15183
|
delete this.current[undef];
|
|
14982
15184
|
} else {
|
|
14983
15185
|
this.current[undef] = undefs[undef];
|
|
@@ -15027,6 +15229,7 @@ var Namespace = /*#__PURE__*/function () {
|
|
|
15027
15229
|
* Local set() sets the current value and (when appropriate) adds an undo
|
|
15028
15230
|
* operation to the undo stack. Global set() may change the undo
|
|
15029
15231
|
* operation at every level, so takes time linear in their number.
|
|
15232
|
+
* A value of undefined means to delete existing definitions.
|
|
15030
15233
|
*/
|
|
15031
15234
|
;
|
|
15032
15235
|
|
|
@@ -15058,7 +15261,11 @@ var Namespace = /*#__PURE__*/function () {
|
|
|
15058
15261
|
}
|
|
15059
15262
|
}
|
|
15060
15263
|
|
|
15061
|
-
|
|
15264
|
+
if (value == null) {
|
|
15265
|
+
delete this.current[name];
|
|
15266
|
+
} else {
|
|
15267
|
+
this.current[name] = value;
|
|
15268
|
+
}
|
|
15062
15269
|
};
|
|
15063
15270
|
|
|
15064
15271
|
return Namespace;
|
|
@@ -15456,7 +15663,7 @@ defineMacro("\\varOmega", "\\mathit{\\Omega}"); //\newcommand{\substack}[1]{\sub
|
|
|
15456
15663
|
defineMacro("\\substack", "\\begin{subarray}{c}#1\\end{subarray}"); // \renewcommand{\colon}{\nobreak\mskip2mu\mathpunct{}\nonscript
|
|
15457
15664
|
// \mkern-\thinmuskip{:}\mskip6muplus1mu\relax}
|
|
15458
15665
|
|
|
15459
|
-
defineMacro("\\colon", "\\nobreak\\mskip2mu\\mathpunct{}" + "\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu"); // \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}}
|
|
15666
|
+
defineMacro("\\colon", "\\nobreak\\mskip2mu\\mathpunct{}" + "\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax"); // \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}}
|
|
15460
15667
|
|
|
15461
15668
|
defineMacro("\\boxed", "\\fbox{$\\displaystyle{#1}$}"); // \def\iff{\DOTSB\;\Longleftrightarrow\;}
|
|
15462
15669
|
// \def\implies{\DOTSB\;\Longrightarrow\;}
|
|
@@ -15990,8 +16197,6 @@ defineMacro("\\kaGreen", "\\textcolor{##71B307}{#1}");
|
|
|
15990
16197
|
// List of commands that act like macros but aren't defined as a macro,
|
|
15991
16198
|
// function, or symbol. Used in `isDefined`.
|
|
15992
16199
|
var implicitCommands = {
|
|
15993
|
-
"\\relax": true,
|
|
15994
|
-
// MacroExpander.js
|
|
15995
16200
|
"^": true,
|
|
15996
16201
|
// Parser.js
|
|
15997
16202
|
"_": true,
|
|
@@ -16362,15 +16567,13 @@ var MacroExpander = /*#__PURE__*/function () {
|
|
|
16362
16567
|
var expanded = this.expandOnce(); // expandOnce returns Token if and only if it's fully expanded.
|
|
16363
16568
|
|
|
16364
16569
|
if (expanded instanceof Token) {
|
|
16365
|
-
// \relax stops the expansion, but shouldn't get returned (a
|
|
16366
|
-
// null return value couldn't get implemented as a function).
|
|
16367
16570
|
// the token after \noexpand is interpreted as if its meaning
|
|
16368
16571
|
// were ‘\relax’
|
|
16369
|
-
if (expanded.
|
|
16370
|
-
|
|
16371
|
-
} else {
|
|
16372
|
-
return this.stack.pop(); // === expanded
|
|
16572
|
+
if (expanded.treatAsRelax) {
|
|
16573
|
+
expanded.text = "\\relax";
|
|
16373
16574
|
}
|
|
16575
|
+
|
|
16576
|
+
return this.stack.pop(); // === expanded
|
|
16374
16577
|
}
|
|
16375
16578
|
} // Flow unable to figure out that this pathway is impossible.
|
|
16376
16579
|
// https://github.com/facebook/flow/issues/4808
|
|
@@ -17052,6 +17255,25 @@ var Parser = /*#__PURE__*/function () {
|
|
|
17052
17255
|
} finally {
|
|
17053
17256
|
this.gullet.endGroups();
|
|
17054
17257
|
}
|
|
17258
|
+
}
|
|
17259
|
+
/**
|
|
17260
|
+
* Fully parse a separate sequence of tokens as a separate job.
|
|
17261
|
+
* Tokens should be specified in reverse order, as in a MacroDefinition.
|
|
17262
|
+
*/
|
|
17263
|
+
;
|
|
17264
|
+
|
|
17265
|
+
_proto.subparse = function subparse(tokens) {
|
|
17266
|
+
// Save the next token from the current job.
|
|
17267
|
+
var oldToken = this.nextToken;
|
|
17268
|
+
this.consume(); // Run the new job, terminating it with an excess '}'
|
|
17269
|
+
|
|
17270
|
+
this.gullet.pushToken(new Token("}"));
|
|
17271
|
+
this.gullet.pushTokens(tokens);
|
|
17272
|
+
var parse = this.parseExpression(false);
|
|
17273
|
+
this.expect("}"); // Restore the next token from the current job.
|
|
17274
|
+
|
|
17275
|
+
this.nextToken = oldToken;
|
|
17276
|
+
return parse;
|
|
17055
17277
|
};
|
|
17056
17278
|
|
|
17057
17279
|
/**
|
|
@@ -17977,6 +18199,7 @@ Parser.endOfExpression = ["}", "\\endgroup", "\\end", "\\right", "&"];
|
|
|
17977
18199
|
|
|
17978
18200
|
|
|
17979
18201
|
|
|
18202
|
+
|
|
17980
18203
|
/**
|
|
17981
18204
|
* Parses an expression using a Parser, then returns the parsed result.
|
|
17982
18205
|
*/
|
|
@@ -17999,12 +18222,11 @@ var parseTree = function parseTree(toParse, settings) {
|
|
|
17999
18222
|
throw new src_ParseError("\\tag works only in display equations");
|
|
18000
18223
|
}
|
|
18001
18224
|
|
|
18002
|
-
parser.gullet.feed("\\df@tag");
|
|
18003
18225
|
tree = [{
|
|
18004
18226
|
type: "tag",
|
|
18005
18227
|
mode: "text",
|
|
18006
18228
|
body: tree,
|
|
18007
|
-
tag: parser.
|
|
18229
|
+
tag: parser.subparse([new Token("\\df@tag")])
|
|
18008
18230
|
}];
|
|
18009
18231
|
}
|
|
18010
18232
|
|
|
@@ -18125,7 +18347,7 @@ var renderToHTMLTree = function renderToHTMLTree(expression, options) {
|
|
|
18125
18347
|
/**
|
|
18126
18348
|
* Current KaTeX version
|
|
18127
18349
|
*/
|
|
18128
|
-
version: "0.
|
|
18350
|
+
version: "0.15.1",
|
|
18129
18351
|
|
|
18130
18352
|
/**
|
|
18131
18353
|
* Renders the given LaTeX into an HTML+MathML combination, and adds
|
|
@@ -18144,6 +18366,11 @@ var renderToHTMLTree = function renderToHTMLTree(expression, options) {
|
|
|
18144
18366
|
*/
|
|
18145
18367
|
ParseError: src_ParseError,
|
|
18146
18368
|
|
|
18369
|
+
/**
|
|
18370
|
+
* The shema of Settings
|
|
18371
|
+
*/
|
|
18372
|
+
SETTINGS_SCHEMA: SETTINGS_SCHEMA,
|
|
18373
|
+
|
|
18147
18374
|
/**
|
|
18148
18375
|
* Parses the given LaTeX into KaTeX's internal parse tree structure,
|
|
18149
18376
|
* without rendering to HTML or MathML.
|