temml 0.10.9 → 0.10.12
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/dist/temml.cjs +13 -113
- package/dist/temml.js +13 -113
- package/dist/temml.min.js +1 -1
- package/dist/temml.mjs +13 -113
- package/dist/temmlPostProcess.js +1 -1
- package/package.json +2 -2
- package/src/Parser.js +2 -8
- package/src/Settings.js +1 -0
- package/src/buildMathML.js +1 -1
- package/src/functions/mclass.js +4 -1
- package/src/functions/symbolsOrd.js +2 -0
- package/src/postProcess.js +1 -1
- package/src/symbols.js +3 -0
- package/src/unicodeScripts.js +0 -119
package/dist/temml.cjs
CHANGED
@@ -188,6 +188,7 @@ class Settings {
|
|
188
188
|
this.displayMode = utils.deflt(options.displayMode, false); // boolean
|
189
189
|
this.annotate = utils.deflt(options.annotate, false); // boolean
|
190
190
|
this.leqno = utils.deflt(options.leqno, false); // boolean
|
191
|
+
this.throwOnError = utils.deflt(options.throwOnError, false); // boolean
|
191
192
|
this.errorColor = utils.deflt(options.errorColor, "#b22222"); // string
|
192
193
|
this.macros = options.macros || {};
|
193
194
|
this.wrap = utils.deflt(options.wrap, "tex"); // "tex" | "="
|
@@ -865,6 +866,9 @@ defineSymbol(math, rel, "\u225e", "\\measeq", true);
|
|
865
866
|
defineSymbol(math, rel, "\u225f", "\\questeq", true);
|
866
867
|
defineSymbol(math, rel, "\u2260", "\\ne", true);
|
867
868
|
defineSymbol(math, rel, "\u2260", "\\neq");
|
869
|
+
// unicodemath
|
870
|
+
defineSymbol(math, rel, "\u2a75", "\\eqeq", true);
|
871
|
+
defineSymbol(math, rel, "\u2a76", "\\eqeqeq", true);
|
868
872
|
// mathtools.sty
|
869
873
|
defineSymbol(math, rel, "\u2237", "\\dblcolon", true);
|
870
874
|
defineSymbol(math, rel, "\u2254", "\\coloneqq", true);
|
@@ -2130,7 +2134,7 @@ function buildMathML(tree, texExpression, style, settings) {
|
|
2130
2134
|
math.setAttribute("display", "block");
|
2131
2135
|
math.style.display = math.children.length === 1 && math.children[0].type === "mtable"
|
2132
2136
|
? "inline"
|
2133
|
-
: "
|
2137
|
+
: "block math";
|
2134
2138
|
}
|
2135
2139
|
return math;
|
2136
2140
|
}
|
@@ -6001,7 +6005,9 @@ defineFunction({
|
|
6001
6005
|
const arr = (body.body) ? body.body : [body];
|
6002
6006
|
for (const arg of arr) {
|
6003
6007
|
if (textAtomTypes.includes(arg.type)) {
|
6004
|
-
if (arg.text) {
|
6008
|
+
if (symbols[parser.mode][arg.text]) {
|
6009
|
+
mord.text += symbols[parser.mode][arg.text].replace;
|
6010
|
+
} else if (arg.text) {
|
6005
6011
|
mord.text += arg.text;
|
6006
6012
|
} else if (arg.body) {
|
6007
6013
|
arg.body.map(e => { mord.text += e.text; });
|
@@ -7748,6 +7754,8 @@ defineFunctionBuilders({
|
|
7748
7754
|
node = new mathMLTree.MathNode("mi", [text]);
|
7749
7755
|
if (text.text === origText && latinRegEx.test(origText)) {
|
7750
7756
|
node.setAttribute("mathvariant", "italic");
|
7757
|
+
} else if (text.text === "∇" && variant === "normal") {
|
7758
|
+
node.setAttribute("mathvariant", "normal");
|
7751
7759
|
}
|
7752
7760
|
}
|
7753
7761
|
return node
|
@@ -11235,109 +11243,6 @@ class MacroExpander {
|
|
11235
11243
|
}
|
11236
11244
|
}
|
11237
11245
|
|
11238
|
-
/*
|
11239
|
-
* This file defines the Unicode scripts and script families that we
|
11240
|
-
* support. To add new scripts or families, just add a new entry to the
|
11241
|
-
* scriptData array below. Adding scripts to the scriptData array allows
|
11242
|
-
* characters from that script to appear in \text{} environments.
|
11243
|
-
*/
|
11244
|
-
|
11245
|
-
/**
|
11246
|
-
* Each script or script family has a name and an array of blocks.
|
11247
|
-
* Each block is an array of two numbers which specify the start and
|
11248
|
-
* end points (inclusive) of a block of Unicode codepoints.
|
11249
|
-
|
11250
|
-
/**
|
11251
|
-
* Unicode block data for the families of scripts we support in \text{}.
|
11252
|
-
* Scripts only need to appear here if they do not have font metrics.
|
11253
|
-
*/
|
11254
|
-
const scriptData = [
|
11255
|
-
{
|
11256
|
-
// Latin characters beyond the Latin-1 characters we have metrics for.
|
11257
|
-
// Needed for Czech, Hungarian and Turkish text, for example.
|
11258
|
-
name: "latin",
|
11259
|
-
blocks: [
|
11260
|
-
[0x0100, 0x024f], // Latin Extended-A and Latin Extended-B
|
11261
|
-
[0x0300, 0x036f] // Combining Diacritical marks
|
11262
|
-
]
|
11263
|
-
},
|
11264
|
-
{
|
11265
|
-
// The Cyrillic script used by Russian and related languages.
|
11266
|
-
// A Cyrillic subset used to be supported as explicitly defined
|
11267
|
-
// symbols in symbols.js
|
11268
|
-
name: "cyrillic",
|
11269
|
-
blocks: [[0x0400, 0x04ff]]
|
11270
|
-
},
|
11271
|
-
{
|
11272
|
-
// Armenian
|
11273
|
-
name: "armenian",
|
11274
|
-
blocks: [[0x0530, 0x058f]]
|
11275
|
-
},
|
11276
|
-
{
|
11277
|
-
// The Brahmic scripts of South and Southeast Asia
|
11278
|
-
// Devanagari (0900–097F)
|
11279
|
-
// Bengali (0980–09FF)
|
11280
|
-
// Gurmukhi (0A00–0A7F)
|
11281
|
-
// Gujarati (0A80–0AFF)
|
11282
|
-
// Oriya (0B00–0B7F)
|
11283
|
-
// Tamil (0B80–0BFF)
|
11284
|
-
// Telugu (0C00–0C7F)
|
11285
|
-
// Kannada (0C80–0CFF)
|
11286
|
-
// Malayalam (0D00–0D7F)
|
11287
|
-
// Sinhala (0D80–0DFF)
|
11288
|
-
// Thai (0E00–0E7F)
|
11289
|
-
// Lao (0E80–0EFF)
|
11290
|
-
// Tibetan (0F00–0FFF)
|
11291
|
-
// Myanmar (1000–109F)
|
11292
|
-
name: "brahmic",
|
11293
|
-
blocks: [[0x0900, 0x109f]]
|
11294
|
-
},
|
11295
|
-
{
|
11296
|
-
name: "georgian",
|
11297
|
-
blocks: [[0x10a0, 0x10ff]]
|
11298
|
-
},
|
11299
|
-
{
|
11300
|
-
// Chinese and Japanese.
|
11301
|
-
// The "k" in cjk is for Korean, but we've separated Korean out
|
11302
|
-
name: "cjk",
|
11303
|
-
blocks: [
|
11304
|
-
[0x3000, 0x30ff], // CJK symbols and punctuation, Hiragana, Katakana
|
11305
|
-
[0x4e00, 0x9faf], // CJK ideograms
|
11306
|
-
[0xff00, 0xff60] // Fullwidth punctuation
|
11307
|
-
// TODO: add halfwidth Katakana and Romanji glyphs
|
11308
|
-
]
|
11309
|
-
},
|
11310
|
-
{
|
11311
|
-
// Korean
|
11312
|
-
name: "hangul",
|
11313
|
-
blocks: [[0xac00, 0xd7af]]
|
11314
|
-
}
|
11315
|
-
];
|
11316
|
-
|
11317
|
-
/**
|
11318
|
-
* A flattened version of all the supported blocks in a single array.
|
11319
|
-
* This is an optimization to make supportedCodepoint() fast.
|
11320
|
-
*/
|
11321
|
-
const allBlocks = [];
|
11322
|
-
scriptData.forEach((s) => s.blocks.forEach((b) => allBlocks.push(...b)));
|
11323
|
-
|
11324
|
-
/**
|
11325
|
-
* Given a codepoint, return true if it falls within one of the
|
11326
|
-
* scripts or script families defined above and false otherwise.
|
11327
|
-
*
|
11328
|
-
* Micro benchmarks shows that this is faster than
|
11329
|
-
* /[\u3000-\u30FF\u4E00-\u9FAF\uFF00-\uFF60\uAC00-\uD7AF\u0900-\u109F]/.test()
|
11330
|
-
* in Firefox, Chrome and Node.
|
11331
|
-
*/
|
11332
|
-
function supportedCodepoint(codepoint) {
|
11333
|
-
for (let i = 0; i < allBlocks.length; i += 2) {
|
11334
|
-
if (codepoint >= allBlocks[i] && codepoint <= allBlocks[i + 1]) {
|
11335
|
-
return true;
|
11336
|
-
}
|
11337
|
-
}
|
11338
|
-
return false;
|
11339
|
-
}
|
11340
|
-
|
11341
11246
|
// Helpers for Parser.js handling of Unicode (sub|super)script characters.
|
11342
11247
|
|
11343
11248
|
const unicodeSubRegEx = /^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/;
|
@@ -12740,13 +12645,8 @@ class Parser {
|
|
12740
12645
|
symbol = s;
|
12741
12646
|
} else if (text.charCodeAt(0) >= 0x80) {
|
12742
12647
|
// no symbol for e.g. ^
|
12743
|
-
if (this.settings.strict) {
|
12744
|
-
|
12745
|
-
throw new ParseError(`Unrecognized Unicode character "${text[0]}"` +
|
12746
|
-
` (${text.charCodeAt(0)})`, nucleus);
|
12747
|
-
} else if (this.mode === "math") {
|
12748
|
-
throw new ParseError(`Unicode text character "${text[0]}" used in math mode`, nucleus)
|
12749
|
-
}
|
12648
|
+
if (this.settings.strict && this.mode === "math") {
|
12649
|
+
throw new ParseError(`Unicode text character "${text[0]}" used in math mode`, nucleus)
|
12750
12650
|
}
|
12751
12651
|
// All nonmathematical Unicode characters are rendered as if they
|
12752
12652
|
// are in text mode (wrapped in \text) because that's what it
|
@@ -12977,7 +12877,7 @@ class Style {
|
|
12977
12877
|
* https://mit-license.org/
|
12978
12878
|
*/
|
12979
12879
|
|
12980
|
-
const version = "0.10.
|
12880
|
+
const version = "0.10.12";
|
12981
12881
|
|
12982
12882
|
function postProcess(block) {
|
12983
12883
|
const labelMap = {};
|
package/dist/temml.js
CHANGED
@@ -189,6 +189,7 @@ var temml = (function () {
|
|
189
189
|
this.displayMode = utils.deflt(options.displayMode, false); // boolean
|
190
190
|
this.annotate = utils.deflt(options.annotate, false); // boolean
|
191
191
|
this.leqno = utils.deflt(options.leqno, false); // boolean
|
192
|
+
this.throwOnError = utils.deflt(options.throwOnError, false); // boolean
|
192
193
|
this.errorColor = utils.deflt(options.errorColor, "#b22222"); // string
|
193
194
|
this.macros = options.macros || {};
|
194
195
|
this.wrap = utils.deflt(options.wrap, "tex"); // "tex" | "="
|
@@ -866,6 +867,9 @@ var temml = (function () {
|
|
866
867
|
defineSymbol(math, rel, "\u225f", "\\questeq", true);
|
867
868
|
defineSymbol(math, rel, "\u2260", "\\ne", true);
|
868
869
|
defineSymbol(math, rel, "\u2260", "\\neq");
|
870
|
+
// unicodemath
|
871
|
+
defineSymbol(math, rel, "\u2a75", "\\eqeq", true);
|
872
|
+
defineSymbol(math, rel, "\u2a76", "\\eqeqeq", true);
|
869
873
|
// mathtools.sty
|
870
874
|
defineSymbol(math, rel, "\u2237", "\\dblcolon", true);
|
871
875
|
defineSymbol(math, rel, "\u2254", "\\coloneqq", true);
|
@@ -2131,7 +2135,7 @@ var temml = (function () {
|
|
2131
2135
|
math.setAttribute("display", "block");
|
2132
2136
|
math.style.display = math.children.length === 1 && math.children[0].type === "mtable"
|
2133
2137
|
? "inline"
|
2134
|
-
: "
|
2138
|
+
: "block math";
|
2135
2139
|
}
|
2136
2140
|
return math;
|
2137
2141
|
}
|
@@ -6002,7 +6006,9 @@ var temml = (function () {
|
|
6002
6006
|
const arr = (body.body) ? body.body : [body];
|
6003
6007
|
for (const arg of arr) {
|
6004
6008
|
if (textAtomTypes.includes(arg.type)) {
|
6005
|
-
if (arg.text) {
|
6009
|
+
if (symbols[parser.mode][arg.text]) {
|
6010
|
+
mord.text += symbols[parser.mode][arg.text].replace;
|
6011
|
+
} else if (arg.text) {
|
6006
6012
|
mord.text += arg.text;
|
6007
6013
|
} else if (arg.body) {
|
6008
6014
|
arg.body.map(e => { mord.text += e.text; });
|
@@ -7749,6 +7755,8 @@ var temml = (function () {
|
|
7749
7755
|
node = new mathMLTree.MathNode("mi", [text]);
|
7750
7756
|
if (text.text === origText && latinRegEx.test(origText)) {
|
7751
7757
|
node.setAttribute("mathvariant", "italic");
|
7758
|
+
} else if (text.text === "∇" && variant === "normal") {
|
7759
|
+
node.setAttribute("mathvariant", "normal");
|
7752
7760
|
}
|
7753
7761
|
}
|
7754
7762
|
return node
|
@@ -9336,109 +9344,6 @@ var temml = (function () {
|
|
9336
9344
|
}
|
9337
9345
|
}
|
9338
9346
|
|
9339
|
-
/*
|
9340
|
-
* This file defines the Unicode scripts and script families that we
|
9341
|
-
* support. To add new scripts or families, just add a new entry to the
|
9342
|
-
* scriptData array below. Adding scripts to the scriptData array allows
|
9343
|
-
* characters from that script to appear in \text{} environments.
|
9344
|
-
*/
|
9345
|
-
|
9346
|
-
/**
|
9347
|
-
* Each script or script family has a name and an array of blocks.
|
9348
|
-
* Each block is an array of two numbers which specify the start and
|
9349
|
-
* end points (inclusive) of a block of Unicode codepoints.
|
9350
|
-
|
9351
|
-
/**
|
9352
|
-
* Unicode block data for the families of scripts we support in \text{}.
|
9353
|
-
* Scripts only need to appear here if they do not have font metrics.
|
9354
|
-
*/
|
9355
|
-
const scriptData = [
|
9356
|
-
{
|
9357
|
-
// Latin characters beyond the Latin-1 characters we have metrics for.
|
9358
|
-
// Needed for Czech, Hungarian and Turkish text, for example.
|
9359
|
-
name: "latin",
|
9360
|
-
blocks: [
|
9361
|
-
[0x0100, 0x024f], // Latin Extended-A and Latin Extended-B
|
9362
|
-
[0x0300, 0x036f] // Combining Diacritical marks
|
9363
|
-
]
|
9364
|
-
},
|
9365
|
-
{
|
9366
|
-
// The Cyrillic script used by Russian and related languages.
|
9367
|
-
// A Cyrillic subset used to be supported as explicitly defined
|
9368
|
-
// symbols in symbols.js
|
9369
|
-
name: "cyrillic",
|
9370
|
-
blocks: [[0x0400, 0x04ff]]
|
9371
|
-
},
|
9372
|
-
{
|
9373
|
-
// Armenian
|
9374
|
-
name: "armenian",
|
9375
|
-
blocks: [[0x0530, 0x058f]]
|
9376
|
-
},
|
9377
|
-
{
|
9378
|
-
// The Brahmic scripts of South and Southeast Asia
|
9379
|
-
// Devanagari (0900–097F)
|
9380
|
-
// Bengali (0980–09FF)
|
9381
|
-
// Gurmukhi (0A00–0A7F)
|
9382
|
-
// Gujarati (0A80–0AFF)
|
9383
|
-
// Oriya (0B00–0B7F)
|
9384
|
-
// Tamil (0B80–0BFF)
|
9385
|
-
// Telugu (0C00–0C7F)
|
9386
|
-
// Kannada (0C80–0CFF)
|
9387
|
-
// Malayalam (0D00–0D7F)
|
9388
|
-
// Sinhala (0D80–0DFF)
|
9389
|
-
// Thai (0E00–0E7F)
|
9390
|
-
// Lao (0E80–0EFF)
|
9391
|
-
// Tibetan (0F00–0FFF)
|
9392
|
-
// Myanmar (1000–109F)
|
9393
|
-
name: "brahmic",
|
9394
|
-
blocks: [[0x0900, 0x109f]]
|
9395
|
-
},
|
9396
|
-
{
|
9397
|
-
name: "georgian",
|
9398
|
-
blocks: [[0x10a0, 0x10ff]]
|
9399
|
-
},
|
9400
|
-
{
|
9401
|
-
// Chinese and Japanese.
|
9402
|
-
// The "k" in cjk is for Korean, but we've separated Korean out
|
9403
|
-
name: "cjk",
|
9404
|
-
blocks: [
|
9405
|
-
[0x3000, 0x30ff], // CJK symbols and punctuation, Hiragana, Katakana
|
9406
|
-
[0x4e00, 0x9faf], // CJK ideograms
|
9407
|
-
[0xff00, 0xff60] // Fullwidth punctuation
|
9408
|
-
// TODO: add halfwidth Katakana and Romanji glyphs
|
9409
|
-
]
|
9410
|
-
},
|
9411
|
-
{
|
9412
|
-
// Korean
|
9413
|
-
name: "hangul",
|
9414
|
-
blocks: [[0xac00, 0xd7af]]
|
9415
|
-
}
|
9416
|
-
];
|
9417
|
-
|
9418
|
-
/**
|
9419
|
-
* A flattened version of all the supported blocks in a single array.
|
9420
|
-
* This is an optimization to make supportedCodepoint() fast.
|
9421
|
-
*/
|
9422
|
-
const allBlocks = [];
|
9423
|
-
scriptData.forEach((s) => s.blocks.forEach((b) => allBlocks.push(...b)));
|
9424
|
-
|
9425
|
-
/**
|
9426
|
-
* Given a codepoint, return true if it falls within one of the
|
9427
|
-
* scripts or script families defined above and false otherwise.
|
9428
|
-
*
|
9429
|
-
* Micro benchmarks shows that this is faster than
|
9430
|
-
* /[\u3000-\u30FF\u4E00-\u9FAF\uFF00-\uFF60\uAC00-\uD7AF\u0900-\u109F]/.test()
|
9431
|
-
* in Firefox, Chrome and Node.
|
9432
|
-
*/
|
9433
|
-
function supportedCodepoint(codepoint) {
|
9434
|
-
for (let i = 0; i < allBlocks.length; i += 2) {
|
9435
|
-
if (codepoint >= allBlocks[i] && codepoint <= allBlocks[i + 1]) {
|
9436
|
-
return true;
|
9437
|
-
}
|
9438
|
-
}
|
9439
|
-
return false;
|
9440
|
-
}
|
9441
|
-
|
9442
9347
|
// Helpers for Parser.js handling of Unicode (sub|super)script characters.
|
9443
9348
|
|
9444
9349
|
const unicodeSubRegEx = /^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/;
|
@@ -10841,13 +10746,8 @@ var temml = (function () {
|
|
10841
10746
|
symbol = s;
|
10842
10747
|
} else if (text.charCodeAt(0) >= 0x80) {
|
10843
10748
|
// no symbol for e.g. ^
|
10844
|
-
if (this.settings.strict) {
|
10845
|
-
|
10846
|
-
throw new ParseError(`Unrecognized Unicode character "${text[0]}"` +
|
10847
|
-
` (${text.charCodeAt(0)})`, nucleus);
|
10848
|
-
} else if (this.mode === "math") {
|
10849
|
-
throw new ParseError(`Unicode text character "${text[0]}" used in math mode`, nucleus)
|
10850
|
-
}
|
10749
|
+
if (this.settings.strict && this.mode === "math") {
|
10750
|
+
throw new ParseError(`Unicode text character "${text[0]}" used in math mode`, nucleus)
|
10851
10751
|
}
|
10852
10752
|
// All nonmathematical Unicode characters are rendered as if they
|
10853
10753
|
// are in text mode (wrapped in \text) because that's what it
|
@@ -11078,7 +10978,7 @@ var temml = (function () {
|
|
11078
10978
|
* https://mit-license.org/
|
11079
10979
|
*/
|
11080
10980
|
|
11081
|
-
const version = "0.10.
|
10981
|
+
const version = "0.10.12";
|
11082
10982
|
|
11083
10983
|
function postProcess(block) {
|
11084
10984
|
const labelMap = {};
|