katex 0.14.0 → 0.15.2
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 +385 -154
- package/dist/katex.min.css +1 -1
- package/dist/katex.min.js +1 -1
- package/dist/katex.mjs +281 -63
- package/katex.js +5 -1
- package/package.json +3 -3
- 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/mclass.js +4 -1
- 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",
|
|
@@ -11132,7 +11419,7 @@ function mclass_mathmlBuilder(group, options) {
|
|
|
11132
11419
|
var inner = buildMathML_buildExpression(group.body, options);
|
|
11133
11420
|
|
|
11134
11421
|
if (group.mclass === "minner") {
|
|
11135
|
-
|
|
11422
|
+
node = new mathMLTree.MathNode("mpadded", inner);
|
|
11136
11423
|
} else if (group.mclass === "mord") {
|
|
11137
11424
|
if (group.isCharacterBox) {
|
|
11138
11425
|
node = inner[0];
|
|
@@ -11160,6 +11447,10 @@ function mclass_mathmlBuilder(group, options) {
|
|
|
11160
11447
|
} else if (group.mclass === "mopen" || group.mclass === "mclose") {
|
|
11161
11448
|
node.attributes.lspace = "0em";
|
|
11162
11449
|
node.attributes.rspace = "0em";
|
|
11450
|
+
} else if (group.mclass === "minner") {
|
|
11451
|
+
node.attributes.lspace = "0.0556em"; // 1 mu is the most likely option
|
|
11452
|
+
|
|
11453
|
+
node.attributes.width = "+0.1111em";
|
|
11163
11454
|
} // MathML <mo> default space is 5/18 em, so <mrel> needs no action.
|
|
11164
11455
|
// Ref: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mo
|
|
11165
11456
|
|
|
@@ -13155,19 +13446,6 @@ defineFunction({
|
|
|
13155
13446
|
htmlBuilder: op_htmlBuilder,
|
|
13156
13447
|
mathmlBuilder: op_mathmlBuilder
|
|
13157
13448
|
});
|
|
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
13449
|
;// CONCATENATED MODULE: ./src/functions/operatorname.js
|
|
13172
13450
|
|
|
13173
13451
|
|
|
@@ -13559,6 +13837,23 @@ defineFunction({
|
|
|
13559
13837
|
return node;
|
|
13560
13838
|
}
|
|
13561
13839
|
});
|
|
13840
|
+
;// CONCATENATED MODULE: ./src/functions/relax.js
|
|
13841
|
+
|
|
13842
|
+
defineFunction({
|
|
13843
|
+
type: "internal",
|
|
13844
|
+
names: ["\\relax"],
|
|
13845
|
+
props: {
|
|
13846
|
+
numArgs: 0,
|
|
13847
|
+
allowedInText: true
|
|
13848
|
+
},
|
|
13849
|
+
handler: function handler(_ref) {
|
|
13850
|
+
var parser = _ref.parser;
|
|
13851
|
+
return {
|
|
13852
|
+
type: "internal",
|
|
13853
|
+
mode: parser.mode
|
|
13854
|
+
};
|
|
13855
|
+
}
|
|
13856
|
+
});
|
|
13562
13857
|
;// CONCATENATED MODULE: ./src/functions/rule.js
|
|
13563
13858
|
|
|
13564
13859
|
|
|
@@ -14701,97 +14996,8 @@ var functions = _functions;
|
|
|
14701
14996
|
|
|
14702
14997
|
|
|
14703
14998
|
|
|
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
14999
|
|
|
14732
15000
|
|
|
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
15001
|
;// CONCATENATED MODULE: ./src/Lexer.js
|
|
14796
15002
|
/**
|
|
14797
15003
|
* The Lexer class handles tokenizing the input in various ways. Since our
|
|
@@ -14977,7 +15183,7 @@ var Namespace = /*#__PURE__*/function () {
|
|
|
14977
15183
|
|
|
14978
15184
|
for (var undef in undefs) {
|
|
14979
15185
|
if (undefs.hasOwnProperty(undef)) {
|
|
14980
|
-
if (undefs[undef]
|
|
15186
|
+
if (undefs[undef] == null) {
|
|
14981
15187
|
delete this.current[undef];
|
|
14982
15188
|
} else {
|
|
14983
15189
|
this.current[undef] = undefs[undef];
|
|
@@ -15027,6 +15233,7 @@ var Namespace = /*#__PURE__*/function () {
|
|
|
15027
15233
|
* Local set() sets the current value and (when appropriate) adds an undo
|
|
15028
15234
|
* operation to the undo stack. Global set() may change the undo
|
|
15029
15235
|
* operation at every level, so takes time linear in their number.
|
|
15236
|
+
* A value of undefined means to delete existing definitions.
|
|
15030
15237
|
*/
|
|
15031
15238
|
;
|
|
15032
15239
|
|
|
@@ -15058,7 +15265,11 @@ var Namespace = /*#__PURE__*/function () {
|
|
|
15058
15265
|
}
|
|
15059
15266
|
}
|
|
15060
15267
|
|
|
15061
|
-
|
|
15268
|
+
if (value == null) {
|
|
15269
|
+
delete this.current[name];
|
|
15270
|
+
} else {
|
|
15271
|
+
this.current[name] = value;
|
|
15272
|
+
}
|
|
15062
15273
|
};
|
|
15063
15274
|
|
|
15064
15275
|
return Namespace;
|
|
@@ -15456,7 +15667,7 @@ defineMacro("\\varOmega", "\\mathit{\\Omega}"); //\newcommand{\substack}[1]{\sub
|
|
|
15456
15667
|
defineMacro("\\substack", "\\begin{subarray}{c}#1\\end{subarray}"); // \renewcommand{\colon}{\nobreak\mskip2mu\mathpunct{}\nonscript
|
|
15457
15668
|
// \mkern-\thinmuskip{:}\mskip6muplus1mu\relax}
|
|
15458
15669
|
|
|
15459
|
-
defineMacro("\\colon", "\\nobreak\\mskip2mu\\mathpunct{}" + "\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu"); // \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}}
|
|
15670
|
+
defineMacro("\\colon", "\\nobreak\\mskip2mu\\mathpunct{}" + "\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax"); // \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}}
|
|
15460
15671
|
|
|
15461
15672
|
defineMacro("\\boxed", "\\fbox{$\\displaystyle{#1}$}"); // \def\iff{\DOTSB\;\Longleftrightarrow\;}
|
|
15462
15673
|
// \def\implies{\DOTSB\;\Longrightarrow\;}
|
|
@@ -15990,8 +16201,6 @@ defineMacro("\\kaGreen", "\\textcolor{##71B307}{#1}");
|
|
|
15990
16201
|
// List of commands that act like macros but aren't defined as a macro,
|
|
15991
16202
|
// function, or symbol. Used in `isDefined`.
|
|
15992
16203
|
var implicitCommands = {
|
|
15993
|
-
"\\relax": true,
|
|
15994
|
-
// MacroExpander.js
|
|
15995
16204
|
"^": true,
|
|
15996
16205
|
// Parser.js
|
|
15997
16206
|
"_": true,
|
|
@@ -16362,15 +16571,13 @@ var MacroExpander = /*#__PURE__*/function () {
|
|
|
16362
16571
|
var expanded = this.expandOnce(); // expandOnce returns Token if and only if it's fully expanded.
|
|
16363
16572
|
|
|
16364
16573
|
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
16574
|
// the token after \noexpand is interpreted as if its meaning
|
|
16368
16575
|
// were ‘\relax’
|
|
16369
|
-
if (expanded.
|
|
16370
|
-
|
|
16371
|
-
} else {
|
|
16372
|
-
return this.stack.pop(); // === expanded
|
|
16576
|
+
if (expanded.treatAsRelax) {
|
|
16577
|
+
expanded.text = "\\relax";
|
|
16373
16578
|
}
|
|
16579
|
+
|
|
16580
|
+
return this.stack.pop(); // === expanded
|
|
16374
16581
|
}
|
|
16375
16582
|
} // Flow unable to figure out that this pathway is impossible.
|
|
16376
16583
|
// https://github.com/facebook/flow/issues/4808
|
|
@@ -17052,6 +17259,25 @@ var Parser = /*#__PURE__*/function () {
|
|
|
17052
17259
|
} finally {
|
|
17053
17260
|
this.gullet.endGroups();
|
|
17054
17261
|
}
|
|
17262
|
+
}
|
|
17263
|
+
/**
|
|
17264
|
+
* Fully parse a separate sequence of tokens as a separate job.
|
|
17265
|
+
* Tokens should be specified in reverse order, as in a MacroDefinition.
|
|
17266
|
+
*/
|
|
17267
|
+
;
|
|
17268
|
+
|
|
17269
|
+
_proto.subparse = function subparse(tokens) {
|
|
17270
|
+
// Save the next token from the current job.
|
|
17271
|
+
var oldToken = this.nextToken;
|
|
17272
|
+
this.consume(); // Run the new job, terminating it with an excess '}'
|
|
17273
|
+
|
|
17274
|
+
this.gullet.pushToken(new Token("}"));
|
|
17275
|
+
this.gullet.pushTokens(tokens);
|
|
17276
|
+
var parse = this.parseExpression(false);
|
|
17277
|
+
this.expect("}"); // Restore the next token from the current job.
|
|
17278
|
+
|
|
17279
|
+
this.nextToken = oldToken;
|
|
17280
|
+
return parse;
|
|
17055
17281
|
};
|
|
17056
17282
|
|
|
17057
17283
|
/**
|
|
@@ -17977,6 +18203,7 @@ Parser.endOfExpression = ["}", "\\endgroup", "\\end", "\\right", "&"];
|
|
|
17977
18203
|
|
|
17978
18204
|
|
|
17979
18205
|
|
|
18206
|
+
|
|
17980
18207
|
/**
|
|
17981
18208
|
* Parses an expression using a Parser, then returns the parsed result.
|
|
17982
18209
|
*/
|
|
@@ -17999,12 +18226,11 @@ var parseTree = function parseTree(toParse, settings) {
|
|
|
17999
18226
|
throw new src_ParseError("\\tag works only in display equations");
|
|
18000
18227
|
}
|
|
18001
18228
|
|
|
18002
|
-
parser.gullet.feed("\\df@tag");
|
|
18003
18229
|
tree = [{
|
|
18004
18230
|
type: "tag",
|
|
18005
18231
|
mode: "text",
|
|
18006
18232
|
body: tree,
|
|
18007
|
-
tag: parser.
|
|
18233
|
+
tag: parser.subparse([new Token("\\df@tag")])
|
|
18008
18234
|
}];
|
|
18009
18235
|
}
|
|
18010
18236
|
|
|
@@ -18125,7 +18351,7 @@ var renderToHTMLTree = function renderToHTMLTree(expression, options) {
|
|
|
18125
18351
|
/**
|
|
18126
18352
|
* Current KaTeX version
|
|
18127
18353
|
*/
|
|
18128
|
-
version: "0.
|
|
18354
|
+
version: "0.15.2",
|
|
18129
18355
|
|
|
18130
18356
|
/**
|
|
18131
18357
|
* Renders the given LaTeX into an HTML+MathML combination, and adds
|
|
@@ -18144,6 +18370,11 @@ var renderToHTMLTree = function renderToHTMLTree(expression, options) {
|
|
|
18144
18370
|
*/
|
|
18145
18371
|
ParseError: src_ParseError,
|
|
18146
18372
|
|
|
18373
|
+
/**
|
|
18374
|
+
* The shema of Settings
|
|
18375
|
+
*/
|
|
18376
|
+
SETTINGS_SCHEMA: SETTINGS_SCHEMA,
|
|
18377
|
+
|
|
18147
18378
|
/**
|
|
18148
18379
|
* Parses the given LaTeX into KaTeX's internal parse tree structure,
|
|
18149
18380
|
* without rendering to HTML or MathML.
|