temml 0.13.4 → 0.13.5
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 +1 -1
- package/dist/Temml-Asana.css +2 -2
- package/dist/Temml-Latin-Modern.css +2 -2
- package/dist/Temml-Libertinus.css +2 -2
- package/dist/Temml-Local.css +2 -2
- package/dist/Temml-NotoSans.css +2 -2
- package/dist/Temml-STIX2.css +2 -2
- package/dist/temml.cjs +69 -31
- package/dist/temml.js +69 -31
- package/dist/temml.min.js +1 -1
- package/dist/temml.mjs +69 -31
- package/dist/temmlPostProcess.js +1 -1
- package/package.json +1 -1
- package/src/Namespace.js +2 -2
- package/src/Settings.js +41 -15
- package/src/auto-render.js +1 -1
- package/src/defineMacro.js +1 -1
- package/src/postProcess.js +1 -1
- package/src/symbols.js +12 -8
- package/src/utils.js +10 -2
- package/temml.js +1 -1
package/README.md
CHANGED
package/dist/Temml-Asana.css
CHANGED
|
@@ -331,7 +331,7 @@ math > mrow {
|
|
|
331
331
|
|
|
332
332
|
/* Default mtd top padding is 0.5ex per MathML-Core and user-agent CSS */
|
|
333
333
|
/* We adjust for jot and small */
|
|
334
|
-
mtable.tml-jot mtd {
|
|
334
|
+
mtable.tml-jot > mtr > mtd {
|
|
335
335
|
padding-top: 0.7ex;
|
|
336
336
|
padding-bottom: 0.7ex;
|
|
337
337
|
}
|
|
@@ -347,7 +347,7 @@ mtable.tml-small mtd {
|
|
|
347
347
|
math > mrow { padding: 0 }
|
|
348
348
|
/* Adjust Firefox spacing between array rows */
|
|
349
349
|
mtd, mtable.tml-small mtd { padding-top: 0; padding-bottom: 0; }
|
|
350
|
-
mtable.tml-jot mtd { padding-top: 0.2ex; padding-bottom: 0.
|
|
350
|
+
mtable.tml-jot > mtr > mtd { padding-top: 0.2ex; padding-bottom: 0.2ex; }
|
|
351
351
|
}
|
|
352
352
|
|
|
353
353
|
/* AMS environment auto-numbering via CSS counter. */
|
|
@@ -349,7 +349,7 @@ math > mrow {
|
|
|
349
349
|
|
|
350
350
|
/* Default mtd top padding is 0.5ex per MathML-Core and user-agent CSS */
|
|
351
351
|
/* We adjust for jot and small */
|
|
352
|
-
mtable.tml-jot mtd {
|
|
352
|
+
mtable.tml-jot > mtr > mtd {
|
|
353
353
|
padding-top: 0.7ex;
|
|
354
354
|
padding-bottom: 0.7ex;
|
|
355
355
|
}
|
|
@@ -365,7 +365,7 @@ mtable.tml-small mtd {
|
|
|
365
365
|
math > mrow { padding: 0 }
|
|
366
366
|
/* Adjust Firefox spacing between array rows */
|
|
367
367
|
mtd, mtable.tml-small mtd { padding-top: 0; padding-bottom: 0; }
|
|
368
|
-
mtable.tml-jot mtd { padding-top: 0.2ex; padding-bottom: 0.
|
|
368
|
+
mtable.tml-jot > mtr > mtd { padding-top: 0.2ex; padding-bottom: 0.2ex; }
|
|
369
369
|
}
|
|
370
370
|
|
|
371
371
|
/* AMS environment auto-numbering via CSS counter. */
|
|
@@ -346,7 +346,7 @@ math > mrow {
|
|
|
346
346
|
|
|
347
347
|
/* Default mtd top padding is 0.5ex per MathML-Core and user-agent CSS */
|
|
348
348
|
/* We adjust for jot and small */
|
|
349
|
-
mtable.tml-jot mtd {
|
|
349
|
+
mtable.tml-jot > mtr > mtd {
|
|
350
350
|
padding-top: 0.7ex;
|
|
351
351
|
padding-bottom: 0.7ex;
|
|
352
352
|
}
|
|
@@ -362,7 +362,7 @@ mtable.tml-small mtd {
|
|
|
362
362
|
math > mrow { padding: 0 }
|
|
363
363
|
/* Adjust Firefox spacing between array rows */
|
|
364
364
|
mtd, mtable.tml-small mtd { padding-top: 0; padding-bottom: 0; }
|
|
365
|
-
mtable.tml-jot mtd { padding-top: 0.2ex; padding-bottom: 0.
|
|
365
|
+
mtable.tml-jot > mtr > mtd { padding-top: 0.2ex; padding-bottom: 0.2ex; }
|
|
366
366
|
}
|
|
367
367
|
|
|
368
368
|
/* AMS environment auto-numbering via CSS counter. */
|
package/dist/Temml-Local.css
CHANGED
|
@@ -342,7 +342,7 @@ math > mrow {
|
|
|
342
342
|
|
|
343
343
|
/* Default mtd top padding is 0.5ex per MathML-Core and user-agent CSS */
|
|
344
344
|
/* We adjust for jot and small */
|
|
345
|
-
mtable.tml-jot mtd {
|
|
345
|
+
mtable.tml-jot > mtr > mtd {
|
|
346
346
|
padding-top: 0.7ex;
|
|
347
347
|
padding-bottom: 0.7ex;
|
|
348
348
|
}
|
|
@@ -358,7 +358,7 @@ mtable.tml-small mtd {
|
|
|
358
358
|
math > mrow { padding: 0 }
|
|
359
359
|
/* Adjust Firefox spacing between array rows */
|
|
360
360
|
mtd, mtable.tml-small mtd { padding-top: 0; padding-bottom: 0; }
|
|
361
|
-
mtable.tml-jot mtd { padding-top: 0.2ex; padding-bottom: 0.
|
|
361
|
+
mtable.tml-jot > mtr > mtd { padding-top: 0.2ex; padding-bottom: 0.2ex; }
|
|
362
362
|
}
|
|
363
363
|
|
|
364
364
|
/* AMS environment auto-numbering via CSS counter. */
|
package/dist/Temml-NotoSans.css
CHANGED
|
@@ -346,7 +346,7 @@ math > mrow {
|
|
|
346
346
|
|
|
347
347
|
/* Default mtd top padding is 0.5ex per MathML-Core and user-agent CSS */
|
|
348
348
|
/* We adjust for jot and small */
|
|
349
|
-
mtable.tml-jot mtd {
|
|
349
|
+
mtable.tml-jot > mtr > mtd {
|
|
350
350
|
padding-top: 0.7ex;
|
|
351
351
|
padding-bottom: 0.7ex;
|
|
352
352
|
}
|
|
@@ -362,7 +362,7 @@ mtable.tml-small mtd {
|
|
|
362
362
|
math > mrow { padding: 0 }
|
|
363
363
|
/* Adjust Firefox spacing between array rows */
|
|
364
364
|
mtd, mtable.tml-small mtd { padding-top: 0; padding-bottom: 0; }
|
|
365
|
-
mtable.tml-jot mtd { padding-top: 0.2ex; padding-bottom: 0.
|
|
365
|
+
mtable.tml-jot > mtr > mtd { padding-top: 0.2ex; padding-bottom: 0.2ex; }
|
|
366
366
|
}
|
|
367
367
|
|
|
368
368
|
/* AMS environment auto-numbering via CSS counter. */
|
package/dist/Temml-STIX2.css
CHANGED
|
@@ -337,7 +337,7 @@ math > mrow {
|
|
|
337
337
|
|
|
338
338
|
/* Default mtd top padding is 0.5ex per MathML-Core and user-agent CSS */
|
|
339
339
|
/* We adjust for jot and small */
|
|
340
|
-
mtable.tml-jot mtd {
|
|
340
|
+
mtable.tml-jot > mtr > mtd {
|
|
341
341
|
padding-top: 0.7ex;
|
|
342
342
|
padding-bottom: 0.7ex;
|
|
343
343
|
}
|
|
@@ -353,7 +353,7 @@ mtable.tml-small mtd {
|
|
|
353
353
|
math > mrow { padding: 0 }
|
|
354
354
|
/* Adjust Firefox spacing between array rows */
|
|
355
355
|
mtd, mtable.tml-small mtd { padding-top: 0; padding-bottom: 0; }
|
|
356
|
-
mtable.tml-jot mtd { padding-top: 0.2ex; padding-bottom: 0.
|
|
356
|
+
mtable.tml-jot > mtr > mtd { padding-top: 0.2ex; padding-bottom: 0.2ex; }
|
|
357
357
|
}
|
|
358
358
|
|
|
359
359
|
/* AMS environment auto-numbering via CSS counter. */
|
package/dist/temml.cjs
CHANGED
|
@@ -70,9 +70,17 @@ ParseError.prototype.__proto__ = Error.prototype;
|
|
|
70
70
|
*/
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
|
-
*
|
|
73
|
+
* Look up `key` on a user-supplied `options` object and return its value, or
|
|
74
|
+
* `defaultIfUndefined` if the setting is absent. Reads via
|
|
75
|
+
* `Object.prototype.hasOwnProperty.call` rather than plain property access,
|
|
76
|
+
* so a key that only exists because `Object.prototype` was polluted
|
|
77
|
+
* elsewhere is never mistaken for a setting the caller actually provided.
|
|
74
78
|
*/
|
|
75
|
-
const deflt = function(
|
|
79
|
+
const deflt = function(options, key, defaultIfUndefined) {
|
|
80
|
+
if (!Object.prototype.hasOwnProperty.call(options, key)) {
|
|
81
|
+
return defaultIfUndefined;
|
|
82
|
+
}
|
|
83
|
+
const setting = options[key];
|
|
76
84
|
return setting === undefined ? defaultIfUndefined : setting;
|
|
77
85
|
};
|
|
78
86
|
|
|
@@ -190,6 +198,27 @@ const smalls = "acegıȷmnopqrsuvwxyzαγεηικμνοπρςστυχωϕ𝐚
|
|
|
190
198
|
*/
|
|
191
199
|
|
|
192
200
|
|
|
201
|
+
const FORBIDDEN_MACRO_KEYS = ["__proto__", "prototype", "constructor"];
|
|
202
|
+
|
|
203
|
+
// Sanitize a user-supplied macros object: strip its prototype (so later
|
|
204
|
+
// bracket-notation writes, e.g. from \gdef, can never reach Object.prototype)
|
|
205
|
+
// and delete any own key that could be used to pollute it. This mutates
|
|
206
|
+
// `macros` in place and returns the same reference, rather than a copy,
|
|
207
|
+
// because callers such as auto-render.js rely on that identity to share
|
|
208
|
+
// \gdef'd macros across multiple render calls that pass the same options
|
|
209
|
+
// object.
|
|
210
|
+
const sanitizeMacros = (macros) => {
|
|
211
|
+
if (macros == null || typeof macros !== "object") {
|
|
212
|
+
return Object.create(null);
|
|
213
|
+
}
|
|
214
|
+
for (const key of FORBIDDEN_MACRO_KEYS) {
|
|
215
|
+
if (Object.prototype.hasOwnProperty.call(macros, key)) {
|
|
216
|
+
delete macros[key];
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return Object.setPrototypeOf(macros, null);
|
|
220
|
+
};
|
|
221
|
+
|
|
193
222
|
/**
|
|
194
223
|
* The main Settings object
|
|
195
224
|
*/
|
|
@@ -197,24 +226,29 @@ class Settings {
|
|
|
197
226
|
constructor(options) {
|
|
198
227
|
// allow null options
|
|
199
228
|
options = options || {};
|
|
200
|
-
this.displayMode = deflt(options
|
|
201
|
-
this.annotate = deflt(options
|
|
202
|
-
this.leqno = deflt(options
|
|
203
|
-
this.throwOnError = deflt(options
|
|
204
|
-
this.errorColor = deflt(options
|
|
205
|
-
this.macros =
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
this.
|
|
209
|
-
this.
|
|
210
|
-
this.
|
|
211
|
-
this.
|
|
212
|
-
|
|
213
|
-
|
|
229
|
+
this.displayMode = deflt(options, "displayMode", false); // boolean
|
|
230
|
+
this.annotate = deflt(options, "annotate", false); // boolean
|
|
231
|
+
this.leqno = deflt(options, "leqno", false); // boolean
|
|
232
|
+
this.throwOnError = deflt(options, "throwOnError", false); // boolean
|
|
233
|
+
this.errorColor = deflt(options, "errorColor", "#b22222"); // string
|
|
234
|
+
this.macros = sanitizeMacros(
|
|
235
|
+
Object.prototype.hasOwnProperty.call(options, "macros") ? options.macros : undefined
|
|
236
|
+
);
|
|
237
|
+
this.wrap = deflt(options, "wrap", "none"); // "none" | "tex" | "="
|
|
238
|
+
this.xml = deflt(options, "xml", false); // boolean
|
|
239
|
+
this.colorIsTextColor = deflt(options, "colorIsTextColor", false); // boolean
|
|
240
|
+
this.strict = deflt(options, "strict", false); // boolean
|
|
241
|
+
this.trust = deflt(options, "trust", false); // trust context. See html.js.
|
|
242
|
+
const maxSize = Object.prototype.hasOwnProperty.call(options, "maxSize")
|
|
214
243
|
? options.maxSize
|
|
244
|
+
: undefined;
|
|
245
|
+
this.maxSize = (maxSize === undefined
|
|
246
|
+
? [Infinity, Infinity]
|
|
247
|
+
: Array.isArray(maxSize)
|
|
248
|
+
? maxSize
|
|
215
249
|
: [Infinity, Infinity]
|
|
216
250
|
);
|
|
217
|
-
this.maxExpand = Math.max(0, deflt(options
|
|
251
|
+
this.maxExpand = Math.max(0, deflt(options, "maxExpand", 1000)); // number
|
|
218
252
|
this.wrapDelimiterPairs = true; // boolean
|
|
219
253
|
}
|
|
220
254
|
|
|
@@ -914,22 +948,26 @@ const NON_ATOMS = {
|
|
|
914
948
|
textord: 1
|
|
915
949
|
};
|
|
916
950
|
|
|
917
|
-
const symbols =
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
};
|
|
951
|
+
const symbols = Object.create(null);
|
|
952
|
+
symbols.math = Object.create(null);
|
|
953
|
+
symbols.text = Object.create(null);
|
|
921
954
|
|
|
922
|
-
/** `acceptUnicodeChar = true` is only applicable if `replace` is set. */
|
|
923
955
|
function defineSymbol(mode, group, replace, name, acceptUnicodeChar) {
|
|
924
|
-
|
|
956
|
+
if (mode !== "math" && mode !== "text") {
|
|
957
|
+
throw new TypeError(`Invalid mode: ${mode} called in defineSymbol`);
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
const entry = { group, replace };
|
|
961
|
+
symbols[mode][name] = entry;
|
|
925
962
|
|
|
963
|
+
/** `acceptUnicodeChar = true` is only applicable if `replace` is set. */
|
|
926
964
|
if (acceptUnicodeChar && replace) {
|
|
927
|
-
symbols[mode][replace] =
|
|
965
|
+
symbols[mode][replace] = entry;
|
|
928
966
|
}
|
|
929
967
|
}
|
|
930
968
|
|
|
931
969
|
// Some abbreviations for commonly used strings.
|
|
932
|
-
// This helps minify the code, and also spotting typos
|
|
970
|
+
// This helps minify the code, and also spotting typos via linter.
|
|
933
971
|
|
|
934
972
|
// modes:
|
|
935
973
|
const math = "math";
|
|
@@ -3559,7 +3597,7 @@ const StyleLevel = {
|
|
|
3559
3597
|
* `macros.js` exports this same dictionary again and makes it public.
|
|
3560
3598
|
* `Parser.js` requires this dictionary via `macros.js`.
|
|
3561
3599
|
*/
|
|
3562
|
-
const _macros =
|
|
3600
|
+
const _macros = Object.create(null);
|
|
3563
3601
|
|
|
3564
3602
|
// This function might one day accept an additional argument and do more things.
|
|
3565
3603
|
function defineMacro(name, body) {
|
|
@@ -12000,7 +12038,7 @@ class Namespace {
|
|
|
12000
12038
|
* of initial (global-level) mappings, which will constantly change
|
|
12001
12039
|
* according to any global/top-level `set`s done.
|
|
12002
12040
|
*/
|
|
12003
|
-
constructor(builtins =
|
|
12041
|
+
constructor(builtins = Object.create(null), globalMacros = Object.create(null)) {
|
|
12004
12042
|
this.current = globalMacros;
|
|
12005
12043
|
this.builtins = builtins;
|
|
12006
12044
|
this.undefStack = [];
|
|
@@ -12010,7 +12048,7 @@ class Namespace {
|
|
|
12010
12048
|
* Start a new nested group, affecting future local `set`s.
|
|
12011
12049
|
*/
|
|
12012
12050
|
beginGroup() {
|
|
12013
|
-
this.undefStack.push(
|
|
12051
|
+
this.undefStack.push(Object.create(null));
|
|
12014
12052
|
}
|
|
12015
12053
|
|
|
12016
12054
|
/**
|
|
@@ -14208,7 +14246,7 @@ class Style {
|
|
|
14208
14246
|
* https://mit-license.org/
|
|
14209
14247
|
*/
|
|
14210
14248
|
|
|
14211
|
-
const version = "0.13.
|
|
14249
|
+
const version = "0.13.5";
|
|
14212
14250
|
|
|
14213
14251
|
function postProcess(block) {
|
|
14214
14252
|
const labelMap = {};
|
|
@@ -14529,7 +14567,7 @@ const renderMathInElement = function(elem, options) {
|
|
|
14529
14567
|
|
|
14530
14568
|
// Enable sharing of global macros defined via `\gdef` between different
|
|
14531
14569
|
// math elements within a single call to `renderMathInElement`.
|
|
14532
|
-
optionsCopy.macros = optionsCopy.macros ||
|
|
14570
|
+
optionsCopy.macros = optionsCopy.macros || Object.create(null);
|
|
14533
14571
|
|
|
14534
14572
|
renderElem(elem, optionsCopy);
|
|
14535
14573
|
postProcess(elem);
|
|
@@ -14608,7 +14646,7 @@ const generateParseTree = function(expression, options) {
|
|
|
14608
14646
|
*/
|
|
14609
14647
|
const definePreamble = function(expression, options) {
|
|
14610
14648
|
const settings = new Settings(options);
|
|
14611
|
-
settings.macros =
|
|
14649
|
+
settings.macros = Object.create(null);
|
|
14612
14650
|
if (!(typeof expression === "string" || expression instanceof String)) {
|
|
14613
14651
|
throw new TypeError("Temml can only parse string typed expression")
|
|
14614
14652
|
}
|
package/dist/temml.js
CHANGED
|
@@ -71,9 +71,17 @@ var temml = (function () {
|
|
|
71
71
|
*/
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
|
-
*
|
|
74
|
+
* Look up `key` on a user-supplied `options` object and return its value, or
|
|
75
|
+
* `defaultIfUndefined` if the setting is absent. Reads via
|
|
76
|
+
* `Object.prototype.hasOwnProperty.call` rather than plain property access,
|
|
77
|
+
* so a key that only exists because `Object.prototype` was polluted
|
|
78
|
+
* elsewhere is never mistaken for a setting the caller actually provided.
|
|
75
79
|
*/
|
|
76
|
-
const deflt = function(
|
|
80
|
+
const deflt = function(options, key, defaultIfUndefined) {
|
|
81
|
+
if (!Object.prototype.hasOwnProperty.call(options, key)) {
|
|
82
|
+
return defaultIfUndefined;
|
|
83
|
+
}
|
|
84
|
+
const setting = options[key];
|
|
77
85
|
return setting === undefined ? defaultIfUndefined : setting;
|
|
78
86
|
};
|
|
79
87
|
|
|
@@ -191,6 +199,27 @@ var temml = (function () {
|
|
|
191
199
|
*/
|
|
192
200
|
|
|
193
201
|
|
|
202
|
+
const FORBIDDEN_MACRO_KEYS = ["__proto__", "prototype", "constructor"];
|
|
203
|
+
|
|
204
|
+
// Sanitize a user-supplied macros object: strip its prototype (so later
|
|
205
|
+
// bracket-notation writes, e.g. from \gdef, can never reach Object.prototype)
|
|
206
|
+
// and delete any own key that could be used to pollute it. This mutates
|
|
207
|
+
// `macros` in place and returns the same reference, rather than a copy,
|
|
208
|
+
// because callers such as auto-render.js rely on that identity to share
|
|
209
|
+
// \gdef'd macros across multiple render calls that pass the same options
|
|
210
|
+
// object.
|
|
211
|
+
const sanitizeMacros = (macros) => {
|
|
212
|
+
if (macros == null || typeof macros !== "object") {
|
|
213
|
+
return Object.create(null);
|
|
214
|
+
}
|
|
215
|
+
for (const key of FORBIDDEN_MACRO_KEYS) {
|
|
216
|
+
if (Object.prototype.hasOwnProperty.call(macros, key)) {
|
|
217
|
+
delete macros[key];
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return Object.setPrototypeOf(macros, null);
|
|
221
|
+
};
|
|
222
|
+
|
|
194
223
|
/**
|
|
195
224
|
* The main Settings object
|
|
196
225
|
*/
|
|
@@ -198,24 +227,29 @@ var temml = (function () {
|
|
|
198
227
|
constructor(options) {
|
|
199
228
|
// allow null options
|
|
200
229
|
options = options || {};
|
|
201
|
-
this.displayMode = deflt(options
|
|
202
|
-
this.annotate = deflt(options
|
|
203
|
-
this.leqno = deflt(options
|
|
204
|
-
this.throwOnError = deflt(options
|
|
205
|
-
this.errorColor = deflt(options
|
|
206
|
-
this.macros =
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
this.
|
|
210
|
-
this.
|
|
211
|
-
this.
|
|
212
|
-
this.
|
|
213
|
-
|
|
214
|
-
|
|
230
|
+
this.displayMode = deflt(options, "displayMode", false); // boolean
|
|
231
|
+
this.annotate = deflt(options, "annotate", false); // boolean
|
|
232
|
+
this.leqno = deflt(options, "leqno", false); // boolean
|
|
233
|
+
this.throwOnError = deflt(options, "throwOnError", false); // boolean
|
|
234
|
+
this.errorColor = deflt(options, "errorColor", "#b22222"); // string
|
|
235
|
+
this.macros = sanitizeMacros(
|
|
236
|
+
Object.prototype.hasOwnProperty.call(options, "macros") ? options.macros : undefined
|
|
237
|
+
);
|
|
238
|
+
this.wrap = deflt(options, "wrap", "none"); // "none" | "tex" | "="
|
|
239
|
+
this.xml = deflt(options, "xml", false); // boolean
|
|
240
|
+
this.colorIsTextColor = deflt(options, "colorIsTextColor", false); // boolean
|
|
241
|
+
this.strict = deflt(options, "strict", false); // boolean
|
|
242
|
+
this.trust = deflt(options, "trust", false); // trust context. See html.js.
|
|
243
|
+
const maxSize = Object.prototype.hasOwnProperty.call(options, "maxSize")
|
|
215
244
|
? options.maxSize
|
|
245
|
+
: undefined;
|
|
246
|
+
this.maxSize = (maxSize === undefined
|
|
247
|
+
? [Infinity, Infinity]
|
|
248
|
+
: Array.isArray(maxSize)
|
|
249
|
+
? maxSize
|
|
216
250
|
: [Infinity, Infinity]
|
|
217
251
|
);
|
|
218
|
-
this.maxExpand = Math.max(0, deflt(options
|
|
252
|
+
this.maxExpand = Math.max(0, deflt(options, "maxExpand", 1000)); // number
|
|
219
253
|
this.wrapDelimiterPairs = true; // boolean
|
|
220
254
|
}
|
|
221
255
|
|
|
@@ -915,22 +949,26 @@ var temml = (function () {
|
|
|
915
949
|
textord: 1
|
|
916
950
|
};
|
|
917
951
|
|
|
918
|
-
const symbols =
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
};
|
|
952
|
+
const symbols = Object.create(null);
|
|
953
|
+
symbols.math = Object.create(null);
|
|
954
|
+
symbols.text = Object.create(null);
|
|
922
955
|
|
|
923
|
-
/** `acceptUnicodeChar = true` is only applicable if `replace` is set. */
|
|
924
956
|
function defineSymbol(mode, group, replace, name, acceptUnicodeChar) {
|
|
925
|
-
|
|
957
|
+
if (mode !== "math" && mode !== "text") {
|
|
958
|
+
throw new TypeError(`Invalid mode: ${mode} called in defineSymbol`);
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
const entry = { group, replace };
|
|
962
|
+
symbols[mode][name] = entry;
|
|
926
963
|
|
|
964
|
+
/** `acceptUnicodeChar = true` is only applicable if `replace` is set. */
|
|
927
965
|
if (acceptUnicodeChar && replace) {
|
|
928
|
-
symbols[mode][replace] =
|
|
966
|
+
symbols[mode][replace] = entry;
|
|
929
967
|
}
|
|
930
968
|
}
|
|
931
969
|
|
|
932
970
|
// Some abbreviations for commonly used strings.
|
|
933
|
-
// This helps minify the code, and also spotting typos
|
|
971
|
+
// This helps minify the code, and also spotting typos via linter.
|
|
934
972
|
|
|
935
973
|
// modes:
|
|
936
974
|
const math = "math";
|
|
@@ -3560,7 +3598,7 @@ var temml = (function () {
|
|
|
3560
3598
|
* `macros.js` exports this same dictionary again and makes it public.
|
|
3561
3599
|
* `Parser.js` requires this dictionary via `macros.js`.
|
|
3562
3600
|
*/
|
|
3563
|
-
const _macros =
|
|
3601
|
+
const _macros = Object.create(null);
|
|
3564
3602
|
|
|
3565
3603
|
// This function might one day accept an additional argument and do more things.
|
|
3566
3604
|
function defineMacro(name, body) {
|
|
@@ -10087,7 +10125,7 @@ var temml = (function () {
|
|
|
10087
10125
|
* of initial (global-level) mappings, which will constantly change
|
|
10088
10126
|
* according to any global/top-level `set`s done.
|
|
10089
10127
|
*/
|
|
10090
|
-
constructor(builtins =
|
|
10128
|
+
constructor(builtins = Object.create(null), globalMacros = Object.create(null)) {
|
|
10091
10129
|
this.current = globalMacros;
|
|
10092
10130
|
this.builtins = builtins;
|
|
10093
10131
|
this.undefStack = [];
|
|
@@ -10097,7 +10135,7 @@ var temml = (function () {
|
|
|
10097
10135
|
* Start a new nested group, affecting future local `set`s.
|
|
10098
10136
|
*/
|
|
10099
10137
|
beginGroup() {
|
|
10100
|
-
this.undefStack.push(
|
|
10138
|
+
this.undefStack.push(Object.create(null));
|
|
10101
10139
|
}
|
|
10102
10140
|
|
|
10103
10141
|
/**
|
|
@@ -12295,7 +12333,7 @@ var temml = (function () {
|
|
|
12295
12333
|
* https://mit-license.org/
|
|
12296
12334
|
*/
|
|
12297
12335
|
|
|
12298
|
-
const version = "0.13.
|
|
12336
|
+
const version = "0.13.5";
|
|
12299
12337
|
|
|
12300
12338
|
function postProcess(block) {
|
|
12301
12339
|
const labelMap = {};
|
|
@@ -12616,7 +12654,7 @@ var temml = (function () {
|
|
|
12616
12654
|
|
|
12617
12655
|
// Enable sharing of global macros defined via `\gdef` between different
|
|
12618
12656
|
// math elements within a single call to `renderMathInElement`.
|
|
12619
|
-
optionsCopy.macros = optionsCopy.macros ||
|
|
12657
|
+
optionsCopy.macros = optionsCopy.macros || Object.create(null);
|
|
12620
12658
|
|
|
12621
12659
|
renderElem(elem, optionsCopy);
|
|
12622
12660
|
postProcess(elem);
|
|
@@ -12695,7 +12733,7 @@ var temml = (function () {
|
|
|
12695
12733
|
*/
|
|
12696
12734
|
const definePreamble = function(expression, options) {
|
|
12697
12735
|
const settings = new Settings(options);
|
|
12698
|
-
settings.macros =
|
|
12736
|
+
settings.macros = Object.create(null);
|
|
12699
12737
|
if (!(typeof expression === "string" || expression instanceof String)) {
|
|
12700
12738
|
throw new TypeError("Temml can only parse string typed expression")
|
|
12701
12739
|
}
|