temml 0.10.22 → 0.10.23
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/dist/Temml-Fira.css +152 -0
- package/dist/temml.cjs +40 -5
- package/dist/temml.js +40 -5
- package/dist/temml.min.js +1 -1
- package/dist/temml.mjs +40 -5
- package/dist/temmlPostProcess.js +1 -1
- package/package.json +1 -1
- package/src/buildMathML.js +7 -4
- package/src/functions/font.js +30 -1
- package/src/postProcess.js +1 -1
- package/src/symbols.js +3 -0
package/dist/temml.mjs
CHANGED
@@ -1024,6 +1024,7 @@ defineSymbol(math, mathord, "\u2609", "\\astrosun", true);
|
|
1024
1024
|
defineSymbol(math, mathord, "\u263c", "\\sun", true);
|
1025
1025
|
defineSymbol(math, mathord, "\u263e", "\\leftmoon", true);
|
1026
1026
|
defineSymbol(math, mathord, "\u263d", "\\rightmoon", true);
|
1027
|
+
defineSymbol(math, mathord, "\u2295", "\\Earth");
|
1027
1028
|
|
1028
1029
|
// AMS Negated Binary Relations
|
1029
1030
|
defineSymbol(math, rel, "\u226e", "\\nless", true);
|
@@ -1251,6 +1252,8 @@ defineSymbol(math, bin, "\u27d5", "\\leftouterjoin", true);
|
|
1251
1252
|
defineSymbol(math, bin, "\u27d6", "\\rightouterjoin", true);
|
1252
1253
|
defineSymbol(math, bin, "\u27d7", "\\fullouterjoin", true);
|
1253
1254
|
|
1255
|
+
defineSymbol(math, bin, "\u2238", "\\dotminus", true); // stix
|
1256
|
+
|
1254
1257
|
// AMS Arrows
|
1255
1258
|
// Note: unicode-math maps \u21e2 to their own function \rightdasharrow.
|
1256
1259
|
// We'll map it to AMS function \dashrightarrow. It produces the same atom.
|
@@ -2019,9 +2022,11 @@ const consolidateText = mrow => {
|
|
2019
2022
|
};
|
2020
2023
|
|
2021
2024
|
const numberRegEx$1 = /^[0-9]$/;
|
2022
|
-
const
|
2023
|
-
return (node.type === "
|
2024
|
-
|
2025
|
+
const isDotOrComma = (node, followingNode) => {
|
2026
|
+
return ((node.type === "textord" && node.text === ".") ||
|
2027
|
+
(node.type === "atom" && node.text === ",")) &&
|
2028
|
+
// Don't consolidate if there is a space after the comma.
|
2029
|
+
node.loc && followingNode.loc && node.loc.end === followingNode.loc.start
|
2025
2030
|
};
|
2026
2031
|
const consolidateNumbers = expression => {
|
2027
2032
|
// Consolidate adjacent numbers. We want to return <mn>1,506.3</mn>,
|
@@ -2044,7 +2049,8 @@ const consolidateNumbers = expression => {
|
|
2044
2049
|
|
2045
2050
|
// Determine if numeral groups are separated by a comma or dot.
|
2046
2051
|
for (let i = nums.length - 1; i > 0; i--) {
|
2047
|
-
if (nums[i - 1].end === nums[i].start - 2 &&
|
2052
|
+
if (nums[i - 1].end === nums[i].start - 2 &&
|
2053
|
+
isDotOrComma(expression[nums[i].start - 1], expression[nums[i].start])) {
|
2048
2054
|
// Merge the two groups.
|
2049
2055
|
nums[i - 1].end = nums[i].end;
|
2050
2056
|
nums.splice(i, 1);
|
@@ -5110,6 +5116,21 @@ defineFunction({
|
|
5110
5116
|
}
|
5111
5117
|
});
|
5112
5118
|
|
5119
|
+
const isLongVariableName = (group, font) => {
|
5120
|
+
if (font !== "mathrm" || group.body.type !== "ordgroup" || group.body.body.length === 1) {
|
5121
|
+
return false
|
5122
|
+
}
|
5123
|
+
if (group.body.body[0].type !== "mathord") { return false }
|
5124
|
+
for (let i = 1; i < group.body.body.length; i++) {
|
5125
|
+
const parseNodeType = group.body.body[i].type;
|
5126
|
+
if (!(parseNodeType === "mathord" ||
|
5127
|
+
(parseNodeType === "textord" && !isNaN(group.body.body[i].text)))) {
|
5128
|
+
return false
|
5129
|
+
}
|
5130
|
+
}
|
5131
|
+
return true
|
5132
|
+
};
|
5133
|
+
|
5113
5134
|
const mathmlBuilder$6 = (group, style) => {
|
5114
5135
|
const font = group.font;
|
5115
5136
|
const newStyle = style.withFont(font);
|
@@ -5121,6 +5142,20 @@ const mathmlBuilder$6 = (group, style) => {
|
|
5121
5142
|
return mathGroup
|
5122
5143
|
}
|
5123
5144
|
// Check if it is possible to consolidate elements into a single <mi> element.
|
5145
|
+
if (isLongVariableName(group, font)) {
|
5146
|
+
// This is a \mathrm{…} group. It gets special treatment because symbolsOrd.js
|
5147
|
+
// wraps <mi> elements with <mrow>s to work around a Firefox bug.
|
5148
|
+
const mi = mathGroup.children[0].children[0];
|
5149
|
+
delete mi.attributes.mathvariant;
|
5150
|
+
for (let i = 1; i < mathGroup.children.length; i++) {
|
5151
|
+
mi.children[0].text += mathGroup.children[i].type === "mn"
|
5152
|
+
? mathGroup.children[i].children[0].text
|
5153
|
+
: mathGroup.children[i].children[0].children[0].text;
|
5154
|
+
}
|
5155
|
+
// Wrap in a <mrow> to prevent the same Firefox bug.
|
5156
|
+
const bogus = new mathMLTree.MathNode("mtext", new mathMLTree.TextNode("\u200b"));
|
5157
|
+
return new mathMLTree.MathNode("mrow", [bogus, mi])
|
5158
|
+
}
|
5124
5159
|
let canConsolidate = mathGroup.children[0].type === "mo";
|
5125
5160
|
for (let i = 1; i < mathGroup.children.length; i++) {
|
5126
5161
|
if (mathGroup.children[i].type === "mo" && font === "boldsymbol") {
|
@@ -13186,7 +13221,7 @@ class Style {
|
|
13186
13221
|
* https://mit-license.org/
|
13187
13222
|
*/
|
13188
13223
|
|
13189
|
-
const version = "0.10.
|
13224
|
+
const version = "0.10.23";
|
13190
13225
|
|
13191
13226
|
function postProcess(block) {
|
13192
13227
|
const labelMap = {};
|
package/dist/temmlPostProcess.js
CHANGED
package/package.json
CHANGED
package/src/buildMathML.js
CHANGED
@@ -80,9 +80,11 @@ export const consolidateText = mrow => {
|
|
80
80
|
}
|
81
81
|
|
82
82
|
const numberRegEx = /^[0-9]$/
|
83
|
-
const
|
84
|
-
return (node.type === "
|
85
|
-
|
83
|
+
const isDotOrComma = (node, followingNode) => {
|
84
|
+
return ((node.type === "textord" && node.text === ".") ||
|
85
|
+
(node.type === "atom" && node.text === ",")) &&
|
86
|
+
// Don't consolidate if there is a space after the comma.
|
87
|
+
node.loc && followingNode.loc && node.loc.end === followingNode.loc.start
|
86
88
|
}
|
87
89
|
const consolidateNumbers = expression => {
|
88
90
|
// Consolidate adjacent numbers. We want to return <mn>1,506.3</mn>,
|
@@ -105,7 +107,8 @@ const consolidateNumbers = expression => {
|
|
105
107
|
|
106
108
|
// Determine if numeral groups are separated by a comma or dot.
|
107
109
|
for (let i = nums.length - 1; i > 0; i--) {
|
108
|
-
if (nums[i - 1].end === nums[i].start - 2 &&
|
110
|
+
if (nums[i - 1].end === nums[i].start - 2 &&
|
111
|
+
isDotOrComma(expression[nums[i].start - 1], expression[nums[i].start])) {
|
109
112
|
// Merge the two groups.
|
110
113
|
nums[i - 1].end = nums[i].end
|
111
114
|
nums.splice(i, 1)
|
package/src/functions/font.js
CHANGED
@@ -2,6 +2,21 @@ import defineFunction, { normalizeArgument } from "../defineFunction"
|
|
2
2
|
import * as mml from "../buildMathML"
|
3
3
|
import mathMLTree from "../mathMLTree"
|
4
4
|
|
5
|
+
const isLongVariableName = (group, font) => {
|
6
|
+
if (font !== "mathrm" || group.body.type !== "ordgroup" || group.body.body.length === 1) {
|
7
|
+
return false
|
8
|
+
}
|
9
|
+
if (group.body.body[0].type !== "mathord") { return false }
|
10
|
+
for (let i = 1; i < group.body.body.length; i++) {
|
11
|
+
const parseNodeType = group.body.body[i].type
|
12
|
+
if (!(parseNodeType === "mathord" ||
|
13
|
+
(parseNodeType === "textord" && !isNaN(group.body.body[i].text)))) {
|
14
|
+
return false
|
15
|
+
}
|
16
|
+
}
|
17
|
+
return true
|
18
|
+
}
|
19
|
+
|
5
20
|
const mathmlBuilder = (group, style) => {
|
6
21
|
const font = group.font
|
7
22
|
const newStyle = style.withFont(font)
|
@@ -13,6 +28,20 @@ const mathmlBuilder = (group, style) => {
|
|
13
28
|
return mathGroup
|
14
29
|
}
|
15
30
|
// Check if it is possible to consolidate elements into a single <mi> element.
|
31
|
+
if (isLongVariableName(group, font)) {
|
32
|
+
// This is a \mathrm{…} group. It gets special treatment because symbolsOrd.js
|
33
|
+
// wraps <mi> elements with <mrow>s to work around a Firefox bug.
|
34
|
+
const mi = mathGroup.children[0].children[0];
|
35
|
+
delete mi.attributes.mathvariant
|
36
|
+
for (let i = 1; i < mathGroup.children.length; i++) {
|
37
|
+
mi.children[0].text += mathGroup.children[i].type === "mn"
|
38
|
+
? mathGroup.children[i].children[0].text
|
39
|
+
: mathGroup.children[i].children[0].children[0].text
|
40
|
+
}
|
41
|
+
// Wrap in a <mrow> to prevent the same Firefox bug.
|
42
|
+
const bogus = new mathMLTree.MathNode("mtext", new mathMLTree.TextNode("\u200b"))
|
43
|
+
return new mathMLTree.MathNode("mrow", [bogus, mi])
|
44
|
+
}
|
16
45
|
let canConsolidate = mathGroup.children[0].type === "mo"
|
17
46
|
for (let i = 1; i < mathGroup.children.length; i++) {
|
18
47
|
if (mathGroup.children[i].type === "mo" && font === "boldsymbol") {
|
@@ -25,7 +54,7 @@ const mathmlBuilder = (group, style) => {
|
|
25
54
|
}
|
26
55
|
if (!canConsolidate) { return mathGroup }
|
27
56
|
// Consolidate the <mi> elements.
|
28
|
-
const mi = mathGroup.children[0]
|
57
|
+
const mi = mathGroup.children[0];
|
29
58
|
for (let i = 1; i < mathGroup.children.length; i++) {
|
30
59
|
mi.children.push(mathGroup.children[i].children[0])
|
31
60
|
}
|
package/src/postProcess.js
CHANGED
package/src/symbols.js
CHANGED
@@ -218,6 +218,7 @@ defineSymbol(math, mathord, "\u2609", "\\astrosun", true);
|
|
218
218
|
defineSymbol(math, mathord, "\u263c", "\\sun", true);
|
219
219
|
defineSymbol(math, mathord, "\u263e", "\\leftmoon", true);
|
220
220
|
defineSymbol(math, mathord, "\u263d", "\\rightmoon", true);
|
221
|
+
defineSymbol(math, mathord, "\u2295", "\\Earth");
|
221
222
|
|
222
223
|
// AMS Negated Binary Relations
|
223
224
|
defineSymbol(math, rel, "\u226e", "\\nless", true);
|
@@ -445,6 +446,8 @@ defineSymbol(math, bin, "\u27d5", "\\leftouterjoin", true);
|
|
445
446
|
defineSymbol(math, bin, "\u27d6", "\\rightouterjoin", true);
|
446
447
|
defineSymbol(math, bin, "\u27d7", "\\fullouterjoin", true);
|
447
448
|
|
449
|
+
defineSymbol(math, bin, "\u2238", "\\dotminus", true); // stix
|
450
|
+
|
448
451
|
// AMS Arrows
|
449
452
|
// Note: unicode-math maps \u21e2 to their own function \rightdasharrow.
|
450
453
|
// We'll map it to AMS function \dashrightarrow. It produces the same atom.
|