temml 0.13.2 → 0.13.3
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/README.md +1 -1
- package/dist/Temml-Asana.css +5 -0
- package/dist/Temml-Latin-Modern.css +5 -0
- package/dist/Temml-Libertinus.css +5 -0
- package/dist/Temml-Local.css +5 -0
- package/dist/Temml-NotoSans.css +5 -0
- package/dist/Temml-STIX2.css +5 -0
- package/dist/temml.cjs +275 -252
- package/dist/temml.js +275 -252
- package/dist/temml.min.js +1 -1
- package/dist/temml.mjs +275 -252
- package/dist/temmlPostProcess.js +1 -1
- package/package.json +5 -3
- package/src/MacroExpander.js +2 -1
- package/src/environments/array.js +2 -2
- package/src/functions/bordermatrix.js +3 -5
- package/src/functions/delimiter.js +7 -10
- package/src/functions/enclose.js +20 -1
- package/src/functions/font.js +14 -4
- package/src/functions/phantom.js +1 -1
- package/src/postProcess.js +1 -1
|
@@ -14,13 +14,11 @@ defineFunction({
|
|
|
14
14
|
},
|
|
15
15
|
handler: ({ parser, funcName }, args, optArgs) => {
|
|
16
16
|
// Find out if the author has defined custom delimiters
|
|
17
|
-
let delimiters = ["(", ")"]
|
|
17
|
+
let delimiters = ["(", ")"]; // default
|
|
18
18
|
if (funcName === "\\bordermatrix" && optArgs[0] && optArgs[0].body) {
|
|
19
19
|
const body = optArgs[0].body
|
|
20
|
-
if (body.length ===
|
|
21
|
-
|
|
22
|
-
delimiters = [body[0].text, body[1].text]
|
|
23
|
-
}
|
|
20
|
+
if (body.length === 1 && body[0].type === "delimiter") {
|
|
21
|
+
delimiters = [body[0].left, body[0].right]
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
24
|
// consume the opening brace
|
|
@@ -424,17 +424,14 @@ defineFunction({
|
|
|
424
424
|
mathmlBuilder: (group) => {
|
|
425
425
|
const textNode = mml.makeText(group.delim, group.mode);
|
|
426
426
|
const middleNode = new mathMLTree.MathNode("mo", [textNode]);
|
|
427
|
-
middleNode.setAttribute("
|
|
428
|
-
|
|
429
|
-
|
|
427
|
+
middleNode.setAttribute("stretchy", "true")
|
|
428
|
+
middleNode.setAttribute("form", "infix")
|
|
429
|
+
if (textNode.text !== "/") {
|
|
430
|
+
// MathML gives 5/18em spacing to each <mo> element.
|
|
431
|
+
// \middle should get delimiter spacing instead.
|
|
432
|
+
middleNode.setAttribute("lspace", "0.05em");
|
|
433
|
+
middleNode.setAttribute("rspace", "0.05em");
|
|
430
434
|
}
|
|
431
|
-
// The next line is not semantically correct, but
|
|
432
|
-
// Chromium fails to stretch if it is not there.
|
|
433
|
-
middleNode.setAttribute("form", "prefix")
|
|
434
|
-
// MathML gives 5/18em spacing to each <mo> element.
|
|
435
|
-
// \middle should get delimiter spacing instead.
|
|
436
|
-
middleNode.setAttribute("lspace", "0.05em");
|
|
437
|
-
middleNode.setAttribute("rspace", "0.05em");
|
|
438
435
|
return middleNode;
|
|
439
436
|
}
|
|
440
437
|
});
|
package/src/functions/enclose.js
CHANGED
|
@@ -166,7 +166,7 @@ defineFunction({
|
|
|
166
166
|
|
|
167
167
|
defineFunction({
|
|
168
168
|
type: "enclose",
|
|
169
|
-
names: ["\\angl", "\\cancel", "\\bcancel", "\\xcancel", "\\
|
|
169
|
+
names: ["\\angl", "\\cancel", "\\bcancel", "\\xcancel", "\\overline",
|
|
170
170
|
"\\boxed", "\\longdiv", "\\phase"],
|
|
171
171
|
props: {
|
|
172
172
|
numArgs: 1
|
|
@@ -183,6 +183,25 @@ defineFunction({
|
|
|
183
183
|
mathmlBuilder
|
|
184
184
|
});
|
|
185
185
|
|
|
186
|
+
defineFunction({
|
|
187
|
+
type: "enclose",
|
|
188
|
+
names: ["\\sout"],
|
|
189
|
+
props: {
|
|
190
|
+
numArgs: 1,
|
|
191
|
+
allowedInText: true
|
|
192
|
+
},
|
|
193
|
+
handler({ parser, funcName }, args) {
|
|
194
|
+
const body = args[0];
|
|
195
|
+
return {
|
|
196
|
+
type: "enclose",
|
|
197
|
+
mode: parser.mode,
|
|
198
|
+
label: funcName,
|
|
199
|
+
body
|
|
200
|
+
};
|
|
201
|
+
},
|
|
202
|
+
mathmlBuilder
|
|
203
|
+
});
|
|
204
|
+
|
|
186
205
|
defineFunction({
|
|
187
206
|
type: "enclose",
|
|
188
207
|
names: ["\\underline"],
|
package/src/functions/font.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import defineFunction, { normalizeArgument } from "../defineFunction"
|
|
2
2
|
import * as mml from "../buildMathML"
|
|
3
3
|
import * as mathMLTree from "../mathMLTree"
|
|
4
|
+
import { variantChar } from "../replace"
|
|
5
|
+
|
|
6
|
+
const varNameFonts = ["mathrm", "mathit"];
|
|
4
7
|
|
|
5
8
|
const isLongVariableName = (group, font) => {
|
|
6
|
-
if (font
|
|
9
|
+
if (!varNameFonts.includes(font) || !group.body || group.body.type !== "ordgroup" ||
|
|
10
|
+
group.body.body.length === 1) {
|
|
7
11
|
return false
|
|
8
12
|
}
|
|
9
13
|
if (group.body.body[0].type !== "mathord") { return false }
|
|
@@ -29,8 +33,7 @@ const mathmlBuilder = (group, style) => {
|
|
|
29
33
|
}
|
|
30
34
|
// Check if it is possible to consolidate elements into a single <mi> element.
|
|
31
35
|
if (isLongVariableName(group, font)) {
|
|
32
|
-
// This is a \mathrm{…} group. It gets special treatment
|
|
33
|
-
// wraps <mi> elements with <mpadded>s to work around a Firefox bug.
|
|
36
|
+
// This is a \mathrm{…} or \mathit{…} group. It gets special treatment.
|
|
34
37
|
const mi = mathGroup.children[0].children[0].children
|
|
35
38
|
? mathGroup.children[0].children[0]
|
|
36
39
|
: mathGroup.children[0];
|
|
@@ -40,7 +43,14 @@ const mathmlBuilder = (group, style) => {
|
|
|
40
43
|
? mathGroup.children[i].children[0].children[0].text
|
|
41
44
|
: mathGroup.children[i].children[0].text
|
|
42
45
|
}
|
|
43
|
-
|
|
46
|
+
if (font === "mathit") {
|
|
47
|
+
// Long <mi> elements are normally rendered in upright font.
|
|
48
|
+
// To get italic, we need to convert each character to the corresponding italic character.
|
|
49
|
+
mi.children[0].text = mi.children[0].text.split("")
|
|
50
|
+
.map(c => variantChar(c, "italic")).join("")
|
|
51
|
+
return mi
|
|
52
|
+
}
|
|
53
|
+
// Otherwise, font is "mathrm". Wrap in a <mpadded> to prevent a Firefox spacing bug.
|
|
44
54
|
const mpadded = new mathMLTree.MathNode("mpadded", [mi])
|
|
45
55
|
mpadded.setAttribute("lspace", "0")
|
|
46
56
|
return mpadded
|
package/src/functions/phantom.js
CHANGED
|
@@ -67,7 +67,7 @@ defineFunction({
|
|
|
67
67
|
const inner = mml.buildExpression(ordargument(group.body), style);
|
|
68
68
|
const phantom = new mathMLTree.MathNode("mphantom", inner);
|
|
69
69
|
const node = new mathMLTree.MathNode("mpadded", [phantom]);
|
|
70
|
-
node.setAttribute("width", "
|
|
70
|
+
node.setAttribute("width", "0.1px");
|
|
71
71
|
return node;
|
|
72
72
|
}
|
|
73
73
|
});
|