temml 0.10.14 → 0.10.16
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 +18 -146
- package/dist/Temml-Latin-Modern.css +20 -148
- package/dist/Temml-Libertinus.css +18 -147
- package/dist/Temml-Local.css +19 -147
- package/dist/Temml-STIX2.css +18 -146
- package/dist/Temml.woff2 +0 -0
- package/dist/temml.cjs +221 -55
- package/dist/temml.d.ts +60 -0
- package/dist/temml.js +221 -55
- package/dist/temml.min.js +1 -1
- package/dist/temml.mjs +221 -55
- package/dist/temmlPostProcess.js +1 -1
- package/package.json +4 -2
- package/src/Parser.js +0 -1
- package/src/buildMathML.js +1 -3
- package/src/domTree.js +2 -2
- package/src/environments/array.js +99 -23
- package/src/functions/accent.js +17 -22
- package/src/functions/accentunder.js +1 -1
- package/src/functions/enclose.js +24 -3
- package/src/functions/supsub.js +8 -1
- package/src/functions/symbolsOrd.js +3 -1
- package/src/macros.js +3 -0
- package/src/postProcess.js +1 -1
- package/src/stretchy.js +48 -1
- package/src/symbols.js +13 -1
- package/temml.js +6 -0
package/dist/temml.mjs
CHANGED
@@ -476,7 +476,7 @@ class TextNode$1 {
|
|
476
476
|
}
|
477
477
|
}
|
478
478
|
|
479
|
-
|
479
|
+
/*
|
480
480
|
* This node represents an image embed (<img>) element.
|
481
481
|
*/
|
482
482
|
class Img {
|
@@ -521,7 +521,7 @@ class Img {
|
|
521
521
|
markup += ` style="${utils.escape(styles)}"`;
|
522
522
|
}
|
523
523
|
|
524
|
-
markup += "
|
524
|
+
markup += ">";
|
525
525
|
return markup;
|
526
526
|
}
|
527
527
|
}
|
@@ -697,6 +697,34 @@ var mathMLTree = {
|
|
697
697
|
* This file provides support for building horizontal stretchy elements.
|
698
698
|
*/
|
699
699
|
|
700
|
+
// TODO: Remove when Chromium stretches \widetilde & \widehat
|
701
|
+
const estimatedWidth = node => {
|
702
|
+
let width = 0;
|
703
|
+
if (node.body) {
|
704
|
+
for (const item of node.body) {
|
705
|
+
width += estimatedWidth(item);
|
706
|
+
}
|
707
|
+
} else if (node.type === "supsub") {
|
708
|
+
width += estimatedWidth(node.base);
|
709
|
+
if (node.sub) { width += 0.7 * estimatedWidth(node.sub); }
|
710
|
+
if (node.sup) { width += 0.7 * estimatedWidth(node.sup); }
|
711
|
+
} else if (node.type === "mathord" || node.type === "textord") {
|
712
|
+
for (const ch of node.text.split('')) {
|
713
|
+
const codePoint = ch.codePointAt(0);
|
714
|
+
if ((0x60 < codePoint && codePoint < 0x7B) || (0x03B0 < codePoint && codePoint < 0x3CA)) {
|
715
|
+
width += 0.56; // lower case latin or greek. Use advance width of letter n
|
716
|
+
} else if (0x2F < codePoint && codePoint < 0x3A) {
|
717
|
+
width += 0.50; // numerals.
|
718
|
+
} else {
|
719
|
+
width += 0.92; // advance width of letter M
|
720
|
+
}
|
721
|
+
}
|
722
|
+
} else {
|
723
|
+
width += 1.0;
|
724
|
+
}
|
725
|
+
return width
|
726
|
+
};
|
727
|
+
|
700
728
|
const stretchyCodePoint = {
|
701
729
|
widehat: "^",
|
702
730
|
widecheck: "ˇ",
|
@@ -754,8 +782,27 @@ const mathMLnode = function(label) {
|
|
754
782
|
return node
|
755
783
|
};
|
756
784
|
|
785
|
+
const crookedWides = ["\\widetilde", "\\widehat", "\\widecheck", "\\utilde"];
|
786
|
+
|
787
|
+
// TODO: Remove when Chromium stretches \widetilde & \widehat
|
788
|
+
const accentNode = (group) => {
|
789
|
+
const mo = mathMLnode(group.label);
|
790
|
+
if (crookedWides.includes(group.label)) {
|
791
|
+
const width = estimatedWidth(group.base);
|
792
|
+
if (1 < width && width < 1.6) {
|
793
|
+
mo.classes.push("tml-crooked-2");
|
794
|
+
} else if (1.6 <= width && width < 2.5) {
|
795
|
+
mo.classes.push("tml-crooked-3");
|
796
|
+
} else if (2.5 <= width) {
|
797
|
+
mo.classes.push("tml-crooked-4");
|
798
|
+
}
|
799
|
+
}
|
800
|
+
return mo
|
801
|
+
};
|
802
|
+
|
757
803
|
var stretchy = {
|
758
|
-
mathMLnode
|
804
|
+
mathMLnode,
|
805
|
+
accentNode
|
759
806
|
};
|
760
807
|
|
761
808
|
/**
|
@@ -971,6 +1018,10 @@ defineSymbol(math, mathord, "\u21af", "\\lightning", true);
|
|
971
1018
|
defineSymbol(math, mathord, "\u220E", "\\QED", true);
|
972
1019
|
defineSymbol(math, mathord, "\u2030", "\\permil", true);
|
973
1020
|
defineSymbol(text, textord, "\u2030", "\\permil");
|
1021
|
+
defineSymbol(math, mathord, "\u2609", "\\astrosun", true);
|
1022
|
+
defineSymbol(math, mathord, "\u263c", "\\sun", true);
|
1023
|
+
defineSymbol(math, mathord, "\u263e", "\\leftmoon", true);
|
1024
|
+
defineSymbol(math, mathord, "\u263d", "\\rightmoon", true);
|
974
1025
|
|
975
1026
|
// AMS Negated Binary Relations
|
976
1027
|
defineSymbol(math, rel, "\u226e", "\\nless", true);
|
@@ -1049,6 +1100,8 @@ defineSymbol(math, textord, "\u2127", "\\mho");
|
|
1049
1100
|
defineSymbol(math, textord, "\u2132", "\\Finv", true);
|
1050
1101
|
defineSymbol(math, textord, "\u2141", "\\Game", true);
|
1051
1102
|
defineSymbol(math, textord, "\u2035", "\\backprime");
|
1103
|
+
defineSymbol(math, textord, "\u2036", "\\backdprime");
|
1104
|
+
defineSymbol(math, textord, "\u2037", "\\backtrprime");
|
1052
1105
|
defineSymbol(math, textord, "\u25b2", "\\blacktriangle");
|
1053
1106
|
defineSymbol(math, textord, "\u25bc", "\\blacktriangledown");
|
1054
1107
|
defineSymbol(math, textord, "\u25a0", "\\blacksquare");
|
@@ -1252,6 +1305,9 @@ defineSymbol(text, textord, "\u2423", "\\textvisiblespace", true);
|
|
1252
1305
|
defineSymbol(math, textord, "\u2220", "\\angle", true);
|
1253
1306
|
defineSymbol(math, textord, "\u221e", "\\infty", true);
|
1254
1307
|
defineSymbol(math, textord, "\u2032", "\\prime");
|
1308
|
+
defineSymbol(math, textord, "\u2033", "\\dprime");
|
1309
|
+
defineSymbol(math, textord, "\u2034", "\\trprime");
|
1310
|
+
defineSymbol(math, textord, "\u2057", "\\qprime");
|
1255
1311
|
defineSymbol(math, textord, "\u25b3", "\\triangle");
|
1256
1312
|
defineSymbol(text, textord, "\u0391", "\\Alpha", true);
|
1257
1313
|
defineSymbol(text, textord, "\u0392", "\\Beta", true);
|
@@ -1431,7 +1487,8 @@ defineSymbol(math, punct, ";", ";");
|
|
1431
1487
|
defineSymbol(math, bin, "\u22bc", "\\barwedge", true);
|
1432
1488
|
defineSymbol(math, bin, "\u22bb", "\\veebar", true);
|
1433
1489
|
defineSymbol(math, bin, "\u2299", "\\odot", true);
|
1434
|
-
|
1490
|
+
// Firefox turns ⊕ into an emoji. So append \uFE0E. Define Unicode character in macros, not here.
|
1491
|
+
defineSymbol(math, bin, "\u2295\uFE0E", "\\oplus");
|
1435
1492
|
defineSymbol(math, bin, "\u2297", "\\otimes", true);
|
1436
1493
|
defineSymbol(math, textord, "\u2202", "\\partial", true);
|
1437
1494
|
defineSymbol(math, bin, "\u2298", "\\oslash", true);
|
@@ -1662,6 +1719,8 @@ for (let i = 0; i < letters.length; i++) {
|
|
1662
1719
|
defineSymbol(math, mathord, ch, ch);
|
1663
1720
|
defineSymbol(text, textord, ch, ch);
|
1664
1721
|
}
|
1722
|
+
// Prevent Firefox from using a dotless i.
|
1723
|
+
defineSymbol(text, textord, "i\uFE0E", "i");
|
1665
1724
|
|
1666
1725
|
// Some more letters in Unicode Basic Multilingual Plane.
|
1667
1726
|
const narrow = "ÇÐÞçþℂℍℕℙℚℝℤℎℏℊℋℌℐℑℒℓ℘ℛℜℬℰℱℳℭℨ";
|
@@ -2129,9 +2188,7 @@ function buildMathML(tree, texExpression, style, settings) {
|
|
2129
2188
|
}
|
2130
2189
|
if (settings.displayMode) {
|
2131
2190
|
math.setAttribute("display", "block");
|
2132
|
-
math.style.display = math
|
2133
|
-
? "inline"
|
2134
|
-
: "block math"; // necessary in Chromium.
|
2191
|
+
math.style.display = "block math"; // necessary in Chromium.
|
2135
2192
|
// Firefox and Safari do not recognize display: "block math".
|
2136
2193
|
// Set a class so that the CSS file can set display: block.
|
2137
2194
|
math.classes = ["tml-display"];
|
@@ -2141,7 +2198,7 @@ function buildMathML(tree, texExpression, style, settings) {
|
|
2141
2198
|
|
2142
2199
|
const mathmlBuilder$a = (group, style) => {
|
2143
2200
|
const accentNode = group.isStretchy
|
2144
|
-
? stretchy.
|
2201
|
+
? stretchy.accentNode(group)
|
2145
2202
|
: new mathMLTree.MathNode("mo", [makeText(group.label, group.mode)]);
|
2146
2203
|
|
2147
2204
|
if (group.label === "\\vec") {
|
@@ -2161,25 +2218,21 @@ const mathmlBuilder$a = (group, style) => {
|
|
2161
2218
|
return node;
|
2162
2219
|
};
|
2163
2220
|
|
2164
|
-
const
|
2165
|
-
|
2166
|
-
|
2167
|
-
|
2168
|
-
|
2169
|
-
|
2170
|
-
|
2171
|
-
|
2172
|
-
|
2173
|
-
|
2174
|
-
|
2175
|
-
|
2176
|
-
|
2177
|
-
|
2178
|
-
|
2179
|
-
]
|
2180
|
-
.map((accent) => `\\${accent}`)
|
2181
|
-
.join("|")
|
2182
|
-
);
|
2221
|
+
const nonStretchyAccents = new Set([
|
2222
|
+
"\\acute",
|
2223
|
+
"\\grave",
|
2224
|
+
"\\ddot",
|
2225
|
+
"\\dddot",
|
2226
|
+
"\\ddddot",
|
2227
|
+
"\\tilde",
|
2228
|
+
"\\bar",
|
2229
|
+
"\\breve",
|
2230
|
+
"\\check",
|
2231
|
+
"\\hat",
|
2232
|
+
"\\vec",
|
2233
|
+
"\\dot",
|
2234
|
+
"\\mathring"
|
2235
|
+
]);
|
2183
2236
|
|
2184
2237
|
// Accents
|
2185
2238
|
defineFunction({
|
@@ -2217,7 +2270,7 @@ defineFunction({
|
|
2217
2270
|
handler: (context, args) => {
|
2218
2271
|
const base = normalizeArgument(args[0]);
|
2219
2272
|
|
2220
|
-
const isStretchy = !
|
2273
|
+
const isStretchy = !nonStretchyAccents.has(context.funcName);
|
2221
2274
|
|
2222
2275
|
return {
|
2223
2276
|
type: "accent",
|
@@ -2255,7 +2308,6 @@ defineFunction({
|
|
2255
2308
|
mode: mode,
|
2256
2309
|
label: context.funcName,
|
2257
2310
|
isStretchy: false,
|
2258
|
-
isShifty: true,
|
2259
2311
|
base: base
|
2260
2312
|
};
|
2261
2313
|
},
|
@@ -2285,7 +2337,7 @@ defineFunction({
|
|
2285
2337
|
};
|
2286
2338
|
},
|
2287
2339
|
mathmlBuilder: (group, style) => {
|
2288
|
-
const accentNode = stretchy.
|
2340
|
+
const accentNode = stretchy.accentNode(group);
|
2289
2341
|
accentNode.style["math-depth"] = 0;
|
2290
2342
|
const node = new mathMLTree.MathNode("munder", [
|
2291
2343
|
buildGroup$1(group.base, style),
|
@@ -3822,10 +3874,20 @@ const mathmlBuilder$8 = (group, style) => {
|
|
3822
3874
|
node.style.borderBottom = "0.065em solid";
|
3823
3875
|
break
|
3824
3876
|
case "\\cancel":
|
3825
|
-
node.
|
3877
|
+
node.style.background = `linear-gradient(to top left,
|
3878
|
+
rgba(0,0,0,0) 0%,
|
3879
|
+
rgba(0,0,0,0) calc(50% - 0.06em),
|
3880
|
+
rgba(0,0,0,1) 50%,
|
3881
|
+
rgba(0,0,0,0) calc(50% + 0.06em),
|
3882
|
+
rgba(0,0,0,0) 100%);`;
|
3826
3883
|
break
|
3827
3884
|
case "\\bcancel":
|
3828
|
-
node.
|
3885
|
+
node.style.background = `linear-gradient(to top right,
|
3886
|
+
rgba(0,0,0,0) 0%,
|
3887
|
+
rgba(0,0,0,0) calc(50% - 0.06em),
|
3888
|
+
rgba(0,0,0,1) 50%,
|
3889
|
+
rgba(0,0,0,0) calc(50% + 0.06em),
|
3890
|
+
rgba(0,0,0,0) 100%);`;
|
3829
3891
|
break
|
3830
3892
|
/*
|
3831
3893
|
case "\\longdiv":
|
@@ -3869,7 +3931,18 @@ const mathmlBuilder$8 = (group, style) => {
|
|
3869
3931
|
break
|
3870
3932
|
}
|
3871
3933
|
case "\\xcancel":
|
3872
|
-
node.
|
3934
|
+
node.style.background = `linear-gradient(to top left,
|
3935
|
+
rgba(0,0,0,0) 0%,
|
3936
|
+
rgba(0,0,0,0) calc(50% - 0.06em),
|
3937
|
+
rgba(0,0,0,1) 50%,
|
3938
|
+
rgba(0,0,0,0) calc(50% + 0.06em),
|
3939
|
+
rgba(0,0,0,0) 100%),
|
3940
|
+
linear-gradient(to top right,
|
3941
|
+
rgba(0,0,0,0) 0%,
|
3942
|
+
rgba(0,0,0,0) calc(50% - 0.06em),
|
3943
|
+
rgba(0,0,0,1) 50%,
|
3944
|
+
rgba(0,0,0,0) calc(50% + 0.06em),
|
3945
|
+
rgba(0,0,0,0) 100%);`;
|
3873
3946
|
break
|
3874
3947
|
}
|
3875
3948
|
if (group.backgroundColor) {
|
@@ -4300,24 +4373,98 @@ const mathmlBuilder$7 = function(group, style) {
|
|
4300
4373
|
// Write horizontal rules
|
4301
4374
|
if (i === 0 && hlines[0].length > 0) {
|
4302
4375
|
if (hlines[0].length === 2) {
|
4303
|
-
mtr.
|
4376
|
+
mtr.children.forEach(cell => { cell.style.borderTop = "0.15em double"; });
|
4304
4377
|
} else {
|
4305
|
-
mtr.
|
4378
|
+
mtr.children.forEach(cell => {
|
4379
|
+
cell.style.borderTop = hlines[0][0] ? "0.06em dashed" : "0.06em solid";
|
4380
|
+
});
|
4306
4381
|
}
|
4307
4382
|
}
|
4308
4383
|
if (hlines[i + 1].length > 0) {
|
4309
4384
|
if (hlines[i + 1].length === 2) {
|
4310
|
-
mtr.
|
4385
|
+
mtr.children.forEach(cell => { cell.style.borderBottom = "0.15em double"; });
|
4311
4386
|
} else {
|
4312
|
-
mtr.
|
4387
|
+
mtr.children.forEach(cell => {
|
4388
|
+
cell.style.borderBottom = hlines[i + 1][0] ? "0.06em dashed" : "0.06em solid";
|
4389
|
+
});
|
4313
4390
|
}
|
4314
4391
|
}
|
4315
4392
|
tbl.push(mtr);
|
4316
4393
|
}
|
4317
|
-
|
4394
|
+
|
4318
4395
|
if (group.envClasses.length > 0) {
|
4319
|
-
|
4396
|
+
const pad = group.envClasses.includes("jot")
|
4397
|
+
? "0.7" // 0.5ex + 0.09em top & bot padding
|
4398
|
+
: group.envClasses.includes("small")
|
4399
|
+
? "0.35"
|
4400
|
+
: "0.5"; // 0.5ex default top & bot padding
|
4401
|
+
const sidePadding = group.envClasses.includes("abut")
|
4402
|
+
? "0"
|
4403
|
+
: group.envClasses.includes("cases")
|
4404
|
+
? "0"
|
4405
|
+
: group.envClasses.includes("small")
|
4406
|
+
? "0.1389"
|
4407
|
+
: group.envClasses.includes("cd")
|
4408
|
+
? "0.25"
|
4409
|
+
: "0.4"; // default side padding
|
4410
|
+
|
4411
|
+
const numCols = tbl.length === 0 ? 0 : tbl[0].children.length;
|
4412
|
+
|
4413
|
+
const sidePad = (j, hand) => {
|
4414
|
+
if (j === 0 && hand === 0) { return "0" }
|
4415
|
+
if (j === numCols - 1 && hand === 1) { return "0" }
|
4416
|
+
if (group.envClasses[0] !== "align") { return sidePadding }
|
4417
|
+
if (hand === 1) { return "0" }
|
4418
|
+
if (group.addEqnNum) {
|
4419
|
+
return (j % 2) ? "1" : "0"
|
4420
|
+
} else {
|
4421
|
+
return (j % 2) ? "0" : "1"
|
4422
|
+
}
|
4423
|
+
};
|
4424
|
+
|
4425
|
+
// Padding
|
4426
|
+
for (let i = 0; i < tbl.length; i++) {
|
4427
|
+
for (let j = 0; j < tbl[i].children.length; j++) {
|
4428
|
+
tbl[i].children[j].style.padding = `${pad}ex ${sidePad(j, 1)}em ${pad}ex ${sidePad(j, 0)}em`;
|
4429
|
+
}
|
4430
|
+
}
|
4431
|
+
|
4432
|
+
// Justification
|
4433
|
+
const align = group.envClasses.includes("align") || group.envClasses.includes("alignat");
|
4434
|
+
for (let i = 0; i < tbl.length; i++) {
|
4435
|
+
const row = tbl[i];
|
4436
|
+
if (align) {
|
4437
|
+
for (let j = 0; j < row.children.length; j++) {
|
4438
|
+
// Chromium does not recognize text-align: left. Use -webkit-
|
4439
|
+
// TODO: Remove -webkit- when Chromium no longer needs it.
|
4440
|
+
row.children[j].style.textAlign = "-webkit-" + (j % 2 ? "left" : "right");
|
4441
|
+
}
|
4442
|
+
if (group.addEqnNum) {
|
4443
|
+
const k = group.leqno ? 0 : row.children.length - 1;
|
4444
|
+
row.children[k].style.textAlign = "-webkit-" + (group.leqno ? "left" : "right");
|
4445
|
+
}
|
4446
|
+
}
|
4447
|
+
if (row.children.length > 1 && group.envClasses.includes("cases")) {
|
4448
|
+
row.children[1].style.padding = row.children[1].style.padding.replace(/0em$/, "1em");
|
4449
|
+
}
|
4450
|
+
|
4451
|
+
if (group.envClasses.includes("cases") || group.envClasses.includes("subarray")) {
|
4452
|
+
for (const cell of row.children) {
|
4453
|
+
cell.style.textAlign = "-webkit-" + "left";
|
4454
|
+
}
|
4455
|
+
}
|
4456
|
+
}
|
4457
|
+
} else {
|
4458
|
+
// Set zero padding on side of the matrix
|
4459
|
+
for (let i = 0; i < tbl.length; i++) {
|
4460
|
+
tbl[i].children[0].style.paddingLeft = "0em";
|
4461
|
+
if (tbl[i].children.length === tbl[0].children.length) {
|
4462
|
+
tbl[i].children[tbl[i].children.length - 1].style.paddingRight = "0em";
|
4463
|
+
}
|
4464
|
+
}
|
4320
4465
|
}
|
4466
|
+
|
4467
|
+
let table = new mathMLTree.MathNode("mtable", tbl);
|
4321
4468
|
if (group.scriptLevel === "display") { table.setAttribute("displaystyle", "true"); }
|
4322
4469
|
|
4323
4470
|
if (group.addEqnNum || group.envClasses.includes("multline")) {
|
@@ -4397,6 +4544,8 @@ const mathmlBuilder$7 = function(group, style) {
|
|
4397
4544
|
align = "left " + (align.length > 0 ? align : "center ") + "right ";
|
4398
4545
|
}
|
4399
4546
|
if (align) {
|
4547
|
+
// Firefox reads this attribute, not the -webkit-left|right written above.
|
4548
|
+
// TODO: When Chrome no longer needs "-webkit-", use CSS and delete the next line.
|
4400
4549
|
table.setAttribute("columnalign", align.trim());
|
4401
4550
|
}
|
4402
4551
|
|
@@ -4421,7 +4570,7 @@ const alignedHandler = function(context, args) {
|
|
4421
4570
|
cols,
|
4422
4571
|
addEqnNum: context.envName === "align" || context.envName === "alignat",
|
4423
4572
|
emptySingleRow: true,
|
4424
|
-
envClasses: ["
|
4573
|
+
envClasses: ["abut", "jot"], // set row spacing & provisional column spacing
|
4425
4574
|
maxNumCols: context.envName === "split" ? 2 : undefined,
|
4426
4575
|
leqno: context.parser.settings.leqno
|
4427
4576
|
},
|
@@ -4439,18 +4588,22 @@ const alignedHandler = function(context, args) {
|
|
4439
4588
|
// binary. This behavior is implemented in amsmath's \start@aligned.
|
4440
4589
|
let numMaths;
|
4441
4590
|
let numCols = 0;
|
4442
|
-
|
4591
|
+
const isAlignedAt = context.envName.indexOf("at") > -1;
|
4592
|
+
if (args[0] && isAlignedAt) {
|
4593
|
+
// alignat environment takes an argument w/ number of columns
|
4443
4594
|
let arg0 = "";
|
4444
4595
|
for (let i = 0; i < args[0].body.length; i++) {
|
4445
4596
|
const textord = assertNodeType(args[0].body[i], "textord");
|
4446
4597
|
arg0 += textord.text;
|
4447
4598
|
}
|
4599
|
+
if (isNaN(arg0)) {
|
4600
|
+
throw new ParseError("The alignat enviroment requires a numeric first argument.")
|
4601
|
+
}
|
4448
4602
|
numMaths = Number(arg0);
|
4449
4603
|
numCols = numMaths * 2;
|
4450
4604
|
}
|
4451
|
-
const isAligned = !numCols;
|
4452
4605
|
res.body.forEach(function(row) {
|
4453
|
-
if (
|
4606
|
+
if (isAlignedAt) {
|
4454
4607
|
// Case 1
|
4455
4608
|
const curMaths = row.length / 2;
|
4456
4609
|
if (numMaths < curMaths) {
|
@@ -4478,14 +4631,10 @@ const alignedHandler = function(context, args) {
|
|
4478
4631
|
align: align
|
4479
4632
|
};
|
4480
4633
|
}
|
4481
|
-
if (context.envName === "split") ; else if (
|
4482
|
-
res.envClasses.push("
|
4483
|
-
} else if (isAligned) {
|
4484
|
-
res.envClasses[1] = context.envName === "align*"
|
4485
|
-
? "align-star"
|
4486
|
-
: "align"; // Sets column spacing & justification
|
4634
|
+
if (context.envName === "split") ; else if (isAlignedAt) {
|
4635
|
+
res.envClasses.push("alignat"); // Sets justification
|
4487
4636
|
} else {
|
4488
|
-
res.envClasses
|
4637
|
+
res.envClasses[0] = "align"; // Sets column spacing & justification
|
4489
4638
|
}
|
4490
4639
|
return res;
|
4491
4640
|
};
|
@@ -4735,7 +4884,7 @@ defineEnvironment({
|
|
4735
4884
|
}
|
4736
4885
|
const res = {
|
4737
4886
|
cols: [],
|
4738
|
-
envClasses: ["
|
4887
|
+
envClasses: ["abut", "jot"],
|
4739
4888
|
addEqnNum: context.envName === "gather",
|
4740
4889
|
emptySingleRow: true,
|
4741
4890
|
leqno: context.parser.settings.leqno
|
@@ -7234,7 +7383,14 @@ defineFunctionBuilders({
|
|
7234
7383
|
}
|
7235
7384
|
|
7236
7385
|
if (group.sup) {
|
7237
|
-
|
7386
|
+
const sup = buildGroup$1(group.sup, childStyle);
|
7387
|
+
const testNode = sup.type === "mrow" ? sup.children[0] : sup;
|
7388
|
+
if ((testNode.type === "mo" && testNode.classes.includes("tml-prime"))
|
7389
|
+
&& group.base && group.base.text && group.base.text === "f") {
|
7390
|
+
// Chromium does not address italic correction on prime. Prevent f′ from overlapping.
|
7391
|
+
testNode.classes.push("prime-pad");
|
7392
|
+
}
|
7393
|
+
children.push(sup);
|
7238
7394
|
}
|
7239
7395
|
|
7240
7396
|
let nodeType;
|
@@ -7700,6 +7856,8 @@ const smallCaps = Object.freeze({
|
|
7700
7856
|
|
7701
7857
|
const numberRegEx = /^\d(?:[\d,.]*\d)?$/;
|
7702
7858
|
const latinRegEx = /[A-Ba-z]/;
|
7859
|
+
const primes = new Set(["\\prime", "\\dprime", "\\trprime", "\\qprime",
|
7860
|
+
"\\backprime", "\\backdprime", "\\backtrprime"]);
|
7703
7861
|
|
7704
7862
|
const italicNumber = (text, variant, tag) => {
|
7705
7863
|
const mn = new mathMLTree.MathNode(tag, [text]);
|
@@ -7767,7 +7925,7 @@ defineFunctionBuilders({
|
|
7767
7925
|
text.text = variantChar(text.text, variant);
|
7768
7926
|
}
|
7769
7927
|
node = new mathMLTree.MathNode("mtext", [text]);
|
7770
|
-
} else if (group.text
|
7928
|
+
} else if (primes.has(group.text)) {
|
7771
7929
|
node = new mathMLTree.MathNode("mo", [text]);
|
7772
7930
|
// TODO: If/when Chromium uses ssty variant for prime, remove the next line.
|
7773
7931
|
node.classes.push("tml-prime");
|
@@ -8421,6 +8579,9 @@ defineMacro("\\char", function(context) {
|
|
8421
8579
|
// This macro provides a better rendering.
|
8422
8580
|
defineMacro("\\surd", '\\sqrt{\\vphantom{|}}');
|
8423
8581
|
|
8582
|
+
// See comment for \oplus in symbols.js.
|
8583
|
+
defineMacro("\u2295", "\\oplus");
|
8584
|
+
|
8424
8585
|
defineMacro("\\hbox", "\\text{#1}");
|
8425
8586
|
|
8426
8587
|
// Per TeXbook p.122, "/" gets zero operator spacing.
|
@@ -12701,7 +12862,6 @@ class Parser {
|
|
12701
12862
|
loc: SourceLocation.range(nucleus),
|
12702
12863
|
label: command,
|
12703
12864
|
isStretchy: false,
|
12704
|
-
isShifty: true,
|
12705
12865
|
base: symbol
|
12706
12866
|
};
|
12707
12867
|
}
|
@@ -12899,7 +13059,7 @@ class Style {
|
|
12899
13059
|
* https://mit-license.org/
|
12900
13060
|
*/
|
12901
13061
|
|
12902
|
-
const version = "0.10.
|
13062
|
+
const version = "0.10.16";
|
12903
13063
|
|
12904
13064
|
function postProcess(block) {
|
12905
13065
|
const labelMap = {};
|
@@ -12950,6 +13110,7 @@ function postProcess(block) {
|
|
12950
13110
|
/* eslint no-console:0 */
|
12951
13111
|
|
12952
13112
|
/**
|
13113
|
+
* @type {import('./temml').render}
|
12953
13114
|
* Parse and build an expression, and place that expression in the DOM node
|
12954
13115
|
* given.
|
12955
13116
|
*/
|
@@ -12987,6 +13148,7 @@ if (typeof document !== "undefined") {
|
|
12987
13148
|
}
|
12988
13149
|
|
12989
13150
|
/**
|
13151
|
+
* @type {import('./temml').renderToString}
|
12990
13152
|
* Parse and build an expression, and return the markup for that.
|
12991
13153
|
*/
|
12992
13154
|
const renderToString = function(expression, options) {
|
@@ -12995,6 +13157,7 @@ const renderToString = function(expression, options) {
|
|
12995
13157
|
};
|
12996
13158
|
|
12997
13159
|
/**
|
13160
|
+
* @type {import('./temml').generateParseTree}
|
12998
13161
|
* Parse an expression and return the parse tree.
|
12999
13162
|
*/
|
13000
13163
|
const generateParseTree = function(expression, options) {
|
@@ -13003,6 +13166,7 @@ const generateParseTree = function(expression, options) {
|
|
13003
13166
|
};
|
13004
13167
|
|
13005
13168
|
/**
|
13169
|
+
* @type {import('./temml').definePreamble}
|
13006
13170
|
* Take an expression which contains a preamble.
|
13007
13171
|
* Parse it and return the macros.
|
13008
13172
|
*/
|
@@ -13035,6 +13199,7 @@ const renderError = function(error, expression, options) {
|
|
13035
13199
|
};
|
13036
13200
|
|
13037
13201
|
/**
|
13202
|
+
* @type {import('./temml').renderToMathMLTree}
|
13038
13203
|
* Generates and returns the Temml build tree. This is used for advanced
|
13039
13204
|
* use cases (like rendering to custom output).
|
13040
13205
|
*/
|
@@ -13052,6 +13217,7 @@ const renderToMathMLTree = function(expression, options) {
|
|
13052
13217
|
}
|
13053
13218
|
};
|
13054
13219
|
|
13220
|
+
/** @type {import('./temml').default} */
|
13055
13221
|
var temml = {
|
13056
13222
|
/**
|
13057
13223
|
* Current Temml version
|
package/dist/temmlPostProcess.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "temml",
|
3
|
-
"version": "0.10.
|
3
|
+
"version": "0.10.16",
|
4
4
|
"description": "TeX to MathML conversion in JavaScript.",
|
5
5
|
"main": "dist/temml.js",
|
6
6
|
"engines": {
|
@@ -8,7 +8,9 @@
|
|
8
8
|
},
|
9
9
|
"exports": {
|
10
10
|
".": {
|
11
|
-
"require": "./dist/temml.cjs"
|
11
|
+
"require": "./dist/temml.cjs",
|
12
|
+
"import": "./dist/temml.mjs",
|
13
|
+
"types": "./dist/temml.d.ts"
|
12
14
|
},
|
13
15
|
"./*": "./*"
|
14
16
|
},
|
package/src/Parser.js
CHANGED
package/src/buildMathML.js
CHANGED
@@ -260,9 +260,7 @@ export default function buildMathML(tree, texExpression, style, settings) {
|
|
260
260
|
}
|
261
261
|
if (settings.displayMode) {
|
262
262
|
math.setAttribute("display", "block");
|
263
|
-
math.style.display = math
|
264
|
-
? "inline"
|
265
|
-
: "block math" // necessary in Chromium.
|
263
|
+
math.style.display = "block math" // necessary in Chromium.
|
266
264
|
// Firefox and Safari do not recognize display: "block math".
|
267
265
|
// Set a class so that the CSS file can set display: block.
|
268
266
|
math.classes = ["tml-display"]
|
package/src/domTree.js
CHANGED
@@ -134,7 +134,7 @@ export class TextNode {
|
|
134
134
|
}
|
135
135
|
}
|
136
136
|
|
137
|
-
|
137
|
+
/*
|
138
138
|
* This node represents an image embed (<img>) element.
|
139
139
|
*/
|
140
140
|
export class Img {
|
@@ -179,7 +179,7 @@ export class Img {
|
|
179
179
|
markup += ` style="${utils.escape(styles)}"`;
|
180
180
|
}
|
181
181
|
|
182
|
-
markup += "
|
182
|
+
markup += ">";
|
183
183
|
return markup;
|
184
184
|
}
|
185
185
|
}
|