temml 0.11.1 → 0.11.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/dist/temml.js CHANGED
@@ -1184,9 +1184,6 @@ var temml = (function () {
1184
1184
  defineSymbol(math, textord, "\u2605", "\\bigstar");
1185
1185
  defineSymbol(math, textord, "\u2222", "\\sphericalangle", true);
1186
1186
  defineSymbol(math, textord, "\u2201", "\\complement", true);
1187
- // unicode-math maps U+F0 to \matheth. We map to AMS function \eth
1188
- defineSymbol(math, textord, "\u00f0", "\\eth", true);
1189
- defineSymbol(text, textord, "\u00f0", "\u00f0");
1190
1187
  defineSymbol(math, textord, "\u2571", "\\diagup");
1191
1188
  defineSymbol(math, textord, "\u2572", "\\diagdown");
1192
1189
  defineSymbol(math, textord, "\u25a1", "\\square");
@@ -1546,6 +1543,46 @@ var temml = (function () {
1546
1543
  defineSymbol(math, mathord, "\u03da", "\\Stigma", true);
1547
1544
  defineSymbol(math, mathord, "\u03db", "\\stigma", true);
1548
1545
  defineSymbol(math, mathord, "\u2aeb", "\\Bot");
1546
+
1547
+ // unicode-math maps U+F0 to \matheth. We map to AMS function \eth
1548
+ defineSymbol(math, textord, "\u00f0", "\\eth", true); // ð
1549
+ defineSymbol(text, textord, "\u00f0", "\u00f0");
1550
+ // Extended ASCII and non-ASCII Letters
1551
+ defineSymbol(math, textord, "\u00C5", "\\AA"); // Å
1552
+ defineSymbol(text, textord, "\u00C5", "\\AA", true);
1553
+ defineSymbol(math, textord, "\u00C6", "\\AE", true); // Æ
1554
+ defineSymbol(text, textord, "\u00C6", "\\AE", true);
1555
+ defineSymbol(math, textord, "\u00D0", "\\DH", true); // Ð
1556
+ defineSymbol(text, textord, "\u00D0", "\\DH", true);
1557
+ defineSymbol(math, textord, "\u00DE", "\\TH", true); // Þ
1558
+ defineSymbol(text, textord, "\u00DE", "\\TH", true);
1559
+ defineSymbol(math, textord, "\u00DF", "\\ss", true); // ß
1560
+ defineSymbol(text, textord, "\u00DF", "\\ss", true);
1561
+ defineSymbol(math, textord, "\u00E5", "\\aa"); // å
1562
+ defineSymbol(text, textord, "\u00E5", "\\aa", true);
1563
+ defineSymbol(math, textord, "\u00E6", "\\ae", true); // æ
1564
+ defineSymbol(text, textord, "\u00E6", "\\ae", true);
1565
+ defineSymbol(math, textord, "\u00F0", "\\dh"); // ð
1566
+ defineSymbol(text, textord, "\u00F0", "\\dh", true);
1567
+ defineSymbol(math, textord, "\u00FE", "\\th", true); // þ
1568
+ defineSymbol(text, textord, "\u00FE", "\\th", true);
1569
+ defineSymbol(math, textord, "\u0110", "\\DJ", true); // Đ
1570
+ defineSymbol(text, textord, "\u0110", "\\DJ", true);
1571
+ defineSymbol(math, textord, "\u0111", "\\dj", true); // đ
1572
+ defineSymbol(text, textord, "\u0111", "\\dj", true);
1573
+ defineSymbol(math, textord, "\u0141", "\\L", true); // Ł
1574
+ defineSymbol(text, textord, "\u0141", "\\L", true);
1575
+ defineSymbol(math, textord, "\u0141", "\\l", true); // ł
1576
+ defineSymbol(text, textord, "\u0141", "\\l", true);
1577
+ defineSymbol(math, textord, "\u014A", "\\NG", true); // Ŋ
1578
+ defineSymbol(text, textord, "\u014A", "\\NG", true);
1579
+ defineSymbol(math, textord, "\u014B", "\\ng", true); // ŋ
1580
+ defineSymbol(text, textord, "\u014B", "\\ng", true);
1581
+ defineSymbol(math, textord, "\u0152", "\\OE", true); // Œ
1582
+ defineSymbol(text, textord, "\u0152", "\\OE", true);
1583
+ defineSymbol(math, textord, "\u0153", "\\oe", true); // œ
1584
+ defineSymbol(text, textord, "\u0153", "\\oe", true);
1585
+
1549
1586
  defineSymbol(math, bin, "\u2217", "\u2217", true);
1550
1587
  defineSymbol(math, bin, "+", "+");
1551
1588
  defineSymbol(math, bin, "\u2217", "*");
@@ -1754,13 +1791,8 @@ var temml = (function () {
1754
1791
  defineSymbol(math, textord, "\u0237", "\u0237");
1755
1792
  defineSymbol(text, textord, "\u0131", "\\i", true);
1756
1793
  defineSymbol(text, textord, "\u0237", "\\j", true);
1757
- defineSymbol(text, textord, "\u00df", "\\ss", true);
1758
- defineSymbol(text, textord, "\u00e6", "\\ae", true);
1759
- defineSymbol(text, textord, "\u0153", "\\oe", true);
1760
1794
  defineSymbol(text, textord, "\u00f8", "\\o", true);
1761
1795
  defineSymbol(math, mathord, "\u00f8", "\\o", true);
1762
- defineSymbol(text, textord, "\u00c6", "\\AE", true);
1763
- defineSymbol(text, textord, "\u0152", "\\OE", true);
1764
1796
  defineSymbol(text, textord, "\u00d8", "\\O", true);
1765
1797
  defineSymbol(math, mathord, "\u00d8", "\\O", true);
1766
1798
  defineSymbol(text, accent, "\u02ca", "\\'"); // acute
@@ -1773,7 +1805,7 @@ var temml = (function () {
1773
1805
  defineSymbol(text, accent, "\u00b8", "\\c"); // cedilla
1774
1806
  defineSymbol(text, accent, "\u02da", "\\r"); // ring above
1775
1807
  defineSymbol(text, accent, "\u02c7", "\\v"); // caron
1776
- defineSymbol(text, accent, "\u00a8", '\\"'); // diaresis
1808
+ defineSymbol(text, accent, "\u00a8", '\\"'); // diaeresis
1777
1809
  defineSymbol(text, accent, "\u02dd", "\\H"); // double acute
1778
1810
  defineSymbol(math, accent, "\u02ca", "\\'"); // acute
1779
1811
  defineSymbol(math, accent, "\u02cb", "\\`"); // grave
@@ -1785,7 +1817,7 @@ var temml = (function () {
1785
1817
  defineSymbol(math, accent, "\u00b8", "\\c"); // cedilla
1786
1818
  defineSymbol(math, accent, "\u02da", "\\r"); // ring above
1787
1819
  defineSymbol(math, accent, "\u02c7", "\\v"); // caron
1788
- defineSymbol(math, accent, "\u00a8", '\\"'); // diaresis
1820
+ defineSymbol(math, accent, "\u00a8", '\\"'); // diaeresis
1789
1821
  defineSymbol(math, accent, "\u02dd", "\\H"); // double acute
1790
1822
 
1791
1823
  // These ligatures are detected and created in Parser.js's `formLigatures`.
@@ -2753,17 +2785,17 @@ var temml = (function () {
2753
2785
 
2754
2786
  // Helper functions
2755
2787
 
2756
- const padding$2 = width => {
2788
+ const padding$1 = width => {
2757
2789
  const node = new mathMLTree.MathNode("mspace");
2758
2790
  node.setAttribute("width", width + "em");
2759
2791
  return node
2760
2792
  };
2761
2793
 
2762
2794
  const paddedNode = (group, lspace = 0.3, rspace = 0, mustSmash = false) => {
2763
- if (group == null && rspace === 0) { return padding$2(lspace) }
2795
+ if (group == null && rspace === 0) { return padding$1(lspace) }
2764
2796
  const row = group ? [group] : [];
2765
- if (lspace !== 0) { row.unshift(padding$2(lspace)); }
2766
- if (rspace > 0) { row.push(padding$2(rspace)); }
2797
+ if (lspace !== 0) { row.unshift(padding$1(lspace)); }
2798
+ if (rspace > 0) { row.push(padding$1(rspace)); }
2767
2799
  if (mustSmash) {
2768
2800
  // Used for the bottom arrow in a {CD} environment
2769
2801
  const mpadded = new mathMLTree.MathNode("mpadded", row);
@@ -2890,8 +2922,8 @@ var temml = (function () {
2890
2922
  const node = munderoverNode(group.name, group.body, group.below, style);
2891
2923
  // Create operator spacing for a relation.
2892
2924
  const row = [node];
2893
- row.unshift(padding$2(0.2778));
2894
- row.push(padding$2(0.2778));
2925
+ row.unshift(padding$1(0.2778));
2926
+ row.push(padding$1(0.2778));
2895
2927
  return new mathMLTree.MathNode("mrow", row)
2896
2928
  }
2897
2929
  });
@@ -2966,13 +2998,13 @@ var temml = (function () {
2966
2998
  botNode.setAttribute("width", "0.5em");
2967
2999
  wrapper = new mathMLTree.MathNode(
2968
3000
  "mpadded",
2969
- [padding$2(0.2778), botNode, raiseNode, padding$2(0.2778)]
3001
+ [padding$1(0.2778), botNode, raiseNode, padding$1(0.2778)]
2970
3002
  );
2971
3003
  } else {
2972
3004
  raiseNode.setAttribute("width", (group.name === "\\equilibriumRight" ? "0.5em" : "0"));
2973
3005
  wrapper = new mathMLTree.MathNode(
2974
3006
  "mpadded",
2975
- [padding$2(0.2778), raiseNode, botArrow, padding$2(0.2778)]
3007
+ [padding$1(0.2778), raiseNode, botArrow, padding$1(0.2778)]
2976
3008
  );
2977
3009
  }
2978
3010
 
@@ -3348,7 +3380,7 @@ var temml = (function () {
3348
3380
  // A vphantom with contents from the pmatrix, to set minimum cell height
3349
3381
  const phantomBody = [];
3350
3382
  for (let j = 0; j < body[i].length; j++) {
3351
- phantomBody.push(structuredClone(body[i][j]));
3383
+ phantomBody.push(body[i][j]);
3352
3384
  }
3353
3385
  leftColumnBody[i - 1].push(phantom(phantomBody, "vphantom"));
3354
3386
  }
@@ -3356,18 +3388,18 @@ var temml = (function () {
3356
3388
  // Create an array for the top row
3357
3389
  const topRowBody = new Array(body.length).fill().map(() => []);
3358
3390
  for (let j = 0; j < body[0].length; j++) {
3359
- topRowBody[0].push(structuredClone(body[0][j]));
3391
+ topRowBody[0].push(body[0][j]);
3360
3392
  }
3361
3393
  // Copy the rest of the pmatrix, but squashed via \hphantom
3362
3394
  for (let i = 1; i < body.length; i++) {
3363
3395
  for (let j = 0; j < body[0].length; j++) {
3364
- topRowBody[i].push(phantom(structuredClone(body[i][j]).body, "hphantom"));
3396
+ topRowBody[i].push(phantom(body[i][j].body, "hphantom"));
3365
3397
  }
3366
3398
  }
3367
3399
 
3368
3400
  // Squash the top row of the main {pmatrix}
3369
3401
  for (let j = 0; j < body[0].length; j++) {
3370
- body[0][j] = phantom(structuredClone(body[0][j]).body, "hphantom");
3402
+ body[0][j] = phantom(body[0][j].body, "hphantom");
3371
3403
  }
3372
3404
 
3373
3405
  // Now wrap the arrays in the proper parse nodes.
@@ -6170,7 +6202,7 @@ var temml = (function () {
6170
6202
  }
6171
6203
  });
6172
6204
 
6173
- const padding$1 = _ => {
6205
+ const padding = _ => {
6174
6206
  const node = new mathMLTree.MathNode("mspace");
6175
6207
  node.setAttribute("width", "3pt");
6176
6208
  return node
@@ -6183,9 +6215,9 @@ var temml = (function () {
6183
6215
  // Firefox does not reliably add side padding.
6184
6216
  // Insert <mspace>
6185
6217
  node = new mathMLTree.MathNode("mrow", [
6186
- padding$1(),
6218
+ padding(),
6187
6219
  buildGroup$1(group.body, style),
6188
- padding$1()
6220
+ padding()
6189
6221
  ]);
6190
6222
  } else {
6191
6223
  node = new mathMLTree.MathNode("menclose", [buildGroup$1(group.body, style)]);
@@ -6534,9 +6566,9 @@ var temml = (function () {
6534
6566
  const mi = mathGroup.children[0].children[0];
6535
6567
  delete mi.attributes.mathvariant;
6536
6568
  for (let i = 1; i < mathGroup.children.length; i++) {
6537
- mi.children[0].text += mathGroup.children[i].type === "mn"
6538
- ? mathGroup.children[i].children[0].text
6539
- : mathGroup.children[i].children[0].children[0].text;
6569
+ mi.children[0].text += mathGroup.children[i].children[0].children
6570
+ ? mathGroup.children[i].children[0].children[0].text
6571
+ : mathGroup.children[i].children[0].text;
6540
6572
  }
6541
6573
  // Wrap in a <mrow> to prevent the same Firefox bug.
6542
6574
  const bogus = new mathMLTree.MathNode("mtext", new mathMLTree.TextNode("\u200b"));
@@ -7585,12 +7617,6 @@ var temml = (function () {
7585
7617
 
7586
7618
  const textAtomTypes = ["text", "textord", "mathord", "atom"];
7587
7619
 
7588
- const padding = width => {
7589
- const node = new mathMLTree.MathNode("mspace");
7590
- node.setAttribute("width", width + "em");
7591
- return node
7592
- };
7593
-
7594
7620
  function mathmlBuilder$3(group, style) {
7595
7621
  let node;
7596
7622
  const inner = buildExpression(group.body, style);
@@ -7626,17 +7652,17 @@ var temml = (function () {
7626
7652
  if (doSpacing ) {
7627
7653
  if (group.mclass === "mbin") {
7628
7654
  // medium space
7629
- node.children.unshift(padding(0.2222));
7630
- node.children.push(padding(0.2222));
7655
+ node.children.unshift(padding$1(0.2222));
7656
+ node.children.push(padding$1(0.2222));
7631
7657
  } else if (group.mclass === "mrel") {
7632
7658
  // thickspace
7633
- node.children.unshift(padding(0.2778));
7634
- node.children.push(padding(0.2778));
7659
+ node.children.unshift(padding$1(0.2778));
7660
+ node.children.push(padding$1(0.2778));
7635
7661
  } else if (group.mclass === "mpunct") {
7636
- node.children.push(padding(0.1667));
7662
+ node.children.push(padding$1(0.1667));
7637
7663
  } else if (group.mclass === "minner") {
7638
- node.children.unshift(padding(0.0556)); // 1 mu is the most likely option
7639
- node.children.push(padding(0.0556));
7664
+ node.children.unshift(padding$1(0.0556)); // 1 mu is the most likely option
7665
+ node.children.push(padding$1(0.0556));
7640
7666
  }
7641
7667
  }
7642
7668
  } else {
@@ -7706,14 +7732,19 @@ var temml = (function () {
7706
7732
  break
7707
7733
  }
7708
7734
  }
7709
- return {
7710
- type: "mclass",
7711
- mode: parser.mode,
7712
- mclass: "m" + funcName.slice(5),
7713
- body: ordargument(mustPromote ? mord : body),
7714
- isCharacterBox,
7715
- mustPromote
7716
- };
7735
+ if (mustPromote && funcName === "\\mathord" && mord.type === "mathord"
7736
+ && mord.text.length > 1) {
7737
+ return mord
7738
+ } else {
7739
+ return {
7740
+ type: "mclass",
7741
+ mode: parser.mode,
7742
+ mclass: "m" + funcName.slice(5),
7743
+ body: ordargument(mustPromote ? mord : body),
7744
+ isCharacterBox,
7745
+ mustPromote
7746
+ };
7747
+ }
7717
7748
  },
7718
7749
  mathmlBuilder: mathmlBuilder$3
7719
7750
  });
@@ -8031,8 +8062,13 @@ var temml = (function () {
8031
8062
  "\u2a00",
8032
8063
  "\u2a01",
8033
8064
  "\u2a02",
8065
+ "\u2a03",
8034
8066
  "\u2a04",
8035
- "\u2a06"
8067
+ "\u2a05",
8068
+ "\u2a06",
8069
+ "\u2a07",
8070
+ "\u2a08",
8071
+ "\u2a09"
8036
8072
  ],
8037
8073
  props: {
8038
8074
  numArgs: 0
@@ -8275,7 +8311,7 @@ var temml = (function () {
8275
8311
  for (let i = 0; i < expression.length; i++) {
8276
8312
  let node = expression[i];
8277
8313
  if (node instanceof mathMLTree.MathNode) {
8278
- if (node.type === "mrow" && node.children.length === 1 &&
8314
+ if ((node.type === "mrow" || node.type === "mpadded") && node.children.length === 1 &&
8279
8315
  node.children[0] instanceof mathMLTree.MathNode) {
8280
8316
  node = node.children[0];
8281
8317
  }
@@ -8893,7 +8929,7 @@ var temml = (function () {
8893
8929
  defineFunctionBuilders({
8894
8930
  type: "supsub",
8895
8931
  mathmlBuilder(group, style) {
8896
- // Is the inner group a relevant horizonal brace?
8932
+ // Is the inner group a relevant horizontal brace?
8897
8933
  let isBrace = false;
8898
8934
  let isOver;
8899
8935
  let isSup;
@@ -9076,6 +9112,14 @@ var temml = (function () {
9076
9112
  // ":" is not in the MathML operator dictionary. Give it BIN spacing.
9077
9113
  node.attributes.lspace = "0.2222em";
9078
9114
  node.attributes.rspace = "0.2222em";
9115
+ } else if (group.needsSpacing) {
9116
+ // Fix a MathML bug that occurs when a <mo> is between two <mtext> elements.
9117
+ if (group.family === "bin") {
9118
+ return new mathMLTree.MathNode("mrow", [padding$1(0.222), node, padding$1(0.222)])
9119
+ } else {
9120
+ // REL spacing
9121
+ return new mathMLTree.MathNode("mrow", [padding$1(0.2778), node, padding$1(0.2778)])
9122
+ }
9079
9123
  }
9080
9124
  return node;
9081
9125
  }
@@ -9443,7 +9487,8 @@ var temml = (function () {
9443
9487
  node.setAttribute("mathvariant", "normal");
9444
9488
  if (text.text.length === 1) {
9445
9489
  // A Firefox bug will apply spacing here, but there should be none. Fix it.
9446
- node = new mathMLTree.MathNode("mrow", [node]);
9490
+ node = new mathMLTree.MathNode("mpadded", [node]);
9491
+ node.setAttribute("lspace", "0");
9447
9492
  }
9448
9493
  }
9449
9494
  return node
@@ -10822,6 +10867,7 @@ var temml = (function () {
10822
10867
 
10823
10868
  const binLeftCancellers = ["bin", "op", "open", "punct", "rel"];
10824
10869
  const sizeRegEx = /([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/;
10870
+ const textRegEx = /^ *\\text/;
10825
10871
 
10826
10872
  /**
10827
10873
  * This file contains the parser used to parse out a TeX expression from the
@@ -11732,6 +11778,11 @@ var temml = (function () {
11732
11778
  loc,
11733
11779
  text
11734
11780
  };
11781
+ if ((family === "rel" || family === "bin") && this.prevAtomType === "text") {
11782
+ if (textRegEx.test(loc.lexer.input.slice(loc.end))) {
11783
+ s.needsSpacing = true; // Fix a MathML bug.
11784
+ }
11785
+ }
11735
11786
  } else {
11736
11787
  if (asciiFromScript[text]) {
11737
11788
  // Unicode 14 disambiguates chancery from roundhand.
@@ -11989,7 +12040,7 @@ var temml = (function () {
11989
12040
  * https://mit-license.org/
11990
12041
  */
11991
12042
 
11992
- const version = "0.11.01";
12043
+ const version = "0.11.03";
11993
12044
 
11994
12045
  function postProcess(block) {
11995
12046
  const labelMap = {};