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/dist/temml.mjs CHANGED
@@ -971,6 +971,10 @@ defineSymbol(math, mathord, "\u21af", "\\lightning", true);
971
971
  defineSymbol(math, mathord, "\u220E", "\\QED", true);
972
972
  defineSymbol(math, mathord, "\u2030", "\\permil", true);
973
973
  defineSymbol(text, textord, "\u2030", "\\permil");
974
+ defineSymbol(math, mathord, "\u2609", "\\astrosun", true);
975
+ defineSymbol(math, mathord, "\u263c", "\\sun", true);
976
+ defineSymbol(math, mathord, "\u263e", "\\leftmoon", true);
977
+ defineSymbol(math, mathord, "\u263d", "\\rightmoon", true);
974
978
 
975
979
  // AMS Negated Binary Relations
976
980
  defineSymbol(math, rel, "\u226e", "\\nless", true);
@@ -1115,6 +1119,7 @@ defineSymbol(math, rel, "\u2ab7", "\\precapprox", true);
1115
1119
  defineSymbol(math, rel, "\u22b2", "\\vartriangleleft");
1116
1120
  defineSymbol(math, rel, "\u22b4", "\\trianglelefteq");
1117
1121
  defineSymbol(math, rel, "\u22a8", "\\vDash", true);
1122
+ defineSymbol(math, rel, "\u22ab", "\\VDash", true);
1118
1123
  defineSymbol(math, rel, "\u22aa", "\\Vvdash", true);
1119
1124
  defineSymbol(math, rel, "\u2323", "\\smallsmile");
1120
1125
  defineSymbol(math, rel, "\u2322", "\\smallfrown");
