temml 0.10.10 → 0.10.13
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 +64 -29
- package/dist/temml.js +64 -29
- package/dist/temml.min.js +1 -1
- package/dist/temml.mjs +64 -29
- package/dist/temmlPostProcess.js +1 -1
- package/package.json +5 -2
- package/src/Settings.js +1 -0
- package/src/buildMathML.js +1 -1
- package/src/functions/arrow.js +50 -24
- package/src/functions/mclass.js +4 -1
- package/src/functions/symbolsOrd.js +2 -0
- package/src/postProcess.js +1 -1
- package/src/symbols.js +4 -0
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);
|
@@ -966,6 +970,7 @@ defineSymbol(math, rel, "\u21c1", "\\rightharpoondown", true);
|
|
966
970
|
defineSymbol(math, rel, "\u2196", "\\nwarrow", true);
|
967
971
|
defineSymbol(math, rel, "\u21cc", "\\rightleftharpoons", true);
|
968
972
|
defineSymbol(math, mathord, "\u21af", "\\lightning", true);
|
973
|
+
defineSymbol(math, mathord, "\u220E", "\\QED", true);
|
969
974
|
defineSymbol(math, mathord, "\u2030", "\\permil", true);
|
970
975
|
defineSymbol(text, textord, "\u2030", "\\permil");
|
971
976
|
|
@@ -2130,7 +2135,7 @@ function buildMathML(tree, texExpression, style, settings) {
|
|
2130
2135
|
math.setAttribute("display", "block");
|
2131
2136
|
math.style.display = math.children.length === 1 && math.children[0].type === "mtable"
|
2132
2137
|
? "inline"
|
2133
|
-
: "
|
2138
|
+
: "block math";
|
2134
2139
|
}
|
2135
2140
|
return math;
|
2136
2141
|
}
|
@@ -2414,43 +2419,69 @@ const paddedNode = (group, lspace = 0.3, rspace = 0) => {
|
|
2414
2419
|
return new mathMLTree.MathNode("mrow", row)
|
2415
2420
|
};
|
2416
2421
|
|
2417
|
-
const labelSize = (size, scriptLevel) => (size / emScale(scriptLevel)
|
2422
|
+
const labelSize = (size, scriptLevel) => Number(size) / emScale(scriptLevel);
|
2418
2423
|
|
2419
|
-
const munderoverNode = (
|
2420
|
-
const arrowNode = stretchy.mathMLnode(
|
2424
|
+
const munderoverNode = (fName, body, below, style) => {
|
2425
|
+
const arrowNode = stretchy.mathMLnode(fName);
|
2421
2426
|
// Is this the short part of a mhchem equilibrium arrow?
|
2422
|
-
const isEq =
|
2423
|
-
const minWidth =
|
2424
|
-
? "1.75" // mathtools extensible arrows are 1.75em long
|
2425
|
-
:
|
2427
|
+
const isEq = fName.slice(1, 3) === "eq";
|
2428
|
+
const minWidth = fName.charAt(1) === "x"
|
2429
|
+
? "1.75" // mathtools extensible arrows are ≥ 1.75em long
|
2430
|
+
: fName.slice(2, 4) === "cd"
|
2426
2431
|
? "3.0" // cd package arrows
|
2427
2432
|
: isEq
|
2428
2433
|
? "1.0" // The shorter harpoon of a mhchem equilibrium arrow
|
2429
2434
|
: "2.0"; // other mhchem arrows
|
2430
|
-
|
2435
|
+
// TODO: When Firefox supports minsize, use the next line.
|
2436
|
+
//arrowNode.setAttribute("minsize", String(minWidth) + "em")
|
2431
2437
|
arrowNode.setAttribute("lspace", "0");
|
2432
2438
|
arrowNode.setAttribute("rspace", (isEq ? "0.5em" : "0"));
|
2433
2439
|
|
2434
2440
|
// <munderover> upper and lower labels are set to scriptlevel by MathML
|
2435
|
-
// So we have to adjust our dimensions accordingly.
|
2441
|
+
// So we have to adjust our label dimensions accordingly.
|
2436
2442
|
const labelStyle = style.withLevel(style.level < 2 ? 2 : 3);
|
2437
|
-
const
|
2438
|
-
|
2439
|
-
|
2440
|
-
|
2441
|
-
const
|
2443
|
+
const minArrowWidth = labelSize(minWidth, labelStyle.level);
|
2444
|
+
// The dummyNode will be inside a <mover> inside a <mover>
|
2445
|
+
// So it will be at scriptlevel 3
|
2446
|
+
const dummyWidth = labelSize(minWidth, 3);
|
2447
|
+
const emptyLabel = paddedNode(null, minArrowWidth.toFixed(4), 0);
|
2448
|
+
const dummyNode = paddedNode(null, dummyWidth.toFixed(4), 0);
|
2449
|
+
// The arrow is a little longer than the label. Set a spacer length.
|
2450
|
+
const space = labelSize((isEq ? 0 : 0.3), labelStyle.level).toFixed(4);
|
2451
|
+
let upperNode;
|
2452
|
+
let lowerNode;
|
2453
|
+
|
2454
|
+
const gotUpper = (body && body.body &&
|
2442
2455
|
// \hphantom visible content
|
2443
|
-
(body.body.body || body.body.length > 0))
|
2444
|
-
|
2445
|
-
|
2446
|
-
|
2447
|
-
|
2448
|
-
|
2449
|
-
|
2450
|
-
|
2451
|
-
|
2452
|
-
const
|
2453
|
-
|
2456
|
+
(body.body.body || body.body.length > 0));
|
2457
|
+
if (gotUpper) {
|
2458
|
+
let label = buildGroup$1(body, labelStyle);
|
2459
|
+
label = paddedNode(label, space, space);
|
2460
|
+
// Since Firefox does not support minsize, stack a invisible node
|
2461
|
+
// on top of the label. Its width will serve as a min-width.
|
2462
|
+
// TODO: Refactor this after Firefox supports minsize.
|
2463
|
+
upperNode = new mathMLTree.MathNode("mover", [label, dummyNode]);
|
2464
|
+
}
|
2465
|
+
const gotLower = (below && below.body &&
|
2466
|
+
(below.body.body || below.body.length > 0));
|
2467
|
+
if (gotLower) {
|
2468
|
+
let label = buildGroup$1(below, labelStyle);
|
2469
|
+
label = paddedNode(label, space, space);
|
2470
|
+
lowerNode = new mathMLTree.MathNode("munder", [label, dummyNode]);
|
2471
|
+
}
|
2472
|
+
|
2473
|
+
let node;
|
2474
|
+
if (!gotUpper && !gotLower) {
|
2475
|
+
node = new mathMLTree.MathNode("mover", [arrowNode, emptyLabel]);
|
2476
|
+
} else if (gotUpper && gotLower) {
|
2477
|
+
node = new mathMLTree.MathNode("munderover", [arrowNode, lowerNode, upperNode]);
|
2478
|
+
} else if (gotUpper) {
|
2479
|
+
node = new mathMLTree.MathNode("mover", [arrowNode, upperNode]);
|
2480
|
+
} else {
|
2481
|
+
node = new mathMLTree.MathNode("munder", [arrowNode, lowerNode]);
|
2482
|
+
}
|
2483
|
+
if (minWidth === "3.0") { node.style.height = "1em"; } // CD environment
|
2484
|
+
node.setAttribute("accent", "false"); // Necessary for MS Word
|
2454
2485
|
return node
|
2455
2486
|
};
|
2456
2487
|
|
@@ -2529,7 +2560,7 @@ defineFunction({
|
|
2529
2560
|
"\\xleftrightharpoons", // mathtools
|
2530
2561
|
"\\xrightleftharpoons", // mathtools
|
2531
2562
|
"\\yieldsLeftRight", // mhchem
|
2532
|
-
"\\equilibrium",
|
2563
|
+
"\\equilibrium", // mhchem
|
2533
2564
|
"\\equilibriumRight",
|
2534
2565
|
"\\equilibriumLeft"
|
2535
2566
|
],
|
@@ -6001,7 +6032,9 @@ defineFunction({
|
|
6001
6032
|
const arr = (body.body) ? body.body : [body];
|
6002
6033
|
for (const arg of arr) {
|
6003
6034
|
if (textAtomTypes.includes(arg.type)) {
|
6004
|
-
if (arg.text) {
|
6035
|
+
if (symbols[parser.mode][arg.text]) {
|
6036
|
+
mord.text += symbols[parser.mode][arg.text].replace;
|
6037
|
+
} else if (arg.text) {
|
6005
6038
|
mord.text += arg.text;
|
6006
6039
|
} else if (arg.body) {
|
6007
6040
|
arg.body.map(e => { mord.text += e.text; });
|
@@ -7748,6 +7781,8 @@ defineFunctionBuilders({
|
|
7748
7781
|
node = new mathMLTree.MathNode("mi", [text]);
|
7749
7782
|
if (text.text === origText && latinRegEx.test(origText)) {
|
7750
7783
|
node.setAttribute("mathvariant", "italic");
|
7784
|
+
} else if (text.text === "∇" && variant === "normal") {
|
7785
|
+
node.setAttribute("mathvariant", "normal");
|
7751
7786
|
}
|
7752
7787
|
}
|
7753
7788
|
return node
|
@@ -12869,7 +12904,7 @@ class Style {
|
|
12869
12904
|
* https://mit-license.org/
|
12870
12905
|
*/
|
12871
12906
|
|
12872
|
-
const version = "0.10.
|
12907
|
+
const version = "0.10.13";
|
12873
12908
|
|
12874
12909
|
function postProcess(block) {
|
12875
12910
|
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);
|
@@ -967,6 +971,7 @@ var temml = (function () {
|
|
967
971
|
defineSymbol(math, rel, "\u2196", "\\nwarrow", true);
|
968
972
|
defineSymbol(math, rel, "\u21cc", "\\rightleftharpoons", true);
|
969
973
|
defineSymbol(math, mathord, "\u21af", "\\lightning", true);
|
974
|
+
defineSymbol(math, mathord, "\u220E", "\\QED", true);
|
970
975
|
defineSymbol(math, mathord, "\u2030", "\\permil", true);
|
971
976
|
defineSymbol(text, textord, "\u2030", "\\permil");
|
972
977
|
|
@@ -2131,7 +2136,7 @@ var temml = (function () {
|
|
2131
2136
|
math.setAttribute("display", "block");
|
2132
2137
|
math.style.display = math.children.length === 1 && math.children[0].type === "mtable"
|
2133
2138
|
? "inline"
|
2134
|
-
: "
|
2139
|
+
: "block math";
|
2135
2140
|
}
|
2136
2141
|
return math;
|
2137
2142
|
}
|
@@ -2415,43 +2420,69 @@ var temml = (function () {
|
|
2415
2420
|
return new mathMLTree.MathNode("mrow", row)
|
2416
2421
|
};
|
2417
2422
|
|
2418
|
-
const labelSize = (size, scriptLevel) => (size / emScale(scriptLevel)
|
2423
|
+
const labelSize = (size, scriptLevel) => Number(size) / emScale(scriptLevel);
|
2419
2424
|
|
2420
|
-
const munderoverNode = (
|
2421
|
-
const arrowNode = stretchy.mathMLnode(
|
2425
|
+
const munderoverNode = (fName, body, below, style) => {
|
2426
|
+
const arrowNode = stretchy.mathMLnode(fName);
|
2422
2427
|
// Is this the short part of a mhchem equilibrium arrow?
|
2423
|
-
const isEq =
|
2424
|
-
const minWidth =
|
2425
|
-
? "1.75" // mathtools extensible arrows are 1.75em long
|
2426
|
-
:
|
2428
|
+
const isEq = fName.slice(1, 3) === "eq";
|
2429
|
+
const minWidth = fName.charAt(1) === "x"
|
2430
|
+
? "1.75" // mathtools extensible arrows are ≥ 1.75em long
|
2431
|
+
: fName.slice(2, 4) === "cd"
|
2427
2432
|
? "3.0" // cd package arrows
|
2428
2433
|
: isEq
|
2429
2434
|
? "1.0" // The shorter harpoon of a mhchem equilibrium arrow
|
2430
2435
|
: "2.0"; // other mhchem arrows
|
2431
|
-
|
2436
|
+
// TODO: When Firefox supports minsize, use the next line.
|
2437
|
+
//arrowNode.setAttribute("minsize", String(minWidth) + "em")
|
2432
2438
|
arrowNode.setAttribute("lspace", "0");
|
2433
2439
|
arrowNode.setAttribute("rspace", (isEq ? "0.5em" : "0"));
|
2434
2440
|
|
2435
2441
|
// <munderover> upper and lower labels are set to scriptlevel by MathML
|
2436
|
-
// So we have to adjust our dimensions accordingly.
|
2442
|
+
// So we have to adjust our label dimensions accordingly.
|
2437
2443
|
const labelStyle = style.withLevel(style.level < 2 ? 2 : 3);
|
2438
|
-
const
|
2439
|
-
|
2440
|
-
|
2441
|
-
|
2442
|
-
const
|
2444
|
+
const minArrowWidth = labelSize(minWidth, labelStyle.level);
|
2445
|
+
// The dummyNode will be inside a <mover> inside a <mover>
|
2446
|
+
// So it will be at scriptlevel 3
|
2447
|
+
const dummyWidth = labelSize(minWidth, 3);
|
2448
|
+
const emptyLabel = paddedNode(null, minArrowWidth.toFixed(4), 0);
|
2449
|
+
const dummyNode = paddedNode(null, dummyWidth.toFixed(4), 0);
|
2450
|
+
// The arrow is a little longer than the label. Set a spacer length.
|
2451
|
+
const space = labelSize((isEq ? 0 : 0.3), labelStyle.level).toFixed(4);
|
2452
|
+
let upperNode;
|
2453
|
+
let lowerNode;
|
2454
|
+
|
2455
|
+
const gotUpper = (body && body.body &&
|
2443
2456
|
// \hphantom visible content
|
2444
|
-
(body.body.body || body.body.length > 0))
|
2445
|
-
|
2446
|
-
|
2447
|
-
|
2448
|
-
|
2449
|
-
|
2450
|
-
|
2451
|
-
|
2452
|
-
|
2453
|
-
const
|
2454
|
-
|
2457
|
+
(body.body.body || body.body.length > 0));
|
2458
|
+
if (gotUpper) {
|
2459
|
+
let label = buildGroup$1(body, labelStyle);
|
2460
|
+
label = paddedNode(label, space, space);
|
2461
|
+
// Since Firefox does not support minsize, stack a invisible node
|
2462
|
+
// on top of the label. Its width will serve as a min-width.
|
2463
|
+
// TODO: Refactor this after Firefox supports minsize.
|
2464
|
+
upperNode = new mathMLTree.MathNode("mover", [label, dummyNode]);
|
2465
|
+
}
|
2466
|
+
const gotLower = (below && below.body &&
|
2467
|
+
(below.body.body || below.body.length > 0));
|
2468
|
+
if (gotLower) {
|
2469
|
+
let label = buildGroup$1(below, labelStyle);
|
2470
|
+
label = paddedNode(label, space, space);
|
2471
|
+
lowerNode = new mathMLTree.MathNode("munder", [label, dummyNode]);
|
2472
|
+
}
|
2473
|
+
|
2474
|
+
let node;
|
2475
|
+
if (!gotUpper && !gotLower) {
|
2476
|
+
node = new mathMLTree.MathNode("mover", [arrowNode, emptyLabel]);
|
2477
|
+
} else if (gotUpper && gotLower) {
|
2478
|
+
node = new mathMLTree.MathNode("munderover", [arrowNode, lowerNode, upperNode]);
|
2479
|
+
} else if (gotUpper) {
|
2480
|
+
node = new mathMLTree.MathNode("mover", [arrowNode, upperNode]);
|
2481
|
+
} else {
|
2482
|
+
node = new mathMLTree.MathNode("munder", [arrowNode, lowerNode]);
|
2483
|
+
}
|
2484
|
+
if (minWidth === "3.0") { node.style.height = "1em"; } // CD environment
|
2485
|
+
node.setAttribute("accent", "false"); // Necessary for MS Word
|
2455
2486
|
return node
|
2456
2487
|
};
|
2457
2488
|
|
@@ -2530,7 +2561,7 @@ var temml = (function () {
|
|
2530
2561
|
"\\xleftrightharpoons", // mathtools
|
2531
2562
|
"\\xrightleftharpoons", // mathtools
|
2532
2563
|
"\\yieldsLeftRight", // mhchem
|
2533
|
-
"\\equilibrium",
|
2564
|
+
"\\equilibrium", // mhchem
|
2534
2565
|
"\\equilibriumRight",
|
2535
2566
|
"\\equilibriumLeft"
|
2536
2567
|
],
|
@@ -6002,7 +6033,9 @@ var temml = (function () {
|
|
6002
6033
|
const arr = (body.body) ? body.body : [body];
|
6003
6034
|
for (const arg of arr) {
|
6004
6035
|
if (textAtomTypes.includes(arg.type)) {
|
6005
|
-
if (arg.text) {
|
6036
|
+
if (symbols[parser.mode][arg.text]) {
|
6037
|
+
mord.text += symbols[parser.mode][arg.text].replace;
|
6038
|
+
} else if (arg.text) {
|
6006
6039
|
mord.text += arg.text;
|
6007
6040
|
} else if (arg.body) {
|
6008
6041
|
arg.body.map(e => { mord.text += e.text; });
|
@@ -7749,6 +7782,8 @@ var temml = (function () {
|
|
7749
7782
|
node = new mathMLTree.MathNode("mi", [text]);
|
7750
7783
|
if (text.text === origText && latinRegEx.test(origText)) {
|
7751
7784
|
node.setAttribute("mathvariant", "italic");
|
7785
|
+
} else if (text.text === "∇" && variant === "normal") {
|
7786
|
+
node.setAttribute("mathvariant", "normal");
|
7752
7787
|
}
|
7753
7788
|
}
|
7754
7789
|
return node
|
@@ -10970,7 +11005,7 @@ var temml = (function () {
|
|
10970
11005
|
* https://mit-license.org/
|
10971
11006
|
*/
|
10972
11007
|
|
10973
|
-
const version = "0.10.
|
11008
|
+
const version = "0.10.13";
|
10974
11009
|
|
10975
11010
|
function postProcess(block) {
|
10976
11011
|
const labelMap = {};
|