temml 0.11.10 → 0.11.11
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 +25 -42
- package/dist/temml.js +25 -42
- package/dist/temml.min.js +1 -1
- package/dist/temml.mjs +25 -42
- package/dist/temmlPostProcess.js +1 -1
- package/package.json +1 -1
- package/src/functions/delimsizing.js +3 -0
- package/src/functions/enclose.js +4 -24
- package/src/postProcess.js +1 -1
package/dist/temml.mjs
CHANGED
|
@@ -2805,17 +2805,17 @@ const calculateSize = function(sizeValue, style) {
|
|
|
2805
2805
|
|
|
2806
2806
|
// Helper functions
|
|
2807
2807
|
|
|
2808
|
-
const padding
|
|
2808
|
+
const padding = width => {
|
|
2809
2809
|
const node = new mathMLTree.MathNode("mspace");
|
|
2810
2810
|
node.setAttribute("width", width + "em");
|
|
2811
2811
|
return node
|
|
2812
2812
|
};
|
|
2813
2813
|
|
|
2814
2814
|
const paddedNode = (group, lspace = 0.3, rspace = 0, mustSmash = false) => {
|
|
2815
|
-
if (group == null && rspace === 0) { return padding
|
|
2815
|
+
if (group == null && rspace === 0) { return padding(lspace) }
|
|
2816
2816
|
const row = group ? [group] : [];
|
|
2817
|
-
if (lspace !== 0) { row.unshift(padding
|
|
2818
|
-
if (rspace > 0) { row.push(padding
|
|
2817
|
+
if (lspace !== 0) { row.unshift(padding(lspace)); }
|
|
2818
|
+
if (rspace > 0) { row.push(padding(rspace)); }
|
|
2819
2819
|
if (mustSmash) {
|
|
2820
2820
|
// Used for the bottom arrow in a {CD} environment
|
|
2821
2821
|
const mpadded = new mathMLTree.MathNode("mpadded", row);
|
|
@@ -2947,8 +2947,8 @@ defineFunction({
|
|
|
2947
2947
|
const node = munderoverNode(group.name, group.body, group.below, style);
|
|
2948
2948
|
// Create operator spacing for a relation.
|
|
2949
2949
|
const row = [node];
|
|
2950
|
-
row.unshift(padding
|
|
2951
|
-
row.push(padding
|
|
2950
|
+
row.unshift(padding(0.2778));
|
|
2951
|
+
row.push(padding(0.2778));
|
|
2952
2952
|
return new mathMLTree.MathNode("mrow", row)
|
|
2953
2953
|
}
|
|
2954
2954
|
});
|
|
@@ -3012,13 +3012,13 @@ defineFunction({
|
|
|
3012
3012
|
botNode.setAttribute("width", "0.5em");
|
|
3013
3013
|
wrapper = new mathMLTree.MathNode(
|
|
3014
3014
|
"mpadded",
|
|
3015
|
-
[padding
|
|
3015
|
+
[padding(0.2778), botNode, raiseNode, padding(0.2778)]
|
|
3016
3016
|
);
|
|
3017
3017
|
} else {
|
|
3018
3018
|
raiseNode.setAttribute("width", (group.name === "\\equilibriumRight" ? "0.5em" : "0"));
|
|
3019
3019
|
wrapper = new mathMLTree.MathNode(
|
|
3020
3020
|
"mpadded",
|
|
3021
|
-
[padding
|
|
3021
|
+
[padding(0.2778), raiseNode, botArrow, padding(0.2778)]
|
|
3022
3022
|
);
|
|
3023
3023
|
}
|
|
3024
3024
|
|
|
@@ -7906,6 +7906,9 @@ const sizeToMaxHeight = [0, 1.2, 1.8, 2.4, 3.0];
|
|
|
7906
7906
|
|
|
7907
7907
|
// Delimiter functions
|
|
7908
7908
|
function checkDelimiter(delim, context) {
|
|
7909
|
+
if (delim.type === "ordgroup" && delim.body.length === 1) {
|
|
7910
|
+
delim = delim.body[0]; // Unwrap the braces
|
|
7911
|
+
}
|
|
7909
7912
|
const symDelim = checkSymbolNodeType(delim);
|
|
7910
7913
|
if (symDelim && delimiters.includes(symDelim.text)) {
|
|
7911
7914
|
// If a character is not in the MathML operator dictionary, it will not stretch.
|
|
@@ -8137,26 +8140,8 @@ defineFunction({
|
|
|
8137
8140
|
}
|
|
8138
8141
|
});
|
|
8139
8142
|
|
|
8140
|
-
const padding = _ => {
|
|
8141
|
-
const node = new mathMLTree.MathNode("mspace");
|
|
8142
|
-
node.setAttribute("width", "3pt");
|
|
8143
|
-
return node
|
|
8144
|
-
};
|
|
8145
|
-
|
|
8146
8143
|
const mathmlBuilder$7 = (group, style) => {
|
|
8147
|
-
|
|
8148
|
-
if (group.label.indexOf("colorbox") > -1 || group.label === "\\boxed") {
|
|
8149
|
-
// MathML core does not support +width attribute in <mpadded>.
|
|
8150
|
-
// Firefox does not reliably add side padding.
|
|
8151
|
-
// Insert <mspace>
|
|
8152
|
-
node = new mathMLTree.MathNode("mrow", [
|
|
8153
|
-
padding(),
|
|
8154
|
-
buildGroup$1(group.body, style),
|
|
8155
|
-
padding()
|
|
8156
|
-
]);
|
|
8157
|
-
} else {
|
|
8158
|
-
node = new mathMLTree.MathNode("menclose", [buildGroup$1(group.body, style)]);
|
|
8159
|
-
}
|
|
8144
|
+
const node = new mathMLTree.MathNode("menclose", [buildGroup$1(group.body, style)]);
|
|
8160
8145
|
switch (group.label) {
|
|
8161
8146
|
case "\\overline":
|
|
8162
8147
|
node.setAttribute("notation", "top"); // for Firefox & WebKit
|
|
@@ -8204,7 +8189,7 @@ const mathmlBuilder$7 = (group, style) => {
|
|
|
8204
8189
|
case "\\boxed":
|
|
8205
8190
|
// \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} from amsmath.sty
|
|
8206
8191
|
node.setAttribute("notation", "box");
|
|
8207
|
-
node.style.padding = "
|
|
8192
|
+
node.style.padding = "3pt";
|
|
8208
8193
|
node.style.border = "1px solid";
|
|
8209
8194
|
node.setAttribute("scriptlevel", "0");
|
|
8210
8195
|
node.setAttribute("displaystyle", "true");
|
|
@@ -8221,12 +8206,10 @@ const mathmlBuilder$7 = (group, style) => {
|
|
|
8221
8206
|
//const fboxsep = 3; // 3 pt from LaTeX source2e
|
|
8222
8207
|
//node.setAttribute("height", `+${2 * fboxsep}pt`)
|
|
8223
8208
|
//node.setAttribute("voffset", `${fboxsep}pt`)
|
|
8224
|
-
|
|
8225
|
-
|
|
8209
|
+
node.style.padding = "3pt";
|
|
8226
8210
|
if (group.label === "\\fcolorbox") {
|
|
8227
|
-
style.border = "0.0667em solid " + String(group.borderColor);
|
|
8211
|
+
node.style.border = "0.0667em solid " + String(group.borderColor);
|
|
8228
8212
|
}
|
|
8229
|
-
node.style = style;
|
|
8230
8213
|
break
|
|
8231
8214
|
}
|
|
8232
8215
|
}
|
|
@@ -9516,17 +9499,17 @@ function mathmlBuilder$3(group, style) {
|
|
|
9516
9499
|
if (doSpacing ) {
|
|
9517
9500
|
if (group.mclass === "mbin") {
|
|
9518
9501
|
// medium space
|
|
9519
|
-
node.children.unshift(padding
|
|
9520
|
-
node.children.push(padding
|
|
9502
|
+
node.children.unshift(padding(0.2222));
|
|
9503
|
+
node.children.push(padding(0.2222));
|
|
9521
9504
|
} else if (group.mclass === "mrel") {
|
|
9522
9505
|
// thickspace
|
|
9523
|
-
node.children.unshift(padding
|
|
9524
|
-
node.children.push(padding
|
|
9506
|
+
node.children.unshift(padding(0.2778));
|
|
9507
|
+
node.children.push(padding(0.2778));
|
|
9525
9508
|
} else if (group.mclass === "mpunct") {
|
|
9526
|
-
node.children.push(padding
|
|
9509
|
+
node.children.push(padding(0.1667));
|
|
9527
9510
|
} else if (group.mclass === "minner") {
|
|
9528
|
-
node.children.unshift(padding
|
|
9529
|
-
node.children.push(padding
|
|
9511
|
+
node.children.unshift(padding(0.0556)); // 1 mu is the most likely option
|
|
9512
|
+
node.children.push(padding(0.0556));
|
|
9530
9513
|
}
|
|
9531
9514
|
}
|
|
9532
9515
|
} else {
|
|
@@ -11090,10 +11073,10 @@ defineFunctionBuilders({
|
|
|
11090
11073
|
} else if (group.needsSpacing) {
|
|
11091
11074
|
// Fix a MathML bug that occurs when a <mo> is between two <mtext> elements.
|
|
11092
11075
|
if (group.family === "bin") {
|
|
11093
|
-
return new mathMLTree.MathNode("mrow", [padding
|
|
11076
|
+
return new mathMLTree.MathNode("mrow", [padding(0.222), node, padding(0.222)])
|
|
11094
11077
|
} else {
|
|
11095
11078
|
// REL spacing
|
|
11096
|
-
return new mathMLTree.MathNode("mrow", [padding
|
|
11079
|
+
return new mathMLTree.MathNode("mrow", [padding(0.2778), node, padding(0.2778)])
|
|
11097
11080
|
}
|
|
11098
11081
|
}
|
|
11099
11082
|
return node;
|
|
@@ -14026,7 +14009,7 @@ class Style {
|
|
|
14026
14009
|
* https://mit-license.org/
|
|
14027
14010
|
*/
|
|
14028
14011
|
|
|
14029
|
-
const version = "0.11.
|
|
14012
|
+
const version = "0.11.11";
|
|
14030
14013
|
|
|
14031
14014
|
function postProcess(block) {
|
|
14032
14015
|
const labelMap = {};
|
package/dist/temmlPostProcess.js
CHANGED
package/package.json
CHANGED
|
@@ -115,6 +115,9 @@ const sizeToMaxHeight = [0, 1.2, 1.8, 2.4, 3.0];
|
|
|
115
115
|
|
|
116
116
|
// Delimiter functions
|
|
117
117
|
function checkDelimiter(delim, context) {
|
|
118
|
+
if (delim.type === "ordgroup" && delim.body.length === 1) {
|
|
119
|
+
delim = delim.body[0]; // Unwrap the braces
|
|
120
|
+
}
|
|
118
121
|
const symDelim = checkSymbolNodeType(delim)
|
|
119
122
|
if (symDelim && delimiters.includes(symDelim.text)) {
|
|
120
123
|
// If a character is not in the MathML operator dictionary, it will not stretch.
|
package/src/functions/enclose.js
CHANGED
|
@@ -4,26 +4,8 @@ import { assertNodeType } from "../parseNode";
|
|
|
4
4
|
import { colorFromSpec, validateColor } from "./color"
|
|
5
5
|
import * as mml from "../buildMathML";
|
|
6
6
|
|
|
7
|
-
const padding = _ => {
|
|
8
|
-
const node = new mathMLTree.MathNode("mspace")
|
|
9
|
-
node.setAttribute("width", "3pt")
|
|
10
|
-
return node
|
|
11
|
-
}
|
|
12
|
-
|
|
13
7
|
const mathmlBuilder = (group, style) => {
|
|
14
|
-
|
|
15
|
-
if (group.label.indexOf("colorbox") > -1 || group.label === "\\boxed") {
|
|
16
|
-
// MathML core does not support +width attribute in <mpadded>.
|
|
17
|
-
// Firefox does not reliably add side padding.
|
|
18
|
-
// Insert <mspace>
|
|
19
|
-
node = new mathMLTree.MathNode("mrow", [
|
|
20
|
-
padding(),
|
|
21
|
-
mml.buildGroup(group.body, style),
|
|
22
|
-
padding()
|
|
23
|
-
])
|
|
24
|
-
} else {
|
|
25
|
-
node = new mathMLTree.MathNode("menclose", [mml.buildGroup(group.body, style)])
|
|
26
|
-
}
|
|
8
|
+
const node = new mathMLTree.MathNode("menclose", [mml.buildGroup(group.body, style)])
|
|
27
9
|
switch (group.label) {
|
|
28
10
|
case "\\overline":
|
|
29
11
|
node.setAttribute("notation", "top") // for Firefox & WebKit
|
|
@@ -71,7 +53,7 @@ const mathmlBuilder = (group, style) => {
|
|
|
71
53
|
case "\\boxed":
|
|
72
54
|
// \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} from amsmath.sty
|
|
73
55
|
node.setAttribute("notation", "box")
|
|
74
|
-
node.style.padding = "
|
|
56
|
+
node.style.padding = "3pt"
|
|
75
57
|
node.style.border = "1px solid"
|
|
76
58
|
node.setAttribute("scriptlevel", "0")
|
|
77
59
|
node.setAttribute("displaystyle", "true")
|
|
@@ -88,12 +70,10 @@ const mathmlBuilder = (group, style) => {
|
|
|
88
70
|
//const fboxsep = 3; // 3 pt from LaTeX source2e
|
|
89
71
|
//node.setAttribute("height", `+${2 * fboxsep}pt`)
|
|
90
72
|
//node.setAttribute("voffset", `${fboxsep}pt`)
|
|
91
|
-
|
|
92
|
-
|
|
73
|
+
node.style.padding = "3pt"
|
|
93
74
|
if (group.label === "\\fcolorbox") {
|
|
94
|
-
style.border = "0.0667em solid " + String(group.borderColor)
|
|
75
|
+
node.style.border = "0.0667em solid " + String(group.borderColor)
|
|
95
76
|
}
|
|
96
|
-
node.style = style
|
|
97
77
|
break
|
|
98
78
|
}
|
|
99
79
|
}
|