temml 0.10.12 → 0.10.13
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/temml.cjs +54 -27
- package/dist/temml.js +54 -27
- package/dist/temml.min.js +1 -1
- package/dist/temml.mjs +54 -27
- package/dist/temmlPostProcess.js +1 -1
- package/package.json +4 -1
- package/src/functions/arrow.js +50 -24
- package/src/postProcess.js +1 -1
- package/src/symbols.js +1 -0
package/dist/temml.mjs
CHANGED
@@ -968,6 +968,7 @@ defineSymbol(math, rel, "\u21c1", "\\rightharpoondown", true);
|
|
968
968
|
defineSymbol(math, rel, "\u2196", "\\nwarrow", true);
|
969
969
|
defineSymbol(math, rel, "\u21cc", "\\rightleftharpoons", true);
|
970
970
|
defineSymbol(math, mathord, "\u21af", "\\lightning", true);
|
971
|
+
defineSymbol(math, mathord, "\u220E", "\\QED", true);
|
971
972
|
defineSymbol(math, mathord, "\u2030", "\\permil", true);
|
972
973
|
defineSymbol(text, textord, "\u2030", "\\permil");
|
973
974
|
|
@@ -2416,43 +2417,69 @@ const paddedNode = (group, lspace = 0.3, rspace = 0) => {
|
|
2416
2417
|
return new mathMLTree.MathNode("mrow", row)
|
2417
2418
|
};
|
2418
2419
|
|
2419
|
-
const labelSize = (size, scriptLevel) => (size / emScale(scriptLevel)
|
2420
|
+
const labelSize = (size, scriptLevel) => Number(size) / emScale(scriptLevel);
|
2420
2421
|
|
2421
|
-
const munderoverNode = (
|
2422
|
-
const arrowNode = stretchy.mathMLnode(
|
2422
|
+
const munderoverNode = (fName, body, below, style) => {
|
2423
|
+
const arrowNode = stretchy.mathMLnode(fName);
|
2423
2424
|
// Is this the short part of a mhchem equilibrium arrow?
|
2424
|
-
const isEq =
|
2425
|
-
const minWidth =
|
2426
|
-
? "1.75" // mathtools extensible arrows are 1.75em long
|
2427
|
-
:
|
2425
|
+
const isEq = fName.slice(1, 3) === "eq";
|
2426
|
+
const minWidth = fName.charAt(1) === "x"
|
2427
|
+
? "1.75" // mathtools extensible arrows are ≥ 1.75em long
|
2428
|
+
: fName.slice(2, 4) === "cd"
|
2428
2429
|
? "3.0" // cd package arrows
|
2429
2430
|
: isEq
|
2430
2431
|
? "1.0" // The shorter harpoon of a mhchem equilibrium arrow
|
2431
2432
|
: "2.0"; // other mhchem arrows
|
2432
|
-
|
2433
|
+
// TODO: When Firefox supports minsize, use the next line.
|
2434
|
+
//arrowNode.setAttribute("minsize", String(minWidth) + "em")
|
2433
2435
|
arrowNode.setAttribute("lspace", "0");
|
2434
2436
|
arrowNode.setAttribute("rspace", (isEq ? "0.5em" : "0"));
|
2435
2437
|
|
2436
2438
|
// <munderover> upper and lower labels are set to scriptlevel by MathML
|
2437
|
-
// So we have to adjust our dimensions accordingly.
|
2439
|
+
// So we have to adjust our label dimensions accordingly.
|
2438
2440
|
const labelStyle = style.withLevel(style.level < 2 ? 2 : 3);
|
2439
|
-
const
|
2440
|
-
|
2441
|
-
|
2442
|
-
|
2443
|
-
const
|
2441
|
+
const minArrowWidth = labelSize(minWidth, labelStyle.level);
|
2442
|
+
// The dummyNode will be inside a <mover> inside a <mover>
|
2443
|
+
// So it will be at scriptlevel 3
|
2444
|
+
const dummyWidth = labelSize(minWidth, 3);
|
2445
|
+
const emptyLabel = paddedNode(null, minArrowWidth.toFixed(4), 0);
|
2446
|
+
const dummyNode = paddedNode(null, dummyWidth.toFixed(4), 0);
|
2447
|
+
// The arrow is a little longer than the label. Set a spacer length.
|
2448
|
+
const space = labelSize((isEq ? 0 : 0.3), labelStyle.level).toFixed(4);
|
2449
|
+
let upperNode;
|
2450
|
+
let lowerNode;
|
2451
|
+
|
2452
|
+
const gotUpper = (body && body.body &&
|
2444
2453
|
// \hphantom visible content
|
2445
|
-
(body.body.body || body.body.length > 0))
|
2446
|
-
|
2447
|
-
|
2448
|
-
|
2449
|
-
|
2450
|
-
|
2451
|
-
|
2452
|
-
|
2453
|
-
|
2454
|
-
const
|
2455
|
-
|
2454
|
+
(body.body.body || body.body.length > 0));
|
2455
|
+
if (gotUpper) {
|
2456
|
+
let label = buildGroup$1(body, labelStyle);
|
2457
|
+
label = paddedNode(label, space, space);
|
2458
|
+
// Since Firefox does not support minsize, stack a invisible node
|
2459
|
+
// on top of the label. Its width will serve as a min-width.
|
2460
|
+
// TODO: Refactor this after Firefox supports minsize.
|
2461
|
+
upperNode = new mathMLTree.MathNode("mover", [label, dummyNode]);
|
2462
|
+
}
|
2463
|
+
const gotLower = (below && below.body &&
|
2464
|
+
(below.body.body || below.body.length > 0));
|
2465
|
+
if (gotLower) {
|
2466
|
+
let label = buildGroup$1(below, labelStyle);
|
2467
|
+
label = paddedNode(label, space, space);
|
2468
|
+
lowerNode = new mathMLTree.MathNode("munder", [label, dummyNode]);
|
2469
|
+
}
|
2470
|
+
|
2471
|
+
let node;
|
2472
|
+
if (!gotUpper && !gotLower) {
|
2473
|
+
node = new mathMLTree.MathNode("mover", [arrowNode, emptyLabel]);
|
2474
|
+
} else if (gotUpper && gotLower) {
|
2475
|
+
node = new mathMLTree.MathNode("munderover", [arrowNode, lowerNode, upperNode]);
|
2476
|
+
} else if (gotUpper) {
|
2477
|
+
node = new mathMLTree.MathNode("mover", [arrowNode, upperNode]);
|
2478
|
+
} else {
|
2479
|
+
node = new mathMLTree.MathNode("munder", [arrowNode, lowerNode]);
|
2480
|
+
}
|
2481
|
+
if (minWidth === "3.0") { node.style.height = "1em"; } // CD environment
|
2482
|
+
node.setAttribute("accent", "false"); // Necessary for MS Word
|
2456
2483
|
return node
|
2457
2484
|
};
|
2458
2485
|
|
@@ -2531,7 +2558,7 @@ defineFunction({
|
|
2531
2558
|
"\\xleftrightharpoons", // mathtools
|
2532
2559
|
"\\xrightleftharpoons", // mathtools
|
2533
2560
|
"\\yieldsLeftRight", // mhchem
|
2534
|
-
"\\equilibrium",
|
2561
|
+
"\\equilibrium", // mhchem
|
2535
2562
|
"\\equilibriumRight",
|
2536
2563
|
"\\equilibriumLeft"
|
2537
2564
|
],
|
@@ -12875,7 +12902,7 @@ class Style {
|
|
12875
12902
|
* https://mit-license.org/
|
12876
12903
|
*/
|
12877
12904
|
|
12878
|
-
const version = "0.10.
|
12905
|
+
const version = "0.10.13";
|
12879
12906
|
|
12880
12907
|
function postProcess(block) {
|
12881
12908
|
const labelMap = {};
|
package/dist/temmlPostProcess.js
CHANGED
package/package.json
CHANGED
package/src/functions/arrow.js
CHANGED
@@ -18,45 +18,71 @@ const paddedNode = (group, lspace = 0.3, rspace = 0) => {
|
|
18
18
|
if (lspace !== 0) { row.unshift(padding(lspace)) }
|
19
19
|
if (rspace > 0) { row.push(padding(rspace)) }
|
20
20
|
return new mathMLTree.MathNode("mrow", row)
|
21
|
-
}
|
21
|
+
}
|
22
22
|
|
23
|
-
const labelSize = (size, scriptLevel) => (size / emScale(scriptLevel)
|
23
|
+
const labelSize = (size, scriptLevel) => Number(size) / emScale(scriptLevel);
|
24
24
|
|
25
|
-
const munderoverNode = (
|
26
|
-
const arrowNode = stretchy.mathMLnode(
|
25
|
+
const munderoverNode = (fName, body, below, style) => {
|
26
|
+
const arrowNode = stretchy.mathMLnode(fName);
|
27
27
|
// Is this the short part of a mhchem equilibrium arrow?
|
28
|
-
const isEq =
|
29
|
-
const minWidth =
|
30
|
-
? "1.75" // mathtools extensible arrows are 1.75em long
|
31
|
-
:
|
28
|
+
const isEq = fName.slice(1, 3) === "eq"
|
29
|
+
const minWidth = fName.charAt(1) === "x"
|
30
|
+
? "1.75" // mathtools extensible arrows are ≥ 1.75em long
|
31
|
+
: fName.slice(2, 4) === "cd"
|
32
32
|
? "3.0" // cd package arrows
|
33
33
|
: isEq
|
34
34
|
? "1.0" // The shorter harpoon of a mhchem equilibrium arrow
|
35
35
|
: "2.0"; // other mhchem arrows
|
36
|
-
|
36
|
+
// TODO: When Firefox supports minsize, use the next line.
|
37
|
+
//arrowNode.setAttribute("minsize", String(minWidth) + "em")
|
37
38
|
arrowNode.setAttribute("lspace", "0")
|
38
39
|
arrowNode.setAttribute("rspace", (isEq ? "0.5em" : "0"))
|
39
40
|
|
40
41
|
// <munderover> upper and lower labels are set to scriptlevel by MathML
|
41
|
-
// So we have to adjust our dimensions accordingly.
|
42
|
+
// So we have to adjust our label dimensions accordingly.
|
42
43
|
const labelStyle = style.withLevel(style.level < 2 ? 2 : 3)
|
43
|
-
const
|
44
|
-
|
45
|
-
|
44
|
+
const minArrowWidth = labelSize(minWidth, labelStyle.level)
|
45
|
+
// The dummyNode will be inside a <mover> inside a <mover>
|
46
|
+
// So it will be at scriptlevel 3
|
47
|
+
const dummyWidth = labelSize(minWidth, 3)
|
48
|
+
const emptyLabel = paddedNode(null, minArrowWidth.toFixed(4), 0)
|
49
|
+
const dummyNode = paddedNode(null, dummyWidth.toFixed(4), 0)
|
50
|
+
// The arrow is a little longer than the label. Set a spacer length.
|
51
|
+
const space = labelSize((isEq ? 0 : 0.3), labelStyle.level).toFixed(4)
|
52
|
+
let upperNode
|
53
|
+
let lowerNode
|
46
54
|
|
47
|
-
const
|
55
|
+
const gotUpper = (body && body.body &&
|
48
56
|
// \hphantom visible content
|
49
57
|
(body.body.body || body.body.length > 0))
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
58
|
+
if (gotUpper) {
|
59
|
+
let label = mml.buildGroup(body, labelStyle)
|
60
|
+
label = paddedNode(label, space, space)
|
61
|
+
// Since Firefox does not support minsize, stack a invisible node
|
62
|
+
// on top of the label. Its width will serve as a min-width.
|
63
|
+
// TODO: Refactor this after Firefox supports minsize.
|
64
|
+
upperNode = new mathMLTree.MathNode("mover", [label, dummyNode])
|
65
|
+
}
|
66
|
+
const gotLower = (below && below.body &&
|
55
67
|
(below.body.body || below.body.length > 0))
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
68
|
+
if (gotLower) {
|
69
|
+
let label = mml.buildGroup(below, labelStyle)
|
70
|
+
label = paddedNode(label, space, space)
|
71
|
+
lowerNode = new mathMLTree.MathNode("munder", [label, dummyNode])
|
72
|
+
}
|
73
|
+
|
74
|
+
let node
|
75
|
+
if (!gotUpper && !gotLower) {
|
76
|
+
node = new mathMLTree.MathNode("mover", [arrowNode, emptyLabel])
|
77
|
+
} else if (gotUpper && gotLower) {
|
78
|
+
node = new mathMLTree.MathNode("munderover", [arrowNode, lowerNode, upperNode])
|
79
|
+
} else if (gotUpper) {
|
80
|
+
node = new mathMLTree.MathNode("mover", [arrowNode, upperNode])
|
81
|
+
} else {
|
82
|
+
node = new mathMLTree.MathNode("munder", [arrowNode, lowerNode])
|
83
|
+
}
|
84
|
+
if (minWidth === "3.0") { node.style.height = "1em" } // CD environment
|
85
|
+
node.setAttribute("accent", "false") // Necessary for MS Word
|
60
86
|
return node
|
61
87
|
}
|
62
88
|
|
@@ -135,7 +161,7 @@ defineFunction({
|
|
135
161
|
"\\xleftrightharpoons", // mathtools
|
136
162
|
"\\xrightleftharpoons", // mathtools
|
137
163
|
"\\yieldsLeftRight", // mhchem
|
138
|
-
"\\equilibrium",
|
164
|
+
"\\equilibrium", // mhchem
|
139
165
|
"\\equilibriumRight",
|
140
166
|
"\\equilibriumLeft"
|
141
167
|
],
|
package/src/postProcess.js
CHANGED
package/src/symbols.js
CHANGED
@@ -209,6 +209,7 @@ defineSymbol(math, rel, "\u21c1", "\\rightharpoondown", true);
|
|
209
209
|
defineSymbol(math, rel, "\u2196", "\\nwarrow", true);
|
210
210
|
defineSymbol(math, rel, "\u21cc", "\\rightleftharpoons", true);
|
211
211
|
defineSymbol(math, mathord, "\u21af", "\\lightning", true);
|
212
|
+
defineSymbol(math, mathord, "\u220E", "\\QED", true);
|
212
213
|
defineSymbol(math, mathord, "\u2030", "\\permil", true);
|
213
214
|
defineSymbol(text, textord, "\u2030", "\\permil");
|
214
215
|
|