temml 0.10.13 → 0.10.15
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 -147
- package/dist/Temml-Latin-Modern.css +5 -148
- package/dist/Temml-Libertinus.css +5 -148
- package/dist/Temml-Local.css +5 -147
- package/dist/Temml-STIX2.css +5 -147
- package/dist/temml.cjs +197 -99
- package/dist/temml.d.ts +60 -0
- package/dist/temml.js +197 -99
- package/dist/temml.min.js +1 -1
- package/dist/temml.mjs +197 -99
- package/dist/temmlPostProcess.js +1 -1
- package/package.json +4 -2
- package/src/buildMathML.js +4 -3
- package/src/environments/array.js +95 -23
- package/src/functions/delimsizing.js +2 -3
- package/src/functions/enclose.js +37 -16
- package/src/functions/raise.js +7 -7
- package/src/linebreaking.js +45 -48
- package/src/macros.js +1 -4
- package/src/postProcess.js +1 -1
- package/src/symbols.js +5 -0
- package/temml.js +6 -0
package/dist/temml.cjs
CHANGED
@@ -973,6 +973,10 @@ defineSymbol(math, mathord, "\u21af", "\\lightning", true);
|
|
973
973
|
defineSymbol(math, mathord, "\u220E", "\\QED", true);
|
974
974
|
defineSymbol(math, mathord, "\u2030", "\\permil", true);
|
975
975
|
defineSymbol(text, textord, "\u2030", "\\permil");
|
976
|
+
defineSymbol(math, mathord, "\u2609", "\\astrosun", true);
|
977
|
+
defineSymbol(math, mathord, "\u263c", "\\sun", true);
|
978
|
+
defineSymbol(math, mathord, "\u263e", "\\leftmoon", true);
|
979
|
+
defineSymbol(math, mathord, "\u263d", "\\rightmoon", true);
|
976
980
|
|
977
981
|
// AMS Negated Binary Relations
|
978
982
|
defineSymbol(math, rel, "\u226e", "\\nless", true);
|
@@ -1117,6 +1121,7 @@ defineSymbol(math, rel, "\u2ab7", "\\precapprox", true);
|
|
1117
1121
|
defineSymbol(math, rel, "\u22b2", "\\vartriangleleft");
|
1118
1122
|
defineSymbol(math, rel, "\u22b4", "\\trianglelefteq");
|
1119
1123
|
defineSymbol(math, rel, "\u22a8", "\\vDash", true);
|
1124
|
+
defineSymbol(math, rel, "\u22ab", "\\VDash", true);
|
1120
1125
|
defineSymbol(math, rel, "\u22aa", "\\Vvdash", true);
|
1121
1126
|
defineSymbol(math, rel, "\u2323", "\\smallsmile");
|
1122
1127
|
defineSymbol(math, rel, "\u2322", "\\smallfrown");
|
@@ -1766,13 +1771,16 @@ for (let i = 0; i < 10; i++) {
|
|
1766
1771
|
* much of this module.
|
1767
1772
|
*/
|
1768
1773
|
|
1774
|
+
const openDelims = "([{⌊⌈⟨⟮⎰⟦⦃";
|
1775
|
+
const closeDelims = ")]}⌋⌉⟩⟯⎱⟦⦄";
|
1776
|
+
|
1769
1777
|
function setLineBreaks(expression, wrapMode, isDisplayMode) {
|
1770
1778
|
const mtrs = [];
|
1771
1779
|
let mrows = [];
|
1772
1780
|
let block = [];
|
1773
1781
|
let numTopLevelEquals = 0;
|
1774
|
-
let canBeBIN = false; // The first node cannot be an infix binary operator.
|
1775
1782
|
let i = 0;
|
1783
|
+
let level = 0;
|
1776
1784
|
while (i < expression.length) {
|
1777
1785
|
while (expression[i] instanceof DocumentFragment) {
|
1778
1786
|
expression.splice(i, 1, ...expression[i].children); // Expand the fragment.
|
@@ -1795,7 +1803,12 @@ function setLineBreaks(expression, wrapMode, isDisplayMode) {
|
|
1795
1803
|
}
|
1796
1804
|
block.push(node);
|
1797
1805
|
if (node.type && node.type === "mo" && node.children.length === 1) {
|
1798
|
-
|
1806
|
+
const ch = node.children[0].text;
|
1807
|
+
if (openDelims.indexOf(ch) > -1) {
|
1808
|
+
level += 1;
|
1809
|
+
} else if (closeDelims.indexOf(ch) > -1) {
|
1810
|
+
level -= 1;
|
1811
|
+
} else if (level === 0 && wrapMode === "=" && ch === "=") {
|
1799
1812
|
numTopLevelEquals += 1;
|
1800
1813
|
if (numTopLevelEquals > 1) {
|
1801
1814
|
block.pop();
|
@@ -1804,59 +1817,48 @@ function setLineBreaks(expression, wrapMode, isDisplayMode) {
|
|
1804
1817
|
mrows.push(element);
|
1805
1818
|
block = [node];
|
1806
1819
|
}
|
1807
|
-
} else if (wrapMode === "tex") {
|
1808
|
-
//
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
1814
|
-
|
1815
|
-
|
1816
|
-
|
1817
|
-
|
1818
|
-
|
1819
|
-
|
1820
|
-
|
1821
|
-
|
1822
|
-
|
1823
|
-
|
1824
|
-
|
1820
|
+
} else if (level === 0 && wrapMode === "tex") {
|
1821
|
+
// Check if the following node is a \nobreak text node, e.g. "~""
|
1822
|
+
const next = i < expression.length - 1 ? expression[i + 1] : null;
|
1823
|
+
let glueIsFreeOfNobreak = true;
|
1824
|
+
if (
|
1825
|
+
!(
|
1826
|
+
next &&
|
1827
|
+
next.type === "mtext" &&
|
1828
|
+
next.attributes.linebreak &&
|
1829
|
+
next.attributes.linebreak === "nobreak"
|
1830
|
+
)
|
1831
|
+
) {
|
1832
|
+
// We may need to start a new block.
|
1833
|
+
// First, put any post-operator glue on same line as operator.
|
1834
|
+
for (let j = i + 1; j < expression.length; j++) {
|
1835
|
+
const nd = expression[j];
|
1836
|
+
if (
|
1837
|
+
nd.type &&
|
1838
|
+
nd.type === "mspace" &&
|
1839
|
+
!(nd.attributes.linebreak && nd.attributes.linebreak === "newline")
|
1840
|
+
) {
|
1841
|
+
block.push(nd);
|
1842
|
+
i += 1;
|
1825
1843
|
if (
|
1826
|
-
nd.
|
1827
|
-
nd.
|
1828
|
-
|
1844
|
+
nd.attributes &&
|
1845
|
+
nd.attributes.linebreak &&
|
1846
|
+
nd.attributes.linebreak === "nobreak"
|
1829
1847
|
) {
|
1830
|
-
|
1831
|
-
i += 1;
|
1832
|
-
if (
|
1833
|
-
nd.attributes &&
|
1834
|
-
nd.attributes.linebreak &&
|
1835
|
-
nd.attributes.linebreak === "nobreak"
|
1836
|
-
) {
|
1837
|
-
glueIsFreeOfNobreak = false;
|
1838
|
-
}
|
1839
|
-
} else {
|
1840
|
-
break;
|
1848
|
+
glueIsFreeOfNobreak = false;
|
1841
1849
|
}
|
1850
|
+
} else {
|
1851
|
+
break;
|
1842
1852
|
}
|
1843
1853
|
}
|
1844
|
-
if (glueIsFreeOfNobreak) {
|
1845
|
-
// Start a new block. (Insert a soft linebreak.)
|
1846
|
-
const element = new mathMLTree.MathNode("mrow", block);
|
1847
|
-
mrows.push(element);
|
1848
|
-
block = [];
|
1849
|
-
}
|
1850
|
-
canBeBIN = false;
|
1851
1854
|
}
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1855
|
-
|
1856
|
-
|
1855
|
+
if (glueIsFreeOfNobreak) {
|
1856
|
+
// Start a new block. (Insert a soft linebreak.)
|
1857
|
+
const element = new mathMLTree.MathNode("mrow", block);
|
1858
|
+
mrows.push(element);
|
1859
|
+
block = [];
|
1860
|
+
}
|
1857
1861
|
}
|
1858
|
-
} else {
|
1859
|
-
canBeBIN = true;
|
1860
1862
|
}
|
1861
1863
|
i += 1;
|
1862
1864
|
}
|
@@ -2133,9 +2135,10 @@ function buildMathML(tree, texExpression, style, settings) {
|
|
2133
2135
|
}
|
2134
2136
|
if (settings.displayMode) {
|
2135
2137
|
math.setAttribute("display", "block");
|
2136
|
-
math.style.display = math
|
2137
|
-
|
2138
|
-
|
2138
|
+
math.style.display = "block math"; // necessary in Chromium.
|
2139
|
+
// Firefox and Safari do not recognize display: "block math".
|
2140
|
+
// Set a class so that the CSS file can set display: block.
|
2141
|
+
math.classes = ["tml-display"];
|
2139
2142
|
}
|
2140
2143
|
return math;
|
2141
2144
|
}
|
@@ -3664,10 +3667,9 @@ defineFunction({
|
|
3664
3667
|
// so we have to explicitly set stretchy to true.
|
3665
3668
|
node.setAttribute("stretchy", "true");
|
3666
3669
|
}
|
3667
|
-
|
3668
3670
|
node.setAttribute("symmetric", "true"); // Needed for tall arrows in Firefox.
|
3669
3671
|
node.setAttribute("minsize", sizeToMaxHeight[group.size] + "em");
|
3670
|
-
|
3672
|
+
node.setAttribute("maxsize", sizeToMaxHeight[group.size] + "em");
|
3671
3673
|
return node;
|
3672
3674
|
}
|
3673
3675
|
});
|
@@ -3802,34 +3804,42 @@ const padding$1 = _ => {
|
|
3802
3804
|
|
3803
3805
|
const mathmlBuilder$8 = (group, style) => {
|
3804
3806
|
let node;
|
3805
|
-
if (group.label.indexOf("colorbox") > -1) {
|
3806
|
-
//
|
3807
|
-
|
3807
|
+
if (group.label.indexOf("colorbox") > -1 || group.label === "\\boxed") {
|
3808
|
+
// MathML core does not support +width attribute in <mpadded>.
|
3809
|
+
// Firefox does not reliably add side padding.
|
3810
|
+
// Insert <mspace>
|
3811
|
+
node = new mathMLTree.MathNode("mrow", [
|
3808
3812
|
padding$1(),
|
3809
3813
|
buildGroup$1(group.body, style),
|
3810
3814
|
padding$1()
|
3811
3815
|
]);
|
3812
3816
|
} else {
|
3813
|
-
node = new mathMLTree.MathNode("
|
3817
|
+
node = new mathMLTree.MathNode("mrow", [buildGroup$1(group.body, style)]);
|
3814
3818
|
}
|
3815
3819
|
switch (group.label) {
|
3816
3820
|
case "\\overline":
|
3817
|
-
node.setAttribute("notation", "top");
|
3818
3821
|
node.style.padding = "0.1em 0 0 0";
|
3819
3822
|
node.style.borderTop = "0.065em solid";
|
3820
3823
|
break
|
3821
3824
|
case "\\underline":
|
3822
|
-
node.setAttribute("notation", "bottom");
|
3823
3825
|
node.style.padding = "0 0 0.1em 0";
|
3824
3826
|
node.style.borderBottom = "0.065em solid";
|
3825
3827
|
break
|
3826
3828
|
case "\\cancel":
|
3827
|
-
node.
|
3828
|
-
|
3829
|
+
node.style.background = `linear-gradient(to top left,
|
3830
|
+
rgba(0,0,0,0) 0%,
|
3831
|
+
rgba(0,0,0,0) calc(50% - 0.06em),
|
3832
|
+
rgba(0,0,0,1) 50%,
|
3833
|
+
rgba(0,0,0,0) calc(50% + 0.06em),
|
3834
|
+
rgba(0,0,0,0) 100%);`;
|
3829
3835
|
break
|
3830
3836
|
case "\\bcancel":
|
3831
|
-
node.
|
3832
|
-
|
3837
|
+
node.style.background = `linear-gradient(to top right,
|
3838
|
+
rgba(0,0,0,0) 0%,
|
3839
|
+
rgba(0,0,0,0) calc(50% - 0.06em),
|
3840
|
+
rgba(0,0,0,1) 50%,
|
3841
|
+
rgba(0,0,0,0) calc(50% + 0.06em),
|
3842
|
+
rgba(0,0,0,0) 100%);`;
|
3833
3843
|
break
|
3834
3844
|
/*
|
3835
3845
|
case "\\longdiv":
|
@@ -3839,18 +3849,21 @@ const mathmlBuilder$8 = (group, style) => {
|
|
3839
3849
|
node.setAttribute("notation", "phasorangle");
|
3840
3850
|
break */
|
3841
3851
|
case "\\angl":
|
3842
|
-
node.setAttribute("notation", "actuarial");
|
3843
3852
|
node.style.padding = "0.03889em 0.03889em 0 0.03889em";
|
3844
3853
|
node.style.borderTop = "0.049em solid";
|
3845
3854
|
node.style.borderRight = "0.049em solid";
|
3846
3855
|
node.style.marginRight = "0.03889em";
|
3847
3856
|
break
|
3848
3857
|
case "\\sout":
|
3849
|
-
node.setAttribute("notation", "horizontalstrike");
|
3850
3858
|
node.style["text-decoration"] = "line-through 0.08em solid";
|
3851
3859
|
break
|
3860
|
+
case "\\boxed":
|
3861
|
+
// \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} from amsmath.sty
|
3862
|
+
node.style = { padding: "3pt 0 3pt 0", border: "1px solid" };
|
3863
|
+
node.setAttribute("scriptlevel", "0");
|
3864
|
+
node.setAttribute("displaystyle", "true");
|
3865
|
+
break
|
3852
3866
|
case "\\fbox":
|
3853
|
-
node.setAttribute("notation", "box");
|
3854
3867
|
node.style = { padding: "3pt", border: "1px solid" };
|
3855
3868
|
break
|
3856
3869
|
case "\\fcolorbox":
|
@@ -3870,8 +3883,18 @@ const mathmlBuilder$8 = (group, style) => {
|
|
3870
3883
|
break
|
3871
3884
|
}
|
3872
3885
|
case "\\xcancel":
|
3873
|
-
node.
|
3874
|
-
|
3886
|
+
node.style.background = `linear-gradient(to top left,
|
3887
|
+
rgba(0,0,0,0) 0%,
|
3888
|
+
rgba(0,0,0,0) calc(50% - 0.06em),
|
3889
|
+
rgba(0,0,0,1) 50%,
|
3890
|
+
rgba(0,0,0,0) calc(50% + 0.06em),
|
3891
|
+
rgba(0,0,0,0) 100%),
|
3892
|
+
linear-gradient(to top right,
|
3893
|
+
rgba(0,0,0,0) 0%,
|
3894
|
+
rgba(0,0,0,0) calc(50% - 0.06em),
|
3895
|
+
rgba(0,0,0,1) 50%,
|
3896
|
+
rgba(0,0,0,0) calc(50% + 0.06em),
|
3897
|
+
rgba(0,0,0,0) 100%);`;
|
3875
3898
|
break
|
3876
3899
|
}
|
3877
3900
|
if (group.backgroundColor) {
|
@@ -3965,7 +3988,7 @@ defineFunction({
|
|
3965
3988
|
|
3966
3989
|
defineFunction({
|
3967
3990
|
type: "enclose",
|
3968
|
-
names: ["\\angl", "\\cancel", "\\bcancel", "\\xcancel", "\\sout", "\\overline"],
|
3991
|
+
names: ["\\angl", "\\cancel", "\\bcancel", "\\xcancel", "\\sout", "\\overline", "\\boxed"],
|
3969
3992
|
// , "\\phase", "\\longdiv"
|
3970
3993
|
props: {
|
3971
3994
|
numArgs: 1
|
@@ -4302,24 +4325,94 @@ const mathmlBuilder$7 = function(group, style) {
|
|
4302
4325
|
// Write horizontal rules
|
4303
4326
|
if (i === 0 && hlines[0].length > 0) {
|
4304
4327
|
if (hlines[0].length === 2) {
|
4305
|
-
mtr.
|
4328
|
+
mtr.children.forEach(cell => { cell.style.borderTop = "0.15em double"; });
|
4306
4329
|
} else {
|
4307
|
-
mtr.
|
4330
|
+
mtr.children.forEach(cell => {
|
4331
|
+
cell.style.borderTop = hlines[0][0] ? "0.06em dashed" : "0.06em solid";
|
4332
|
+
});
|
4308
4333
|
}
|
4309
4334
|
}
|
4310
4335
|
if (hlines[i + 1].length > 0) {
|
4311
4336
|
if (hlines[i + 1].length === 2) {
|
4312
|
-
mtr.
|
4337
|
+
mtr.children.forEach(cell => { cell.style.borderBottom = "0.15em double"; });
|
4313
4338
|
} else {
|
4314
|
-
mtr.
|
4339
|
+
mtr.children.forEach(cell => {
|
4340
|
+
cell.style.borderBottom = hlines[i + 1][0] ? "0.06em dashed" : "0.06em solid";
|
4341
|
+
});
|
4315
4342
|
}
|
4316
4343
|
}
|
4317
4344
|
tbl.push(mtr);
|
4318
4345
|
}
|
4319
|
-
|
4346
|
+
|
4320
4347
|
if (group.envClasses.length > 0) {
|
4321
|
-
|
4348
|
+
const pad = group.envClasses.includes("jot")
|
4349
|
+
? "0.7" // 0.5ex + 0.09em top & bot padding
|
4350
|
+
: group.envClasses.includes("small")
|
4351
|
+
? "0.35"
|
4352
|
+
: "0.5"; // 0.5ex default top & bot padding
|
4353
|
+
const sidePadding = group.envClasses.includes("abut")
|
4354
|
+
? "0"
|
4355
|
+
: group.envClasses.includes("cases")
|
4356
|
+
? "0"
|
4357
|
+
: group.envClasses.includes("small")
|
4358
|
+
? "0.1389"
|
4359
|
+
: group.envClasses.includes("cd")
|
4360
|
+
? "0.25"
|
4361
|
+
: "0.4"; // default side padding
|
4362
|
+
|
4363
|
+
const numCols = tbl.length === 0 ? 0 : tbl[0].children.length;
|
4364
|
+
|
4365
|
+
const sidePad = (j, hand) => {
|
4366
|
+
if (j === 0 && hand === 0) { return "0" }
|
4367
|
+
if (j === numCols - 1 && hand === 1) { return "0" }
|
4368
|
+
if (group.envClasses[0] !== "align") { return sidePadding }
|
4369
|
+
if (hand === 1) { return "0" }
|
4370
|
+
if (group.addEqnNum) {
|
4371
|
+
return (j % 2) ? "1" : "0"
|
4372
|
+
} else {
|
4373
|
+
return (j % 2) ? "0" : "1"
|
4374
|
+
}
|
4375
|
+
};
|
4376
|
+
|
4377
|
+
// Padding
|
4378
|
+
for (let i = 0; i < tbl.length; i++) {
|
4379
|
+
for (let j = 0; j < tbl[i].children.length; j++) {
|
4380
|
+
tbl[i].children[j].style.padding = `${pad}ex ${sidePad(j, 1)}em ${pad}ex ${sidePad(j, 0)}em`;
|
4381
|
+
}
|
4382
|
+
}
|
4383
|
+
|
4384
|
+
// Justification
|
4385
|
+
const align = group.envClasses.includes("align") || group.envClasses.includes("alignat");
|
4386
|
+
for (let i = 0; i < tbl.length; i++) {
|
4387
|
+
const row = tbl[i];
|
4388
|
+
if (align) {
|
4389
|
+
for (let j = 0; j < row.children.length; j++) {
|
4390
|
+
// Chromium does not recognize text-align: left. Use -webkit-
|
4391
|
+
// TODO: Remove -webkit- when Chromium no longer needs it.
|
4392
|
+
row.children[j].style.textAlign = "-webkit-" + (j % 2 ? "left" : "right");
|
4393
|
+
}
|
4394
|
+
}
|
4395
|
+
if (row.children.length > 1 && group.envClasses.includes("cases")) {
|
4396
|
+
row.children[1].style.padding = row.children[1].style.padding.replace(/0em$/, "1em");
|
4397
|
+
}
|
4398
|
+
|
4399
|
+
if (group.envClasses.includes("cases") || group.envClasses.includes("subarray")) {
|
4400
|
+
for (const cell of row.children) {
|
4401
|
+
cell.style.textAlign = "-webkit-" + "left";
|
4402
|
+
}
|
4403
|
+
}
|
4404
|
+
}
|
4405
|
+
} else {
|
4406
|
+
// Set zero padding on side of the matrix
|
4407
|
+
for (let i = 0; i < tbl.length; i++) {
|
4408
|
+
tbl[i].children[0].style.paddingLeft = "0em";
|
4409
|
+
if (tbl[i].children.length === tbl[0].children.length) {
|
4410
|
+
tbl[i].children[tbl[i].children.length - 1].style.paddingRight = "0em";
|
4411
|
+
}
|
4412
|
+
}
|
4322
4413
|
}
|
4414
|
+
|
4415
|
+
let table = new mathMLTree.MathNode("mtable", tbl);
|
4323
4416
|
if (group.scriptLevel === "display") { table.setAttribute("displaystyle", "true"); }
|
4324
4417
|
|
4325
4418
|
if (group.addEqnNum || group.envClasses.includes("multline")) {
|
@@ -4399,6 +4492,8 @@ const mathmlBuilder$7 = function(group, style) {
|
|
4399
4492
|
align = "left " + (align.length > 0 ? align : "center ") + "right ";
|
4400
4493
|
}
|
4401
4494
|
if (align) {
|
4495
|
+
// Firefox reads this attribute, not the -webkit-left|right written above.
|
4496
|
+
// TODO: When Chrome no longer needs "-webkit-", use CSS and delete the next line.
|
4402
4497
|
table.setAttribute("columnalign", align.trim());
|
4403
4498
|
}
|
4404
4499
|
|
@@ -4423,7 +4518,7 @@ const alignedHandler = function(context, args) {
|
|
4423
4518
|
cols,
|
4424
4519
|
addEqnNum: context.envName === "align" || context.envName === "alignat",
|
4425
4520
|
emptySingleRow: true,
|
4426
|
-
envClasses: ["
|
4521
|
+
envClasses: ["abut", "jot"], // set row spacing & provisional column spacing
|
4427
4522
|
maxNumCols: context.envName === "split" ? 2 : undefined,
|
4428
4523
|
leqno: context.parser.settings.leqno
|
4429
4524
|
},
|
@@ -4441,18 +4536,22 @@ const alignedHandler = function(context, args) {
|
|
4441
4536
|
// binary. This behavior is implemented in amsmath's \start@aligned.
|
4442
4537
|
let numMaths;
|
4443
4538
|
let numCols = 0;
|
4444
|
-
|
4539
|
+
const isAlignedAt = context.envName.indexOf("at") > -1;
|
4540
|
+
if (args[0] && isAlignedAt) {
|
4541
|
+
// alignat environment takes an argument w/ number of columns
|
4445
4542
|
let arg0 = "";
|
4446
4543
|
for (let i = 0; i < args[0].body.length; i++) {
|
4447
4544
|
const textord = assertNodeType(args[0].body[i], "textord");
|
4448
4545
|
arg0 += textord.text;
|
4449
4546
|
}
|
4547
|
+
if (isNaN(arg0)) {
|
4548
|
+
throw new ParseError("The alignat enviroment requires a numeric first argument.")
|
4549
|
+
}
|
4450
4550
|
numMaths = Number(arg0);
|
4451
4551
|
numCols = numMaths * 2;
|
4452
4552
|
}
|
4453
|
-
const isAligned = !numCols;
|
4454
4553
|
res.body.forEach(function(row) {
|
4455
|
-
if (
|
4554
|
+
if (isAlignedAt) {
|
4456
4555
|
// Case 1
|
4457
4556
|
const curMaths = row.length / 2;
|
4458
4557
|
if (numMaths < curMaths) {
|
@@ -4480,14 +4579,10 @@ const alignedHandler = function(context, args) {
|
|
4480
4579
|
align: align
|
4481
4580
|
};
|
4482
4581
|
}
|
4483
|
-
if (context.envName === "split") ; else if (
|
4484
|
-
res.envClasses.push("
|
4485
|
-
} else if (isAligned) {
|
4486
|
-
res.envClasses[1] = context.envName === "align*"
|
4487
|
-
? "align-star"
|
4488
|
-
: "align"; // Sets column spacing & justification
|
4582
|
+
if (context.envName === "split") ; else if (isAlignedAt) {
|
4583
|
+
res.envClasses.push("alignat"); // Sets justification
|
4489
4584
|
} else {
|
4490
|
-
res.envClasses
|
4585
|
+
res.envClasses[0] = "align"; // Sets column spacing & justification
|
4491
4586
|
}
|
4492
4587
|
return res;
|
4493
4588
|
};
|
@@ -4737,7 +4832,7 @@ defineEnvironment({
|
|
4737
4832
|
}
|
4738
4833
|
const res = {
|
4739
4834
|
cols: [],
|
4740
|
-
envClasses: ["
|
4835
|
+
envClasses: ["abut", "jot"],
|
4741
4836
|
addEqnNum: context.envName === "gather",
|
4742
4837
|
emptySingleRow: true,
|
4743
4838
|
leqno: context.parser.settings.leqno
|
@@ -6831,8 +6926,6 @@ defineFunction({
|
|
6831
6926
|
}
|
6832
6927
|
});
|
6833
6928
|
|
6834
|
-
const sign = num => num >= 0 ? "+" : "-";
|
6835
|
-
|
6836
6929
|
// \raise, \lower, and \raisebox
|
6837
6930
|
|
6838
6931
|
const mathmlBuilder = (group, style) => {
|
@@ -6840,11 +6933,13 @@ const mathmlBuilder = (group, style) => {
|
|
6840
6933
|
const node = new mathMLTree.MathNode("mpadded", [buildGroup$1(group.body, newStyle)]);
|
6841
6934
|
const dy = calculateSize(group.dy, style);
|
6842
6935
|
node.setAttribute("voffset", dy.number + dy.unit);
|
6843
|
-
|
6844
|
-
//
|
6845
|
-
|
6846
|
-
|
6847
|
-
|
6936
|
+
// Add padding, which acts to increase height in Chromium.
|
6937
|
+
// TODO: Figure out some way to change height in Firefox w/o breaking Chromium.
|
6938
|
+
if (dy.number > 0) {
|
6939
|
+
node.style.padding = dy.number + dy.unit + " 0 0 0";
|
6940
|
+
} else {
|
6941
|
+
node.style.padding = "0 0 " + Math.abs(dy.number) + dy.unit + " 0";
|
6942
|
+
}
|
6848
6943
|
return node
|
6849
6944
|
};
|
6850
6945
|
|
@@ -8473,9 +8568,6 @@ defineMacro("\u22ee", "\\vdots");
|
|
8473
8568
|
//\newcommand{\substack}[1]{\subarray{c}#1\endsubarray}
|
8474
8569
|
defineMacro("\\substack", "\\begin{subarray}{c}#1\\end{subarray}");
|
8475
8570
|
|
8476
|
-
// \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}}
|
8477
|
-
defineMacro("\\boxed", "\\fbox{$\\displaystyle{#1}$}");
|
8478
|
-
|
8479
8571
|
// \def\iff{\DOTSB\;\Longleftrightarrow\;}
|
8480
8572
|
// \def\implies{\DOTSB\;\Longrightarrow\;}
|
8481
8573
|
// \def\impliedby{\DOTSB\;\Longleftarrow\;}
|
@@ -8724,7 +8816,7 @@ defineMacro(
|
|
8724
8816
|
defineMacro(
|
8725
8817
|
"\\Temml",
|
8726
8818
|
// eslint-disable-next-line max-len
|
8727
|
-
"\\textrm{T}\\kern-0.2em\\lower{0.2em}\\textrm{E}\\kern-0.08em{\\textrm{M}\\kern-0.08em\\raise{0.2em}\\textrm{M}\\kern-0.08em\\textrm{L}}"
|
8819
|
+
"\\textrm{T}\\kern-0.2em\\lower{0.2em}{\\textrm{E}}\\kern-0.08em{\\textrm{M}\\kern-0.08em\\raise{0.2em}\\textrm{M}\\kern-0.08em\\textrm{L}}"
|
8728
8820
|
);
|
8729
8821
|
|
8730
8822
|
// \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace}
|
@@ -12904,7 +12996,7 @@ class Style {
|
|
12904
12996
|
* https://mit-license.org/
|
12905
12997
|
*/
|
12906
12998
|
|
12907
|
-
const version = "0.10.
|
12999
|
+
const version = "0.10.15";
|
12908
13000
|
|
12909
13001
|
function postProcess(block) {
|
12910
13002
|
const labelMap = {};
|
@@ -12955,6 +13047,7 @@ function postProcess(block) {
|
|
12955
13047
|
/* eslint no-console:0 */
|
12956
13048
|
|
12957
13049
|
/**
|
13050
|
+
* @type {import('./temml').render}
|
12958
13051
|
* Parse and build an expression, and place that expression in the DOM node
|
12959
13052
|
* given.
|
12960
13053
|
*/
|
@@ -12992,6 +13085,7 @@ if (typeof document !== "undefined") {
|
|
12992
13085
|
}
|
12993
13086
|
|
12994
13087
|
/**
|
13088
|
+
* @type {import('./temml').renderToString}
|
12995
13089
|
* Parse and build an expression, and return the markup for that.
|
12996
13090
|
*/
|
12997
13091
|
const renderToString = function(expression, options) {
|
@@ -13000,6 +13094,7 @@ const renderToString = function(expression, options) {
|
|
13000
13094
|
};
|
13001
13095
|
|
13002
13096
|
/**
|
13097
|
+
* @type {import('./temml').generateParseTree}
|
13003
13098
|
* Parse an expression and return the parse tree.
|
13004
13099
|
*/
|
13005
13100
|
const generateParseTree = function(expression, options) {
|
@@ -13008,6 +13103,7 @@ const generateParseTree = function(expression, options) {
|
|
13008
13103
|
};
|
13009
13104
|
|
13010
13105
|
/**
|
13106
|
+
* @type {import('./temml').definePreamble}
|
13011
13107
|
* Take an expression which contains a preamble.
|
13012
13108
|
* Parse it and return the macros.
|
13013
13109
|
*/
|
@@ -13040,6 +13136,7 @@ const renderError = function(error, expression, options) {
|
|
13040
13136
|
};
|
13041
13137
|
|
13042
13138
|
/**
|
13139
|
+
* @type {import('./temml').renderToMathMLTree}
|
13043
13140
|
* Generates and returns the Temml build tree. This is used for advanced
|
13044
13141
|
* use cases (like rendering to custom output).
|
13045
13142
|
*/
|
@@ -13057,6 +13154,7 @@ const renderToMathMLTree = function(expression, options) {
|
|
13057
13154
|
}
|
13058
13155
|
};
|
13059
13156
|
|
13157
|
+
/** @type {import('./temml').default} */
|
13060
13158
|
var temml = {
|
13061
13159
|
/**
|
13062
13160
|
* Current Temml version
|
package/dist/temml.d.ts
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
export interface Options {
|
2
|
+
displayMode?: boolean;
|
3
|
+
annotate?: boolean;
|
4
|
+
leqno?: boolean;
|
5
|
+
throwOnError?: boolean;
|
6
|
+
errorColor?: string;
|
7
|
+
macros?: Record<string, string>;
|
8
|
+
wrap?: "tex" | "=" | "none";
|
9
|
+
xml?: boolean;
|
10
|
+
colorIsTextColor?: boolean;
|
11
|
+
strict?: boolean;
|
12
|
+
trust?: boolean | ((context: any) => boolean);
|
13
|
+
maxSize?: [number, number];
|
14
|
+
maxExpand?: number;
|
15
|
+
}
|
16
|
+
|
17
|
+
export function render(
|
18
|
+
expression: string,
|
19
|
+
baseNode: HTMLElement,
|
20
|
+
options?: Options,
|
21
|
+
): void;
|
22
|
+
|
23
|
+
export function renderToString(expression: string, options?: Options): string;
|
24
|
+
|
25
|
+
export function generateParseTree(expression: string, options?: Options): any;
|
26
|
+
|
27
|
+
export function definePreamble(expression: string, options?: Options): any;
|
28
|
+
|
29
|
+
export function renderToMathMLTree(expression: string, options?: Options): any;
|
30
|
+
|
31
|
+
declare function postProcess(block: any): void;
|
32
|
+
declare function defineMacro(name: string, body: any): void;
|
33
|
+
declare function defineSymbol(
|
34
|
+
mode: string,
|
35
|
+
group: string,
|
36
|
+
replace: string,
|
37
|
+
name: string,
|
38
|
+
acceptUnicodeChar: boolean,
|
39
|
+
): void;
|
40
|
+
declare class ParseError {
|
41
|
+
constructor(
|
42
|
+
message: string, // The error message
|
43
|
+
token: any, // An object providing position information
|
44
|
+
) {}
|
45
|
+
}
|
46
|
+
|
47
|
+
declare const Temml: {
|
48
|
+
version: string;
|
49
|
+
render: typeof render;
|
50
|
+
renderToString: typeof renderToString;
|
51
|
+
postProcess: typeof postProcess;
|
52
|
+
ParseError: typeof ParseError;
|
53
|
+
definePreamble: typeof definePreamble;
|
54
|
+
__parse: typeof generateParseTree;
|
55
|
+
__renderToMathMLTree: typeof renderToMathMLTree;
|
56
|
+
__defineSymbol: typeof defineSymbol;
|
57
|
+
__defineMacro: typeof defineMacro;
|
58
|
+
};
|
59
|
+
|
60
|
+
export default Temml;
|