@@ -1764,13 +1769,16 @@ for (let i = 0; i < 10; i++) {
1764
1769
  * much of this module.
1765
1770
  */
1766
1771
 
1772
+ const openDelims = "([{⌊⌈⟨⟮⎰⟦⦃";
1773
+ const closeDelims = ")]}⌋⌉⟩⟯⎱⟦⦄";
1774
+
1767
1775
  function setLineBreaks(expression, wrapMode, isDisplayMode) {
1768
1776
  const mtrs = [];
1769
1777
  let mrows = [];
1770
1778
  let block = [];
1771
1779
  let numTopLevelEquals = 0;
1772
- let canBeBIN = false; // The first node cannot be an infix binary operator.
1773
1780
  let i = 0;
1781
+ let level = 0;
1774
1782
  while (i < expression.length) {
1775
1783
  while (expression[i] instanceof DocumentFragment) {
1776
1784
  expression.splice(i, 1, ...expression[i].children); // Expand the fragment.
@@ -1793,7 +1801,12 @@ function setLineBreaks(expression, wrapMode, isDisplayMode) {
1793
1801
  }
1794
1802
  block.push(node);
1795
1803
  if (node.type && node.type === "mo" && node.children.length === 1) {
1796
- if (wrapMode === "=" && node.children[0].text === "=") {
1804
+ const ch = node.children[0].text;
1805
+ if (openDelims.indexOf(ch) > -1) {
1806
+ level += 1;
1807
+ } else if (closeDelims.indexOf(ch) > -1) {
1808
+ level -= 1;
1809
+ } else if (level === 0 && wrapMode === "=" && ch === "=") {
1797
1810
  numTopLevelEquals += 1;
1798
1811
  if (numTopLevelEquals > 1) {
1799
1812
  block.pop();
@@ -1802,59 +1815,48 @@ function setLineBreaks(expression, wrapMode, isDisplayMode) {
1802
1815
  mrows.push(element);
1803
1816
  block = [node];
1804
1817
  }
1805
- } else if (wrapMode === "tex") {
1806
- // This may be a place for a soft line break.
1807
- if (canBeBIN && !node.attributes.form) {
1808
- // Check if the following node is a \nobreak text node, e.g. "~""
1809
- const next = i < expression.length - 1 ? expression[i + 1] : null;
1810
- let glueIsFreeOfNobreak = true;
1811
- if (
1812
- !(
1813
- next &&
1814
- next.type === "mtext" &&
1815
- next.attributes.linebreak &&
1816
- next.attributes.linebreak === "nobreak"
1817
- )
1818
- ) {
1819
- // We may need to start a new block.
1820
- // First, put any post-operator glue on same line as operator.
1821
- for (let j = i + 1; j < expression.length; j++) {
1822
- const nd = expression[j];
1818
+ } else if (level === 0 && wrapMode === "tex") {
1819
+ // Check if the following node is a \nobreak text node, e.g. "~""
1820
+ const next = i < expression.length - 1 ? expression[i + 1] : null;
1821
+ let glueIsFreeOfNobreak = true;
1822
+ if (
1823
+ !(
1824
+ next &&
1825
+ next.type === "mtext" &&
1826
+ next.attributes.linebreak &&
1827
+ next.attributes.linebreak === "nobreak"
1828
+ )
1829
+ ) {
1830
+ // We may need to start a new block.
1831
+ // First, put any post-operator glue on same line as operator.
1832
+ for (let j = i + 1; j < expression.length; j++) {
1833
+ const nd = expression[j];
1834
+ if (
1835
+ nd.type &&
1836
+ nd.type === "mspace" &&
1837
+ !(nd.attributes.linebreak && nd.attributes.linebreak === "newline")
1838
+ ) {
1839
+ block.push(nd);
1840
+ i += 1;
1823
1841
  if (
1824
- nd.type &&
1825
- nd.type === "mspace" &&
1826
- !(nd.attributes.linebreak && nd.attributes.linebreak === "newline")
1842
+ nd.attributes &&
1843
+ nd.attributes.linebreak &&
1844
+ nd.attributes.linebreak === "nobreak"
1827
1845
  ) {
1828
- block.push(nd);
1829
- i += 1;
1830
- if (
1831
- nd.attributes &&
1832
- nd.attributes.linebreak &&
1833
- nd.attributes.linebreak === "nobreak"
1834
- ) {
1835
- glueIsFreeOfNobreak = false;
1836
- }
1837
- } else {
1838
- break;
1846
+ glueIsFreeOfNobreak = false;
1839
1847
  }
1848
+ } else {
1849
+ break;
1840
1850
  }
1841
1851
  }
1842
- if (glueIsFreeOfNobreak) {
1843
- // Start a new block. (Insert a soft linebreak.)
1844
- const element = new mathMLTree.MathNode("mrow", block);
1845
- mrows.push(element);
1846
- block = [];
1847
- }
1848
- canBeBIN = false;
1849
1852
  }
1850
- const isOpenDelimiter = node.attributes.form && node.attributes.form === "prefix";
1851
- // Any operator that follows an open delimiter is unary.
1852
- canBeBIN = !(node.attributes.separator || isOpenDelimiter);
1853
- } else {
1854
- canBeBIN = true;
1853
+ if (glueIsFreeOfNobreak) {
1854
+ // Start a new block. (Insert a soft linebreak.)
1855
+ const element = new mathMLTree.MathNode("mrow", block);
1856
+ mrows.push(element);
1857
+ block = [];
1858
+ }
1855
1859
  }
1856
- } else {
1857
- canBeBIN = true;
1858
1860
  }
1859
1861
  i += 1;
1860
1862
  }
@@ -2131,9 +2133,10 @@ function buildMathML(tree, texExpression, style, settings) {
2131
2133
  }
2132
2134
  if (settings.displayMode) {
2133
2135
  math.setAttribute("display", "block");
2134
- math.style.display = math.children.length === 1 && math.children[0].type === "mtable"
2135
- ? "inline"
2136
- : "block math";
2136
+ math.style.display = "block math"; // necessary in Chromium.
2137
+ // Firefox and Safari do not recognize display: "block math".
2138
+ // Set a class so that the CSS file can set display: block.
2139
+ math.classes = ["tml-display"];
2137
2140
  }
2138
2141
  return math;
2139
2142
  }
@@ -3662,10 +3665,9 @@ defineFunction({
3662
3665
  // so we have to explicitly set stretchy to true.
3663
3666
  node.setAttribute("stretchy", "true");
3664
3667
  }
3665
-
3666
3668
  node.setAttribute("symmetric", "true"); // Needed for tall arrows in Firefox.
3667
3669
  node.setAttribute("minsize", sizeToMaxHeight[group.size] + "em");
3668
- // Don't set the maxsize attribute. It's broken in Chromium.
3670
+ node.setAttribute("maxsize", sizeToMaxHeight[group.size] + "em");
3669
3671
  return node;
3670
3672
  }
3671
3673
  });
@@ -3800,34 +3802,42 @@ const padding$1 = _ => {
3800
3802
 
3801
3803
  const mathmlBuilder$8 = (group, style) => {
3802
3804
  let node;
3803
- if (group.label.indexOf("colorbox") > -1) {
3804
- // Chrome mpadded +width attribute is broken. Insert <mspace>
3805
- node = new mathMLTree.MathNode("mpadded", [
3805
+ if (group.label.indexOf("colorbox") > -1 || group.label === "\\boxed") {
3806
+ // MathML core does not support +width attribute in <mpadded>.
3807
+ // Firefox does not reliably add side padding.
3808
+ // Insert <mspace>
3809
+ node = new mathMLTree.MathNode("mrow", [
3806
3810
  padding$1(),
3807
3811
  buildGroup$1(group.body, style),
3808
3812
  padding$1()
3809
3813
  ]);
3810
3814
  } else {
3811
- node = new mathMLTree.MathNode("menclose", [buildGroup$1(group.body, style)]);
3815
+ node = new mathMLTree.MathNode("mrow", [buildGroup$1(group.body, style)]);
3812
3816
  }
3813
3817
  switch (group.label) {
3814
3818
  case "\\overline":
3815
- node.setAttribute("notation", "top");
3816
3819
  node.style.padding = "0.1em 0 0 0";
3817
3820
  node.style.borderTop = "0.065em solid";
3818
3821
  break
3819
3822
  case "\\underline":
3820
- node.setAttribute("notation", "bottom");
3821
3823
  node.style.padding = "0 0 0.1em 0";
3822
3824
  node.style.borderBottom = "0.065em solid";
3823
3825
  break
3824
3826
  case "\\cancel":
3825
- node.setAttribute("notation", "updiagonalstrike");
3826
- node.classes.push("cancel");
3827
+ node.style.background = `linear-gradient(to top left,
3828
+ rgba(0,0,0,0) 0%,
3829
+ rgba(0,0,0,0) calc(50% - 0.06em),
3830
+ rgba(0,0,0,1) 50%,
3831
+ rgba(0,0,0,0) calc(50% + 0.06em),
3832
+ rgba(0,0,0,0) 100%);`;
3827
3833
  break
3828
3834
  case "\\bcancel":
3829
- node.setAttribute("notation", "downdiagonalstrike");
3830
- node.classes.push("bcancel");
3835
+ node.style.background = `linear-gradient(to top right,
3836
+ rgba(0,0,0,0) 0%,
3837
+ rgba(0,0,0,0) calc(50% - 0.06em),
3838
+ rgba(0,0,0,1) 50%,
3839
+ rgba(0,0,0,0) calc(50% + 0.06em),
3840
+ rgba(0,0,0,0) 100%);`;
3831
3841
  break
3832
3842
  /*
3833
3843
  case "\\longdiv":
@@ -3837,18 +3847,21 @@ const mathmlBuilder$8 = (group, style) => {
3837
3847
  node.setAttribute("notation", "phasorangle");
3838
3848
  break */
3839
3849
  case "\\angl":
3840
- node.setAttribute("notation", "actuarial");
3841
3850
  node.style.padding = "0.03889em 0.03889em 0 0.03889em";
3842
3851
  node.style.borderTop = "0.049em solid";
3843
3852
  node.style.borderRight = "0.049em solid";
3844
3853
  node.style.marginRight = "0.03889em";
3845
3854
  break
3846
3855
  case "\\sout":
3847
- node.setAttribute("notation", "horizontalstrike");
3848
3856
  node.style["text-decoration"] = "line-through 0.08em solid";
3849
3857
  break
3858
+ case "\\boxed":
3859
+ // \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} from amsmath.sty
3860
+ node.style = { padding: "3pt 0 3pt 0", border: "1px solid" };
3861
+ node.setAttribute("scriptlevel", "0");
3862
+ node.setAttribute("displaystyle", "true");
3863
+ break
3850
3864
  case "\\fbox":
3851
- node.setAttribute("notation", "box");
3852
3865
  node.style = { padding: "3pt", border: "1px solid" };
3853
3866
  break
3854
3867
  case "\\fcolorbox":
@@ -3868,8 +3881,18 @@ const mathmlBuilder$8 = (group, style) => {
3868
3881
  break
3869
3882
  }
3870
3883
  case "\\xcancel":
3871
- node.setAttribute("notation", "updiagonalstrike downdiagonalstrike");
3872
- node.classes.push("xcancel");
3884
+ node.style.background = `linear-gradient(to top left,
3885
+ rgba(0,0,0,0) 0%,
3886
+ rgba(0,0,0,0) calc(50% - 0.06em),
3887
+ rgba(0,0,0,1) 50%,
3888
+ rgba(0,0,0,0) calc(50% + 0.06em),
3889
+ rgba(0,0,0,0) 100%),
3890
+ linear-gradient(to top right,
3891
+ rgba(0,0,0,0) 0%,
3892
+ rgba(0,0,0,0) calc(50% - 0.06em),
3893
+ rgba(0,0,0,1) 50%,
3894
+ rgba(0,0,0,0) calc(50% + 0.06em),
3895
+ rgba(0,0,0,0) 100%);`;
3873
3896
  break
3874
3897
  }
3875
3898
  if (group.backgroundColor) {
@@ -3963,7 +3986,7 @@ defineFunction({
3963
3986
 
3964
3987
  defineFunction({
3965
3988
  type: "enclose",
3966
- names: ["\\angl", "\\cancel", "\\bcancel", "\\xcancel", "\\sout", "\\overline"],
3989
+ names: ["\\angl", "\\cancel", "\\bcancel", "\\xcancel", "\\sout", "\\overline", "\\boxed"],
3967
3990
  // , "\\phase", "\\longdiv"
3968
3991
  props: {
3969
3992
  numArgs: 1
@@ -4300,24 +4323,94 @@ const mathmlBuilder$7 = function(group, style) {
4300
4323
  // Write horizontal rules
4301
4324
  if (i === 0 && hlines[0].length > 0) {
4302
4325
  if (hlines[0].length === 2) {
4303
- mtr.classes.push("tml-top-double");
4326
+ mtr.children.forEach(cell => { cell.style.borderTop = "0.15em double"; });
4304
4327
  } else {
4305
- mtr.classes.push(hlines[0][0] ? "tml-top-dashed" : "tml-top-solid");
4328
+ mtr.children.forEach(cell => {
4329
+ cell.style.borderTop = hlines[0][0] ? "0.06em dashed" : "0.06em solid";
4330
+ });
4306
4331
  }
4307
4332
  }
4308
4333
  if (hlines[i + 1].length > 0) {
4309
4334
  if (hlines[i + 1].length === 2) {
4310
- mtr.classes.push("tml-hline-double");
4335
+ mtr.children.forEach(cell => { cell.style.borderBottom = "0.15em double"; });
4311
4336
  } else {
4312
- mtr.classes.push(hlines[i + 1][0] ? "tml-hline-dashed" : "tml-hline-solid");
4337
+ mtr.children.forEach(cell => {
4338
+ cell.style.borderBottom = hlines[i + 1][0] ? "0.06em dashed" : "0.06em solid";
4339
+ });
4313
4340
  }
4314
4341
  }
4315
4342
  tbl.push(mtr);
4316
4343
  }
4317
- let table = new mathMLTree.MathNode("mtable", tbl);
4344
+
4318
4345
  if (group.envClasses.length > 0) {
4319
- table.classes = group.envClasses.map(e => "tml-" + e);
4346
+ const pad = group.envClasses.includes("jot")
4347
+ ? "0.7" // 0.5ex + 0.09em top & bot padding
4348
+ : group.envClasses.includes("small")
4349
+ ? "0.35"
4350
+ : "0.5"; // 0.5ex default top & bot padding
4351
+ const sidePadding = group.envClasses.includes("abut")
4352
+ ? "0"
4353
+ : group.envClasses.includes("cases")
4354
+ ? "0"
4355
+ : group.envClasses.includes("small")
4356
+ ? "0.1389"
4357
+ : group.envClasses.includes("cd")
4358
+ ? "0.25"
4359
+ : "0.4"; // default side padding
4360
+
4361
+ const numCols = tbl.length === 0 ? 0 : tbl[0].children.length;
4362
+
4363
+ const sidePad = (j, hand) => {
4364
+ if (j === 0 && hand === 0) { return "0" }
4365
+ if (j === numCols - 1 && hand === 1) { return "0" }
4366
+ if (group.envClasses[0] !== "align") { return sidePadding }
4367
+ if (hand === 1) { return "0" }
4368
+ if (group.addEqnNum) {
4369
+ return (j % 2) ? "1" : "0"
4370
+ } else {
4371
+ return (j % 2) ? "0" : "1"
4372
+ }
4373
+ };
4374
+
4375
+ // Padding
4376
+ for (let i = 0; i < tbl.length; i++) {
4377
+ for (let j = 0; j < tbl[i].children.length; j++) {
4378
+ tbl[i].children[j].style.padding = `${pad}ex ${sidePad(j, 1)}em ${pad}ex ${sidePad(j, 0)}em`;
4379
+ }
4380
+ }
4381
+
4382
+ // Justification
4383
+ const align = group.envClasses.includes("align") || group.envClasses.includes("alignat");
4384
+ for (let i = 0; i < tbl.length; i++) {
4385
+ const row = tbl[i];
4386
+ if (align) {
4387
+ for (let j = 0; j < row.children.length; j++) {
4388
+ // Chromium does not recognize text-align: left. Use -webkit-
4389
+ // TODO: Remove -webkit- when Chromium no longer needs it.
4390
+ row.children[j].style.textAlign = "-webkit-" + (j % 2 ? "left" : "right");
4391
+ }
4392
+ }
4393
+ if (row.children.length > 1 && group.envClasses.includes("cases")) {
4394
+ row.children[1].style.padding = row.children[1].style.padding.replace(/0em$/, "1em");
4395
+ }
4396
+
4397
+ if (group.envClasses.includes("cases") || group.envClasses.includes("subarray")) {
4398
+ for (const cell of row.children) {
4399
+ cell.style.textAlign = "-webkit-" + "left";
4400
+ }
4401
+ }
4402
+ }
4403
+ } else {
4404
+ // Set zero padding on side of the matrix
4405
+ for (let i = 0; i < tbl.length; i++) {
4406
+ tbl[i].children[0].style.paddingLeft = "0em";
4407
+ if (tbl[i].children.length === tbl[0].children.length) {
4408
+ tbl[i].children[tbl[i].children.length - 1].style.paddingRight = "0em";
4409
+ }
4410
+ }
4320
4411
  }
4412
+
4413
+ let table = new mathMLTree.MathNode("mtable", tbl);
4321
4414
  if (group.scriptLevel === "display") { table.setAttribute("displaystyle", "true"); }
4322
4415
 
4323
4416
  if (group.addEqnNum || group.envClasses.includes("multline")) {
@@ -4397,6 +4490,8 @@ const mathmlBuilder$7 = function(group, style) {
4397
4490
  align = "left " + (align.length > 0 ? align : "center ") + "right ";
4398
4491
  }
4399
4492
  if (align) {
4493
+ // Firefox reads this attribute, not the -webkit-left|right written above.
4494
+ // TODO: When Chrome no longer needs "-webkit-", use CSS and delete the next line.
4400
4495
  table.setAttribute("columnalign", align.trim());
4401
4496
  }
4402
4497
 
@@ -4421,7 +4516,7 @@ const alignedHandler = function(context, args) {
4421
4516
  cols,
4422
4517
  addEqnNum: context.envName === "align" || context.envName === "alignat",
4423
4518
  emptySingleRow: true,
4424
- envClasses: ["jot", "abut"], // set row spacing & provisional column spacing
4519
+ envClasses: ["abut", "jot"], // set row spacing & provisional column spacing
4425
4520
  maxNumCols: context.envName === "split" ? 2 : undefined,
4426
4521
  leqno: context.parser.settings.leqno
4427
4522
  },
@@ -4439,18 +4534,22 @@ const alignedHandler = function(context, args) {
4439
4534
  // binary. This behavior is implemented in amsmath's \start@aligned.
4440
4535
  let numMaths;
4441
4536
  let numCols = 0;
4442
- if (args[0] && args[0].type === "ordgroup") {
4537
+ const isAlignedAt = context.envName.indexOf("at") > -1;
4538
+ if (args[0] && isAlignedAt) {
4539
+ // alignat environment takes an argument w/ number of columns
4443
4540
  let arg0 = "";
4444
4541
  for (let i = 0; i < args[0].body.length; i++) {
4445
4542
  const textord = assertNodeType(args[0].body[i], "textord");
4446
4543
  arg0 += textord.text;
4447
4544
  }
4545
+ if (isNaN(arg0)) {
4546
+ throw new ParseError("The alignat enviroment requires a numeric first argument.")
4547
+ }
4448
4548
  numMaths = Number(arg0);
4449
4549
  numCols = numMaths * 2;
4450
4550
  }
4451
- const isAligned = !numCols;
4452
4551
  res.body.forEach(function(row) {
4453
- if (!isAligned) {
4552
+ if (isAlignedAt) {
4454
4553
  // Case 1
4455
4554
  const curMaths = row.length / 2;
4456
4555
  if (numMaths < curMaths) {
@@ -4478,14 +4577,10 @@ const alignedHandler = function(context, args) {
4478
4577
  align: align
4479
4578
  };
4480
4579
  }
4481
- if (context.envName === "split") ; else if (context.envName.indexOf("ed") > -1) {
4482
- res.envClasses.push("aligned"); // Sets justification
4483
- } else if (isAligned) {
4484
- res.envClasses[1] = context.envName === "align*"
4485
- ? "align-star"
4486
- : "align"; // Sets column spacing & justification
4580
+ if (context.envName === "split") ; else if (isAlignedAt) {
4581
+ res.envClasses.push("alignat"); // Sets justification
4487
4582
  } else {
4488
- res.envClasses.push("aligned"); // Sets justification
4583
+ res.envClasses[0] = "align"; // Sets column spacing & justification
4489
4584
  }
4490
4585
  return res;
4491
4586
  };
@@ -4735,7 +4830,7 @@ defineEnvironment({
4735
4830
  }
4736
4831
  const res = {
4737
4832
  cols: [],
4738
- envClasses: ["jot", "abut"],
4833
+ envClasses: ["abut", "jot"],
4739
4834
  addEqnNum: context.envName === "gather",
4740
4835
  emptySingleRow: true,
4741
4836
  leqno: context.parser.settings.leqno
@@ -6829,8 +6924,6 @@ defineFunction({
6829
6924
  }
6830
6925
  });
6831
6926
 
6832
- const sign = num => num >= 0 ? "+" : "-";
6833
-
6834
6927
  // \raise, \lower, and \raisebox
6835
6928
 
6836
6929
  const mathmlBuilder = (group, style) => {
@@ -6838,11 +6931,13 @@ const mathmlBuilder = (group, style) => {
6838
6931
  const node = new mathMLTree.MathNode("mpadded", [buildGroup$1(group.body, newStyle)]);
6839
6932
  const dy = calculateSize(group.dy, style);
6840
6933
  node.setAttribute("voffset", dy.number + dy.unit);
6841
- const dyAbs = Math.abs(dy.number);
6842
- // The next two lines do not work in Chromium.
6843
- // TODO: Find some other way to adjust height and depth.
6844
- node.setAttribute("height", sign(dy.number) + dyAbs + dy.unit);
6845
- node.setAttribute("depth", sign(-dy.number) + dyAbs + dy.unit);
6934
+ // Add padding, which acts to increase height in Chromium.
6935
+ // TODO: Figure out some way to change height in Firefox w/o breaking Chromium.
6936
+ if (dy.number > 0) {
6937
+ node.style.padding = dy.number + dy.unit + " 0 0 0";
6938
+ } else {
6939
+ node.style.padding = "0 0 " + Math.abs(dy.number) + dy.unit + " 0";
6940
+ }
6846
6941
  return node
6847
6942
  };
6848
6943
 
@@ -8471,9 +8566,6 @@ defineMacro("\u22ee", "\\vdots");
8471
8566
  //\newcommand{\substack}[1]{\subarray{c}#1\endsubarray}
8472
8567
  defineMacro("\\substack", "\\begin{subarray}{c}#1\\end{subarray}");
8473
8568
 
8474
- // \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}}
8475
- defineMacro("\\boxed", "\\fbox{$\\displaystyle{#1}$}");
8476
-
8477
8569
  // \def\iff{\DOTSB\;\Longleftrightarrow\;}
8478
8570
  // \def\implies{\DOTSB\;\Longrightarrow\;}
8479
8571
  // \def\impliedby{\DOTSB\;\Longleftarrow\;}
@@ -8722,7 +8814,7 @@ defineMacro(
8722
8814
  defineMacro(
8723
8815
  "\\Temml",
8724
8816
  // eslint-disable-next-line max-len
8725
- "\\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}}"
8817
+ "\\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}}"
8726
8818
  );
8727
8819
 
8728
8820
  // \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace}
@@ -12902,7 +12994,7 @@ class Style {
12902
12994
  * https://mit-license.org/
12903
12995
  */
12904
12996
 
12905
- const version = "0.10.13";
12997
+ const version = "0.10.15";
12906
12998
 
12907
12999
  function postProcess(block) {
12908
13000
  const labelMap = {};
@@ -12953,6 +13045,7 @@ function postProcess(block) {
12953
13045
  /* eslint no-console:0 */
12954
13046
 
12955
13047
  /**
13048
+ * @type {import('./temml').render}
12956
13049
  * Parse and build an expression, and place that expression in the DOM node
12957
13050
  * given.
12958
13051
  */
@@ -12990,6 +13083,7 @@ if (typeof document !== "undefined") {
12990
13083
  }
12991
13084
 
12992
13085
  /**
13086
+ * @type {import('./temml').renderToString}
12993
13087
  * Parse and build an expression, and return the markup for that.
12994
13088
  */
12995
13089
  const renderToString = function(expression, options) {
@@ -12998,6 +13092,7 @@ const renderToString = function(expression, options) {
12998
13092
  };
12999
13093
 
13000
13094
  /**
13095
+ * @type {import('./temml').generateParseTree}
13001
13096
  * Parse an expression and return the parse tree.
13002
13097
  */
13003
13098
  const generateParseTree = function(expression, options) {
@@ -13006,6 +13101,7 @@ const generateParseTree = function(expression, options) {
13006
13101
  };
13007
13102
 
13008
13103
  /**
13104
+ * @type {import('./temml').definePreamble}
13009
13105
  * Take an expression which contains a preamble.
13010
13106
  * Parse it and return the macros.
13011
13107
  */
@@ -13038,6 +13134,7 @@ const renderError = function(error, expression, options) {
13038
13134
  };
13039
13135
 
13040
13136
  /**
13137
+ * @type {import('./temml').renderToMathMLTree}
13041
13138
  * Generates and returns the Temml build tree. This is used for advanced
13042
13139
  * use cases (like rendering to custom output).
13043
13140
  */
@@ -13055,6 +13152,7 @@ const renderToMathMLTree = function(expression, options) {
13055
13152
  }
13056
13153
  };
13057
13154
 
13155
+ /** @type {import('./temml').default} */
13058
13156
  var temml = {
13059
13157
  /**
13060
13158
  * Current Temml version
@@ -14,7 +14,7 @@
14
14
  * https://mit-license.org/
15
15
  */
16
16
 
17
- const version = "0.10.13";
17
+ const version = "0.10.15";
18
18
 
19
19
  function postProcess(block) {
20
20
  const labelMap = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "temml",
3
- "version": "0.10.13",
3
+ "version": "0.10.15",
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
  },
@@ -260,9 +260,10 @@ 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.children.length === 1 && math.children[0].type === "mtable"
264
- ? "inline"
265
- : "block math"
263
+ math.style.display = "block math" // necessary in Chromium.
264
+ // Firefox and Safari do not recognize display: "block math".
265
+ // Set a class so that the CSS file can set display: block.
266
+ math.classes = ["tml-display"]
266
267
  }
267
268
  return math;
268
269
  }