temml 0.11.9 → 0.11.11

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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  | Library | Minified JavaScript + CSS |
4
4
  |:--------------|:-------------------------:|
5
- | Temml | 170 KB |
5
+ | Temml | 171 KB |
6
6
  | MathJax 2.7.5 | 338 KB |
7
7
  | KaTeX | 280 KB |
8
8
  | TeXZilla | 168 KB |
@@ -117,6 +117,9 @@ menclose {
117
117
  text-align: left;
118
118
  }
119
119
 
120
+ /* For CD labels that grow to the left in Firefox and WebKit */
121
+ .tml-shift-left { margin-left:-200% }
122
+
120
123
  /* Styles for Chromium only */
121
124
  @supports (not (-webkit-backdrop-filter: blur(1px))) and (not (-moz-appearance: none)) {
122
125
  /* Italic correction on accents */
@@ -138,6 +141,10 @@ menclose {
138
141
  .chr-lrg-vec {
139
142
  transform: scale(0.75) translate(0.21em, 0)
140
143
  }
144
+
145
+ /* For CD labels that grow to the left */
146
+ .tml-shift-left { margin-left:-100% }
147
+
141
148
  /* MathML Core & Chromium do not support the MathML 3.0 element <menclose> attributes. */
142
149
  /* So use styles. */
143
150
  menclose {
@@ -131,6 +131,9 @@ menclose {
131
131
  text-align: left;
132
132
  }
133
133
 
134
+ /* For CD labels that grow to the left in Firefox and WebKit */
135
+ .tml-shift-left { margin-left:-200% }
136
+
134
137
  /* Styles for Chromium only */
135
138
  @supports (not (-webkit-backdrop-filter: blur(1px))) and (not (-moz-appearance: none)) {
136
139
  /* Italic correction on accents */
@@ -152,6 +155,10 @@ menclose {
152
155
  .chr-lrg-vec {
153
156
  transform: scale(0.75) translate(0.21em, 0)
154
157
  }
158
+
159
+ /* For CD labels that grow to the left */
160
+ .tml-shift-left { margin-left:-100% }
161
+
155
162
  /* MathML Core & Chromium do not support the MathML 3.0 element <menclose> attributes. */
156
163
  /* So use styles. */
157
164
  menclose {
@@ -133,6 +133,9 @@ menclose {
133
133
  text-align: left;
134
134
  }
135
135
 
136
+ /* For CD labels that grow to the left in Firefox and WebKit */
137
+ .tml-shift-left { margin-left:-200% }
138
+
136
139
  /* Styles for Chromium only */
137
140
  @supports (not (-webkit-backdrop-filter: blur(1px))) and (not (-moz-appearance: none)) {
138
141
  /* Italic correction on accents */
@@ -154,6 +157,10 @@ menclose {
154
157
  .chr-lrg-vec {
155
158
  transform: scale(0.75) translate(0.21em, 0)
156
159
  }
160
+
161
+ /* For CD labels that grow to the left */
162
+ .tml-shift-left { margin-left:-100% }
163
+
157
164
  /* MathML Core & Chromium do not support the MathML 3.0 element <menclose> attributes. */
158
165
  /* So use styles. */
159
166
  menclose {
@@ -124,6 +124,9 @@ menclose {
124
124
  text-align: left;
125
125
  }
126
126
 
127
+ /* For CD labels that grow to the left in Firefox and WebKit */
128
+ .tml-shift-left { margin-left:-200% }
129
+
127
130
  /* Styles for Chromium only */
128
131
  @supports (not (-webkit-backdrop-filter: blur(1px))) and (not (-moz-appearance: none)) {
129
132
  /* Italic correction on accents */
@@ -145,6 +148,10 @@ menclose {
145
148
  .chr-lrg-vec {
146
149
  transform: scale(0.75) translate(0.21em, 0)
147
150
  }
151
+
152
+ /* For CD labels that grow to the left */
153
+ .tml-shift-left { margin-left:-100% }
154
+
148
155
  /* MathML Core & Chromium do not support the MathML 3.0 element <menclose> attributes. */
149
156
  /* So use styles. */
150
157
  menclose {
@@ -126,6 +126,9 @@ menclose {
126
126
  text-align: left;
127
127
  }
128
128
 
129
+ /* For CD labels that grow to the left in Firefox and WebKit */
130
+ .tml-shift-left { margin-left:-200% }
131
+
129
132
  /* Styles for Chromium only */
130
133
  @supports (not (-webkit-backdrop-filter: blur(1px))) and (not (-moz-appearance: none)) {
131
134
  /* Italic correction on accents */
@@ -147,6 +150,10 @@ menclose {
147
150
  .chr-lrg-vec {
148
151
  transform: scale(0.75) translate(0.21em, 0)
149
152
  }
153
+
154
+ /* For CD labels that grow to the left */
155
+ .tml-shift-left { margin-left:-100% }
156
+
150
157
  /* MathML Core & Chromium do not support the MathML 3.0 element <menclose> attributes. */
151
158
  /* So use styles. */
152
159
  menclose {
@@ -123,6 +123,9 @@ menclose {
123
123
  text-align: left;
124
124
  }
125
125
 
126
+ /* For CD labels that grow to the left in Firefox and WebKit */
127
+ .tml-shift-left { margin-left:-200% }
128
+
126
129
  /* Styles for Chromium only */
127
130
  @supports (not (-webkit-backdrop-filter: blur(1px))) and (not (-moz-appearance: none)) {
128
131
  /* Italic correction on accents */
@@ -144,6 +147,10 @@ menclose {
144
147
  .chr-lrg-vec {
145
148
  transform: scale(0.75) translate(0.21em, 0)
146
149
  }
150
+
151
+ /* For CD labels that grow to the left */
152
+ .tml-shift-left { margin-left:-100% }
153
+
147
154
  /* MathML Core & Chromium do not support the MathML 3.0 element <menclose> attributes. */
148
155
  /* So use styles. */
149
156
  menclose {
package/dist/temml.cjs CHANGED
@@ -2405,13 +2405,12 @@ const getLabel = parent => {
2405
2405
 
2406
2406
  const taggedExpression = (expression, tag, style, leqno) => {
2407
2407
  tag = buildExpressionRow(tag[0].body, style);
2408
- tag = consolidateText(tag);
2409
- tag.classes.push("tml-tag");
2408
+ tag = consolidateText(tag); // tag is now an <mtext> element
2409
+ tag.classes.push("tml-tag"); // to be available for \ref
2410
2410
 
2411
2411
  const label = getLabel(expression); // from a \label{} function.
2412
2412
  expression = new mathMLTree.MathNode("mtd", [expression]);
2413
2413
  const rowArray = [glue$1(), expression, glue$1()];
2414
- rowArray[leqno ? 0 : 2].classes.push(leqno ? "tml-left" : "tml-right");
2415
2414
  rowArray[leqno ? 0 : 2].children.push(tag);
2416
2415
  const mtr = new mathMLTree.MathNode("mtr", rowArray, ["tml-tageqn"]);
2417
2416
  if (label) { mtr.setAttribute("id", label); }
@@ -2808,21 +2807,21 @@ const calculateSize = function(sizeValue, style) {
2808
2807
 
2809
2808
  // Helper functions
2810
2809
 
2811
- const padding$1 = width => {
2810
+ const padding = width => {
2812
2811
  const node = new mathMLTree.MathNode("mspace");
2813
2812
  node.setAttribute("width", width + "em");
2814
2813
  return node
2815
2814
  };
2816
2815
 
2817
2816
  const paddedNode = (group, lspace = 0.3, rspace = 0, mustSmash = false) => {
2818
- if (group == null && rspace === 0) { return padding$1(lspace) }
2817
+ if (group == null && rspace === 0) { return padding(lspace) }
2819
2818
  const row = group ? [group] : [];
2820
- if (lspace !== 0) { row.unshift(padding$1(lspace)); }
2821
- if (rspace > 0) { row.push(padding$1(rspace)); }
2819
+ if (lspace !== 0) { row.unshift(padding(lspace)); }
2820
+ if (rspace > 0) { row.push(padding(rspace)); }
2822
2821
  if (mustSmash) {
2823
2822
  // Used for the bottom arrow in a {CD} environment
2824
2823
  const mpadded = new mathMLTree.MathNode("mpadded", row);
2825
- mpadded.setAttribute("height", "0");
2824
+ mpadded.setAttribute("height", "0.1px"); // Don't use 0. WebKit would hide it.
2826
2825
  return mpadded
2827
2826
  } else {
2828
2827
  return new mathMLTree.MathNode("mrow", row)
@@ -2950,8 +2949,8 @@ defineFunction({
2950
2949
  const node = munderoverNode(group.name, group.body, group.below, style);
2951
2950
  // Create operator spacing for a relation.
2952
2951
  const row = [node];
2953
- row.unshift(padding$1(0.2778));
2954
- row.push(padding$1(0.2778));
2952
+ row.unshift(padding(0.2778));
2953
+ row.push(padding(0.2778));
2955
2954
  return new mathMLTree.MathNode("mrow", row)
2956
2955
  }
2957
2956
  });
@@ -3015,13 +3014,13 @@ defineFunction({
3015
3014
  botNode.setAttribute("width", "0.5em");
3016
3015
  wrapper = new mathMLTree.MathNode(
3017
3016
  "mpadded",
3018
- [padding$1(0.2778), botNode, raiseNode, padding$1(0.2778)]
3017
+ [padding(0.2778), botNode, raiseNode, padding(0.2778)]
3019
3018
  );
3020
3019
  } else {
3021
3020
  raiseNode.setAttribute("width", (group.name === "\\equilibriumRight" ? "0.5em" : "0"));
3022
3021
  wrapper = new mathMLTree.MathNode(
3023
3022
  "mpadded",
3024
- [padding$1(0.2778), raiseNode, botArrow, padding$1(0.2778)]
3023
+ [padding(0.2778), raiseNode, botArrow, padding(0.2778)]
3025
3024
  );
3026
3025
  }
3027
3026
 
@@ -3314,19 +3313,19 @@ defineFunction({
3314
3313
  return new mathMLTree.MathNode("mrow", style) // empty label
3315
3314
  }
3316
3315
  // Abuse an <mtable> to create vertically centered content.
3317
- const mtd = new mathMLTree.MathNode("mtd", [buildGroup$1(group.label, style)]);
3316
+ const mrow = buildGroup$1(group.label, style);
3317
+ if (group.side === "left") {
3318
+ mrow.classes.push("tml-shift-left");
3319
+ }
3320
+ const mtd = new mathMLTree.MathNode("mtd", [mrow]);
3318
3321
  mtd.style.padding = "0";
3319
3322
  const mtr = new mathMLTree.MathNode("mtr", [mtd]);
3320
3323
  const mtable = new mathMLTree.MathNode("mtable", [mtr]);
3321
3324
  const label = new mathMLTree.MathNode("mpadded", [mtable]);
3322
3325
  // Set the label width to zero so that the arrow will be centered under the corner cell.
3323
- label.setAttribute("width", "0");
3326
+ label.setAttribute("width", "0.1px"); // Don't use 0. WebKit would hide it.
3324
3327
  label.setAttribute("displaystyle", "false");
3325
3328
  label.setAttribute("scriptlevel", "1");
3326
- if (group.side === "left") {
3327
- label.style.display = "flex";
3328
- label.style.justifyContent = "flex-end";
3329
- }
3330
3329
  return label;
3331
3330
  }
3332
3331
  });
@@ -6474,7 +6473,6 @@ const mathmlBuilder$9 = function(group, style) {
6474
6473
 
6475
6474
  if (group.envClasses.includes("multline")) {
6476
6475
  const align = i === 0 ? "left" : i === numRows - 1 ? "right" : "center";
6477
- mtd.setAttribute("columnalign", align);
6478
6476
  if (align !== "center") {
6479
6477
  mtd.classes.push("tml-" + align);
6480
6478
  }
@@ -6504,10 +6502,8 @@ const mathmlBuilder$9 = function(group, style) {
6504
6502
  row.push(glue(group));
6505
6503
  if (group.leqno) {
6506
6504
  row[0].children.push(tagElement);
6507
- row[0].classes.push("tml-left");
6508
6505
  } else {
6509
6506
  row[row.length - 1].children.push(tagElement);
6510
- row[row.length - 1].classes.push("tml-right");
6511
6507
  }
6512
6508
  }
6513
6509
  }
@@ -6548,8 +6544,10 @@ const mathmlBuilder$9 = function(group, style) {
6548
6544
  }
6549
6545
  }
6550
6546
  if (mustSquashRow) {
6551
- // All the cell contents are \hphantom. Squash the padding.
6547
+ // All the cell contents are \hphantom. Squash the cell.
6552
6548
  for (let j = 0; j < mtr.children.length; j++) {
6549
+ mtr.children[j].style.display = "block"; // necessary in Firefox only
6550
+ mtr.children[j].style.height = "0"; // necessary in Firefox only
6553
6551
  mtr.children[j].style.paddingTop = "0";
6554
6552
  mtr.children[j].style.paddingBottom = "0";
6555
6553
  }
@@ -6636,7 +6634,7 @@ const mathmlBuilder$9 = function(group, style) {
6636
6634
  }
6637
6635
  if (group.autoTag) {
6638
6636
  const k = group.leqno ? 0 : row.children.length - 1;
6639
- row.children[k].classes = ["tml-" + (group.leqno ? "left" : "right")];
6637
+ row.children[k].classes = []; // Default is center.
6640
6638
  }
6641
6639
  }
6642
6640
  if (row.children.length > 1 && group.envClasses.includes("cases")) {
@@ -6667,7 +6665,6 @@ const mathmlBuilder$9 = function(group, style) {
6667
6665
  }
6668
6666
 
6669
6667
  // Column separator lines and column alignment
6670
- let align = "";
6671
6668
 
6672
6669
  if (group.cols && group.cols.length > 0) {
6673
6670
  const cols = group.cols;
@@ -6696,7 +6693,6 @@ const mathmlBuilder$9 = function(group, style) {
6696
6693
  for (let i = iStart; i < iEnd; i++) {
6697
6694
  if (cols[i].type === "align") {
6698
6695
  const colAlign = alignMap[cols[i].align];
6699
- align += colAlign;
6700
6696
  iCol += 1;
6701
6697
  for (const row of table.children) {
6702
6698
  if (colAlign.trim() !== "center" && iCol < row.children.length) {
@@ -6734,15 +6730,6 @@ const mathmlBuilder$9 = function(group, style) {
6734
6730
  }
6735
6731
  }
6736
6732
  }
6737
- if (group.autoTag) {
6738
- // allow for glue cells on each side
6739
- align = "left " + (align.length > 0 ? align : "center ") + "right ";
6740
- }
6741
- if (align) {
6742
- // Firefox reads this attribute, not the -webkit-left|right written above.
6743
- // TODO: When Chrome no longer needs "-webkit-", use CSS and delete the next line.
6744
- table.setAttribute("columnalign", align.trim());
6745
- }
6746
6733
 
6747
6734
  if (group.envClasses.includes("small")) {
6748
6735
  // A small array. Wrap in scriptstyle.
@@ -7921,6 +7908,9 @@ const sizeToMaxHeight = [0, 1.2, 1.8, 2.4, 3.0];
7921
7908
 
7922
7909
  // Delimiter functions
7923
7910
  function checkDelimiter(delim, context) {
7911
+ if (delim.type === "ordgroup" && delim.body.length === 1) {
7912
+ delim = delim.body[0]; // Unwrap the braces
7913
+ }
7924
7914
  const symDelim = checkSymbolNodeType(delim);
7925
7915
  if (symDelim && delimiters.includes(symDelim.text)) {
7926
7916
  // If a character is not in the MathML operator dictionary, it will not stretch.
@@ -8152,26 +8142,8 @@ defineFunction({
8152
8142
  }
8153
8143
  });
8154
8144
 
8155
- const padding = _ => {
8156
- const node = new mathMLTree.MathNode("mspace");
8157
- node.setAttribute("width", "3pt");
8158
- return node
8159
- };
8160
-
8161
8145
  const mathmlBuilder$7 = (group, style) => {
8162
- let node;
8163
- if (group.label.indexOf("colorbox") > -1 || group.label === "\\boxed") {
8164
- // MathML core does not support +width attribute in <mpadded>.
8165
- // Firefox does not reliably add side padding.
8166
- // Insert <mspace>
8167
- node = new mathMLTree.MathNode("mrow", [
8168
- padding(),
8169
- buildGroup$1(group.body, style),
8170
- padding()
8171
- ]);
8172
- } else {
8173
- node = new mathMLTree.MathNode("menclose", [buildGroup$1(group.body, style)]);
8174
- }
8146
+ const node = new mathMLTree.MathNode("menclose", [buildGroup$1(group.body, style)]);
8175
8147
  switch (group.label) {
8176
8148
  case "\\overline":
8177
8149
  node.setAttribute("notation", "top"); // for Firefox & WebKit
@@ -8219,7 +8191,7 @@ const mathmlBuilder$7 = (group, style) => {
8219
8191
  case "\\boxed":
8220
8192
  // \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} from amsmath.sty
8221
8193
  node.setAttribute("notation", "box");
8222
- node.style.padding = "padding: 3pt 0 3pt 0";
8194
+ node.style.padding = "3pt";
8223
8195
  node.style.border = "1px solid";
8224
8196
  node.setAttribute("scriptlevel", "0");
8225
8197
  node.setAttribute("displaystyle", "true");
@@ -8236,12 +8208,10 @@ const mathmlBuilder$7 = (group, style) => {
8236
8208
  //const fboxsep = 3; // 3 pt from LaTeX source2e
8237
8209
  //node.setAttribute("height", `+${2 * fboxsep}pt`)
8238
8210
  //node.setAttribute("voffset", `${fboxsep}pt`)
8239
- const style = { padding: "3pt 0 3pt 0" };
8240
-
8211
+ node.style.padding = "3pt";
8241
8212
  if (group.label === "\\fcolorbox") {
8242
- style.border = "0.0667em solid " + String(group.borderColor);
8213
+ node.style.border = "0.0667em solid " + String(group.borderColor);
8243
8214
  }
8244
- node.style = style;
8245
8215
  break
8246
8216
  }
8247
8217
  }
@@ -9384,7 +9354,7 @@ defineFunction({
9384
9354
  const phantomInner = buildExpression(ordargument(group.body), style);
9385
9355
  const phantom = new mathMLTree.MathNode("mphantom", phantomInner);
9386
9356
  strut = new mathMLTree.MathNode("mpadded", [phantom]);
9387
- strut.setAttribute("width", "0px");
9357
+ strut.setAttribute("width", "0.1px"); // Don't use 0. WebKit would hide it.
9388
9358
  }
9389
9359
 
9390
9360
  const inner = buildGroup$1(group.body, style);
@@ -9413,7 +9383,7 @@ defineFunction({
9413
9383
  node.style.justifyContent = "center";
9414
9384
  }
9415
9385
  }
9416
- node.setAttribute("width", "0px");
9386
+ node.setAttribute("width", "0.1px"); // Don't use 0. WebKit would hide it.
9417
9387
  return node
9418
9388
  }
9419
9389
  });
@@ -9531,17 +9501,17 @@ function mathmlBuilder$3(group, style) {
9531
9501
  if (doSpacing ) {
9532
9502
  if (group.mclass === "mbin") {
9533
9503
  // medium space
9534
- node.children.unshift(padding$1(0.2222));
9535
- node.children.push(padding$1(0.2222));
9504
+ node.children.unshift(padding(0.2222));
9505
+ node.children.push(padding(0.2222));
9536
9506
  } else if (group.mclass === "mrel") {
9537
9507
  // thickspace
9538
- node.children.unshift(padding$1(0.2778));
9539
- node.children.push(padding$1(0.2778));
9508
+ node.children.unshift(padding(0.2778));
9509
+ node.children.push(padding(0.2778));
9540
9510
  } else if (group.mclass === "mpunct") {
9541
- node.children.push(padding$1(0.1667));
9511
+ node.children.push(padding(0.1667));
9542
9512
  } else if (group.mclass === "minner") {
9543
- node.children.unshift(padding$1(0.0556)); // 1 mu is the most likely option
9544
- node.children.push(padding$1(0.0556));
9513
+ node.children.unshift(padding(0.0556)); // 1 mu is the most likely option
9514
+ node.children.push(padding(0.0556));
9545
9515
  }
9546
9516
  }
9547
9517
  } else {
@@ -10789,6 +10759,11 @@ defineFunction({
10789
10759
  }
10790
10760
  });
10791
10761
 
10762
+ // Letters that are x-height w/o a descender.
10763
+ const xHeights = ['a', 'c', 'e', 'ı', 'm', 'n', 'o', 'r', 's', 'u', 'v', 'w', 'x', 'z', 'α',
10764
+ 'ε', 'ι', 'κ', 'ν', 'ο', 'π', 'σ', 'τ', 'υ', 'ω', '\\alpha', '\\epsilon', "\\iota",
10765
+ '\\kappa', '\\nu', '\\omega', '\\pi', '\\tau', '\\omega'];
10766
+
10792
10767
  defineFunction({
10793
10768
  type: "sqrt",
10794
10769
  names: ["\\sqrt"],
@@ -10799,6 +10774,20 @@ defineFunction({
10799
10774
  handler({ parser }, args, optArgs) {
10800
10775
  const index = optArgs[0];
10801
10776
  const body = args[0];
10777
+ // Check if the body consists entirely of an x-height letter.
10778
+ // TODO: Remove this check after Chromium is fixed.
10779
+ if (body.body && body.body.length === 1 && body.body[0].text &&
10780
+ xHeights.includes(body.body[0].text)) {
10781
+ // Chromium does not put enough space above an x-height letter.
10782
+ // Insert a strut.
10783
+ body.body.push({
10784
+ "type": "rule",
10785
+ "mode": "math",
10786
+ "shift": null,
10787
+ "width": { "number": 0, "unit": "pt" },
10788
+ "height": { "number": 0.5, "unit": "em" }
10789
+ });
10790
+ }
10802
10791
  return {
10803
10792
  type: "sqrt",
10804
10793
  mode: parser.mode,
@@ -11086,10 +11075,10 @@ defineFunctionBuilders({
11086
11075
  } else if (group.needsSpacing) {
11087
11076
  // Fix a MathML bug that occurs when a <mo> is between two <mtext> elements.
11088
11077
  if (group.family === "bin") {
11089
- return new mathMLTree.MathNode("mrow", [padding$1(0.222), node, padding$1(0.222)])
11078
+ return new mathMLTree.MathNode("mrow", [padding(0.222), node, padding(0.222)])
11090
11079
  } else {
11091
11080
  // REL spacing
11092
- return new mathMLTree.MathNode("mrow", [padding$1(0.2778), node, padding$1(0.2778)])
11081
+ return new mathMLTree.MathNode("mrow", [padding(0.2778), node, padding(0.2778)])
11093
11082
  }
11094
11083
  }
11095
11084
  return node;
@@ -14022,7 +14011,7 @@ class Style {
14022
14011
  * https://mit-license.org/
14023
14012
  */
14024
14013
 
14025
- const version = "0.11.09";
14014
+ const version = "0.11.11";
14026
14015
 
14027
14016
  function postProcess(block) {
14028
14017
  const labelMap = {};