temml 0.10.13 → 0.10.14

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.
@@ -38,6 +38,10 @@ math {
38
38
  font-family: Asana Math, math;
39
39
  }
40
40
 
41
+ /* Next line is active in Firefox and Safari.
42
+ * Not in Chromium, which recognizes display: "block math" written inline. */
43
+ math.tml-display { display: block; }
44
+
41
45
  *.mathcal,
42
46
  mo.tml-prime {
43
47
  font-feature-settings: 'salt';
@@ -54,7 +58,7 @@ math > mrow {
54
58
  }
55
59
 
56
60
  /* Avoid flex-wrap in Firefox */
57
- @supports (-moz-appearance:meterbar) and (display:flex) {
61
+ @-moz-document url-prefix() {
58
62
  math { display: inline; }
59
63
  math > mrow { padding: 0 }
60
64
  }
@@ -179,7 +183,7 @@ mtr.tml-hline-dashed > mtd {
179
183
 
180
184
  /* MathML-Core does not support <menclose> attributes.
181
185
  * So Use background images for \cancel */
182
- menclose.cancel {
186
+ mrow.cancel {
183
187
  background:
184
188
  linear-gradient(to top left,
185
189
  rgba(0,0,0,0) 0%,
@@ -189,7 +193,7 @@ menclose.cancel {
189
193
  rgba(0,0,0,0) 100%);
190
194
  }
191
195
 
192
- menclose.bcancel {
196
+ mrow.bcancel {
193
197
  background:
194
198
  linear-gradient(to top right,
195
199
  rgba(0,0,0,0) 0%,
@@ -199,7 +203,7 @@ menclose.bcancel {
199
203
  rgba(0,0,0,0) 100%);
200
204
  }
201
205
 
202
- menclose.xcancel {
206
+ mrow.xcancel {
203
207
  background:
204
208
  linear-gradient(to top left,
205
209
  rgba(0,0,0,0) 0%,
@@ -44,6 +44,10 @@ math {
44
44
  font-family: "Latin Modern Math", "Times New Roman", math;
45
45
  }
46
46
 
47
+ /* Next line is active in Firefox and Safari.
48
+ * Not in Chromium, which recognizes display: "block math" written inline. */
49
+ math.tml-display { display: block; }
50
+
47
51
  *.mathscr {
48
52
  font-family: "Temml";
49
53
  }
@@ -63,7 +67,7 @@ math > mrow {
63
67
  }
64
68
 
65
69
  /* Avoid flex-wrap in Firefox */
66
- @supports (-moz-appearance:meterbar) and (display:flex) {
70
+ @-moz-document url-prefix() {
67
71
  math { display: inline; }
68
72
  math > mrow { padding: 0 }
69
73
  }
@@ -189,7 +193,7 @@ mtr.tml-hline-dashed > mtd {
189
193
 
190
194
  /* MathML-Core does not support <menclose> attributes.
191
195
  * So Use background images for \cancel */
192
- menclose.cancel {
196
+ mrow.cancel {
193
197
  background:
194
198
  linear-gradient(to top left,
195
199
  rgba(0,0,0,0) 0%,
@@ -199,7 +203,7 @@ menclose.cancel {
199
203
  rgba(0,0,0,0) 100%);
200
204
  }
201
205
 
202
- menclose.bcancel {
206
+ mrow.bcancel {
203
207
  background:
204
208
  linear-gradient(to top right,
205
209
  rgba(0,0,0,0) 0%,
@@ -209,7 +213,7 @@ menclose.bcancel {
209
213
  rgba(0,0,0,0) 100%);
210
214
  }
211
215
 
212
- menclose.xcancel {
216
+ mrow.xcancel {
213
217
  background:
214
218
  linear-gradient(to top left,
215
219
  rgba(0,0,0,0) 0%,
@@ -42,6 +42,10 @@ math {
42
42
  font-family: Libertinus Math, math;
43
43
  }
44
44
 
45
+ /* Next line is active in Firefox and Safari.
46
+ * Not in Chromium, which recognizes display: "block math" written inline. */
47
+ math.tml-display { display: block; }
48
+
45
49
  *.mathcal {
46
50
  font-family: "Cambria Math", 'STIXTwoMath-Regular', "Times New Roman", math;
47
51
  }
@@ -61,7 +65,7 @@ math > mrow {
61
65
  }
62
66
 
63
67
  /* Avoid flex-wrap in Firefox */
64
- @supports (-moz-appearance:meterbar) and (display:flex) {
68
+ @-moz-document url-prefix() {
65
69
  math { display: inline; }
66
70
  math > mrow { padding: 0 }
67
71
  }
@@ -187,7 +191,7 @@ mtr.tml-hline-dashed > mtd {
187
191
 
188
192
  /* MathML-Core does not support <menclose> attributes.
189
193
  * So Use background images for \cancel */
190
- menclose.cancel {
194
+ mrow.cancel {
191
195
  background:
192
196
  linear-gradient(to top left,
193
197
  rgba(0,0,0,0) 0%,
@@ -197,7 +201,7 @@ menclose.cancel {
197
201
  rgba(0,0,0,0) 100%);
198
202
  }
199
203
 
200
- menclose.bcancel {
204
+ mrow.bcancel {
201
205
  background:
202
206
  linear-gradient(to top right,
203
207
  rgba(0,0,0,0) 0%,
@@ -207,7 +211,7 @@ menclose.bcancel {
207
211
  rgba(0,0,0,0) 100%);
208
212
  }
209
213
 
210
- menclose.xcancel {
214
+ mrow.xcancel {
211
215
  background:
212
216
  linear-gradient(to top left,
213
217
  rgba(0,0,0,0) 0%,
@@ -28,6 +28,10 @@ math * {
28
28
  border-color: currentColor;
29
29
  }
30
30
 
31
+ /* Next line is active in Firefox and Safari.
32
+ * Not in Chromium, which recognizes display: "block math" written inline. */
33
+ math.tml-display { display: block; }
34
+
31
35
  math .mathscr {
32
36
  font-family: "Temml";
33
37
  }
@@ -47,7 +51,7 @@ math > mrow {
47
51
  }
48
52
 
49
53
  /* Avoid flex-wrap in Firefox */
50
- @supports (-moz-appearance:meterbar) and (display:flex) {
54
+ @-moz-document url-prefix() {
51
55
  math { display: inline; }
52
56
  math > mrow { padding: 0 }
53
57
  }
@@ -172,7 +176,7 @@ mtr.tml-hline-dashed > mtd {
172
176
 
173
177
  /* MathML-Core does not support <menclose> attributes.
174
178
  * So Use background images for \cancel */
175
- menclose.cancel {
179
+ mrow.cancel {
176
180
  background:
177
181
  linear-gradient(to top left,
178
182
  rgba(0,0,0,0) 0%,
@@ -182,7 +186,7 @@ menclose.cancel {
182
186
  rgba(0,0,0,0) 100%);
183
187
  }
184
188
 
185
- menclose.bcancel {
189
+ mrow.bcancel {
186
190
  background:
187
191
  linear-gradient(to top right,
188
192
  rgba(0,0,0,0) 0%,
@@ -192,7 +196,7 @@ menclose.bcancel {
192
196
  rgba(0,0,0,0) 100%);
193
197
  }
194
198
 
195
- menclose.xcancel {
199
+ mrow.xcancel {
196
200
  background:
197
201
  linear-gradient(to top left,
198
202
  rgba(0,0,0,0) 0%,
@@ -28,6 +28,10 @@ math * {
28
28
  border-color: currentColor;
29
29
  }
30
30
 
31
+ /* Next line is active in Firefox and Safari.
32
+ * Not in Chromium, which recognizes display: "block math" written inline. */
33
+ math.tml-display { display: block; }
34
+
31
35
  mtext {
32
36
  font-family: STIX2;
33
37
  }
@@ -55,7 +59,7 @@ math > mrow {
55
59
  }
56
60
 
57
61
  /* Avoid flex-wrap in Firefox */
58
- @supports (-moz-appearance:meterbar) and (display:flex) {
62
+ @-moz-document url-prefix() {
59
63
  math { display: inline; }
60
64
  math > mrow { padding: 0 }
61
65
  }
@@ -180,7 +184,7 @@ mtr.tml-hline-dashed > mtd {
180
184
 
181
185
  /* MathML-Core does not support <menclose> attributes.
182
186
  * So Use background images for \cancel */
183
- menclose.cancel {
187
+ mrow.cancel {
184
188
  background:
185
189
  linear-gradient(to top left,
186
190
  rgba(0,0,0,0) 0%,
@@ -190,7 +194,7 @@ menclose.cancel {
190
194
  rgba(0,0,0,0) 100%);
191
195
  }
192
196
 
193
- menclose.bcancel {
197
+ mrow.bcancel {
194
198
  background:
195
199
  linear-gradient(to top right,
196
200
  rgba(0,0,0,0) 0%,
@@ -200,7 +204,7 @@ menclose.bcancel {
200
204
  rgba(0,0,0,0) 100%);
201
205
  }
202
206
 
203
- menclose.xcancel {
207
+ mrow.xcancel {
204
208
  background:
205
209
  linear-gradient(to top left,
206
210
  rgba(0,0,0,0) 0%,
package/dist/temml.cjs CHANGED
@@ -1117,6 +1117,7 @@ defineSymbol(math, rel, "\u2ab7", "\\precapprox", true);
1117
1117
  defineSymbol(math, rel, "\u22b2", "\\vartriangleleft");
1118
1118
  defineSymbol(math, rel, "\u22b4", "\\trianglelefteq");
1119
1119
  defineSymbol(math, rel, "\u22a8", "\\vDash", true);
1120
+ defineSymbol(math, rel, "\u22ab", "\\VDash", true);
1120
1121
  defineSymbol(math, rel, "\u22aa", "\\Vvdash", true);
1121
1122
  defineSymbol(math, rel, "\u2323", "\\smallsmile");
1122
1123
  defineSymbol(math, rel, "\u2322", "\\smallfrown");
@@ -1766,13 +1767,16 @@ for (let i = 0; i < 10; i++) {
1766
1767
  * much of this module.
1767
1768
  */
1768
1769
 
1770
+ const openDelims = "([{⌊⌈⟨⟮⎰⟦⦃";
1771
+ const closeDelims = ")]}⌋⌉⟩⟯⎱⟦⦄";
1772
+
1769
1773
  function setLineBreaks(expression, wrapMode, isDisplayMode) {
1770
1774
  const mtrs = [];
1771
1775
  let mrows = [];
1772
1776
  let block = [];
1773
1777
  let numTopLevelEquals = 0;
1774
- let canBeBIN = false; // The first node cannot be an infix binary operator.
1775
1778
  let i = 0;
1779
+ let level = 0;
1776
1780
  while (i < expression.length) {
1777
1781
  while (expression[i] instanceof DocumentFragment) {
1778
1782
  expression.splice(i, 1, ...expression[i].children); // Expand the fragment.
@@ -1795,7 +1799,12 @@ function setLineBreaks(expression, wrapMode, isDisplayMode) {
1795
1799
  }
1796
1800
  block.push(node);
1797
1801
  if (node.type && node.type === "mo" && node.children.length === 1) {
1798
- if (wrapMode === "=" && node.children[0].text === "=") {
1802
+ const ch = node.children[0].text;
1803
+ if (openDelims.indexOf(ch) > -1) {
1804
+ level += 1;
1805
+ } else if (closeDelims.indexOf(ch) > -1) {
1806
+ level -= 1;
1807
+ } else if (level === 0 && wrapMode === "=" && ch === "=") {
1799
1808
  numTopLevelEquals += 1;
1800
1809
  if (numTopLevelEquals > 1) {
1801
1810
  block.pop();
@@ -1804,59 +1813,48 @@ function setLineBreaks(expression, wrapMode, isDisplayMode) {
1804
1813
  mrows.push(element);
1805
1814
  block = [node];
1806
1815
  }
1807
- } else if (wrapMode === "tex") {
1808
- // This may be a place for a soft line break.
1809
- if (canBeBIN && !node.attributes.form) {
1810
- // Check if the following node is a \nobreak text node, e.g. "~""
1811
- const next = i < expression.length - 1 ? expression[i + 1] : null;
1812
- let glueIsFreeOfNobreak = true;
1813
- if (
1814
- !(
1815
- next &&
1816
- next.type === "mtext" &&
1817
- next.attributes.linebreak &&
1818
- next.attributes.linebreak === "nobreak"
1819
- )
1820
- ) {
1821
- // We may need to start a new block.
1822
- // First, put any post-operator glue on same line as operator.
1823
- for (let j = i + 1; j < expression.length; j++) {
1824
- const nd = expression[j];
1816
+ } else if (level === 0 && wrapMode === "tex") {
1817
+ // Check if the following node is a \nobreak text node, e.g. "~""
1818
+ const next = i < expression.length - 1 ? expression[i + 1] : null;
1819
+ let glueIsFreeOfNobreak = true;
1820
+ if (
1821
+ !(
1822
+ next &&
1823
+ next.type === "mtext" &&
1824
+ next.attributes.linebreak &&
1825
+ next.attributes.linebreak === "nobreak"
1826
+ )
1827
+ ) {
1828
+ // We may need to start a new block.
1829
+ // First, put any post-operator glue on same line as operator.
1830
+ for (let j = i + 1; j < expression.length; j++) {
1831
+ const nd = expression[j];
1832
+ if (
1833
+ nd.type &&
1834
+ nd.type === "mspace" &&
1835
+ !(nd.attributes.linebreak && nd.attributes.linebreak === "newline")
1836
+ ) {
1837
+ block.push(nd);
1838
+ i += 1;
1825
1839
  if (
1826
- nd.type &&
1827
- nd.type === "mspace" &&
1828
- !(nd.attributes.linebreak && nd.attributes.linebreak === "newline")
1840
+ nd.attributes &&
1841
+ nd.attributes.linebreak &&
1842
+ nd.attributes.linebreak === "nobreak"
1829
1843
  ) {
1830
- block.push(nd);
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;
1844
+ glueIsFreeOfNobreak = false;
1841
1845
  }
1846
+ } else {
1847
+ break;
1842
1848
  }
1843
1849
  }
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
1850
  }
1852
- const isOpenDelimiter = node.attributes.form && node.attributes.form === "prefix";
1853
- // Any operator that follows an open delimiter is unary.
1854
- canBeBIN = !(node.attributes.separator || isOpenDelimiter);
1855
- } else {
1856
- canBeBIN = true;
1851
+ if (glueIsFreeOfNobreak) {
1852
+ // Start a new block. (Insert a soft linebreak.)
1853
+ const element = new mathMLTree.MathNode("mrow", block);
1854
+ mrows.push(element);
1855
+ block = [];
1856
+ }
1857
1857
  }
1858
- } else {
1859
- canBeBIN = true;
1860
1858
  }
1861
1859
  i += 1;
1862
1860
  }
@@ -2135,7 +2133,10 @@ function buildMathML(tree, texExpression, style, settings) {
2135
2133
  math.setAttribute("display", "block");
2136
2134
  math.style.display = math.children.length === 1 && math.children[0].type === "mtable"
2137
2135
  ? "inline"
2138
- : "block math";
2136
+ : "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"];
2139
2140
  }
2140
2141
  return math;
2141
2142
  }
@@ -3664,10 +3665,9 @@ defineFunction({
3664
3665
  // so we have to explicitly set stretchy to true.
3665
3666
  node.setAttribute("stretchy", "true");
3666
3667
  }
3667
-
3668
3668
  node.setAttribute("symmetric", "true"); // Needed for tall arrows in Firefox.
3669
3669
  node.setAttribute("minsize", sizeToMaxHeight[group.size] + "em");
3670
- // Don't set the maxsize attribute. It's broken in Chromium.
3670
+ node.setAttribute("maxsize", sizeToMaxHeight[group.size] + "em");
3671
3671
  return node;
3672
3672
  }
3673
3673
  });
@@ -3802,33 +3802,31 @@ const padding$1 = _ => {
3802
3802
 
3803
3803
  const mathmlBuilder$8 = (group, style) => {
3804
3804
  let node;
3805
- if (group.label.indexOf("colorbox") > -1) {
3806
- // Chrome mpadded +width attribute is broken. Insert <mspace>
3807
- 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", [
3808
3810
  padding$1(),
3809
3811
  buildGroup$1(group.body, style),
3810
3812
  padding$1()
3811
3813
  ]);
3812
3814
  } else {
3813
- node = new mathMLTree.MathNode("menclose", [buildGroup$1(group.body, style)]);
3815
+ node = new mathMLTree.MathNode("mrow", [buildGroup$1(group.body, style)]);
3814
3816
  }
3815
3817
  switch (group.label) {
3816
3818
  case "\\overline":
3817
- node.setAttribute("notation", "top");
3818
3819
  node.style.padding = "0.1em 0 0 0";
3819
3820
  node.style.borderTop = "0.065em solid";
3820
3821
  break
3821
3822
  case "\\underline":
3822
- node.setAttribute("notation", "bottom");
3823
3823
  node.style.padding = "0 0 0.1em 0";
3824
3824
  node.style.borderBottom = "0.065em solid";
3825
3825
  break
3826
3826
  case "\\cancel":
3827
- node.setAttribute("notation", "updiagonalstrike");
3828
3827
  node.classes.push("cancel");
3829
3828
  break
3830
3829
  case "\\bcancel":
3831
- node.setAttribute("notation", "downdiagonalstrike");
3832
3830
  node.classes.push("bcancel");
3833
3831
  break
3834
3832
  /*
@@ -3839,18 +3837,21 @@ const mathmlBuilder$8 = (group, style) => {
3839
3837
  node.setAttribute("notation", "phasorangle");
3840
3838
  break */
3841
3839
  case "\\angl":
3842
- node.setAttribute("notation", "actuarial");
3843
3840
  node.style.padding = "0.03889em 0.03889em 0 0.03889em";
3844
3841
  node.style.borderTop = "0.049em solid";
3845
3842
  node.style.borderRight = "0.049em solid";
3846
3843
  node.style.marginRight = "0.03889em";
3847
3844
  break
3848
3845
  case "\\sout":
3849
- node.setAttribute("notation", "horizontalstrike");
3850
3846
  node.style["text-decoration"] = "line-through 0.08em solid";
3851
3847
  break
3848
+ case "\\boxed":
3849
+ // \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} from amsmath.sty
3850
+ node.style = { padding: "3pt 0 3pt 0", border: "1px solid" };
3851
+ node.setAttribute("scriptlevel", "0");
3852
+ node.setAttribute("displaystyle", "true");
3853
+ break
3852
3854
  case "\\fbox":
3853
- node.setAttribute("notation", "box");
3854
3855
  node.style = { padding: "3pt", border: "1px solid" };
3855
3856
  break
3856
3857
  case "\\fcolorbox":
@@ -3870,7 +3871,6 @@ const mathmlBuilder$8 = (group, style) => {
3870
3871
  break
3871
3872
  }
3872
3873
  case "\\xcancel":
3873
- node.setAttribute("notation", "updiagonalstrike downdiagonalstrike");
3874
3874
  node.classes.push("xcancel");
3875
3875
  break
3876
3876
  }
@@ -3965,7 +3965,7 @@ defineFunction({
3965
3965
 
3966
3966
  defineFunction({
3967
3967
  type: "enclose",
3968
- names: ["\\angl", "\\cancel", "\\bcancel", "\\xcancel", "\\sout", "\\overline"],
3968
+ names: ["\\angl", "\\cancel", "\\bcancel", "\\xcancel", "\\sout", "\\overline", "\\boxed"],
3969
3969
  // , "\\phase", "\\longdiv"
3970
3970
  props: {
3971
3971
  numArgs: 1
@@ -6831,8 +6831,6 @@ defineFunction({
6831
6831
  }
6832
6832
  });
6833
6833
 
6834
- const sign = num => num >= 0 ? "+" : "-";
6835
-
6836
6834
  // \raise, \lower, and \raisebox
6837
6835
 
6838
6836
  const mathmlBuilder = (group, style) => {
@@ -6840,11 +6838,13 @@ const mathmlBuilder = (group, style) => {
6840
6838
  const node = new mathMLTree.MathNode("mpadded", [buildGroup$1(group.body, newStyle)]);
6841
6839
  const dy = calculateSize(group.dy, style);
6842
6840
  node.setAttribute("voffset", dy.number + dy.unit);
6843
- const dyAbs = Math.abs(dy.number);
6844
- // The next two lines do not work in Chromium.
6845
- // TODO: Find some other way to adjust height and depth.
6846
- node.setAttribute("height", sign(dy.number) + dyAbs + dy.unit);
6847
- node.setAttribute("depth", sign(-dy.number) + dyAbs + dy.unit);
6841
+ // Add padding, which acts to increase height in Chromium.
6842
+ // TODO: Figure out some way to change height in Firefox w/o breaking Chromium.
6843
+ if (dy.number > 0) {
6844
+ node.style.padding = dy.number + dy.unit + " 0 0 0";
6845
+ } else {
6846
+ node.style.padding = "0 0 " + Math.abs(dy.number) + dy.unit + " 0";
6847
+ }
6848
6848
  return node
6849
6849
  };
6850
6850
 
@@ -8473,9 +8473,6 @@ defineMacro("\u22ee", "\\vdots");
8473
8473
  //\newcommand{\substack}[1]{\subarray{c}#1\endsubarray}
8474
8474
  defineMacro("\\substack", "\\begin{subarray}{c}#1\\end{subarray}");
8475
8475
 
8476
- // \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}}
8477
- defineMacro("\\boxed", "\\fbox{$\\displaystyle{#1}$}");
8478
-
8479
8476
  // \def\iff{\DOTSB\;\Longleftrightarrow\;}
8480
8477
  // \def\implies{\DOTSB\;\Longrightarrow\;}
8481
8478
  // \def\impliedby{\DOTSB\;\Longleftarrow\;}
@@ -8724,7 +8721,7 @@ defineMacro(
8724
8721
  defineMacro(
8725
8722
  "\\Temml",
8726
8723
  // 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}}"
8724
+ "\\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
8725
  );
8729
8726
 
8730
8727
  // \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace}
@@ -12904,7 +12901,7 @@ class Style {
12904
12901
  * https://mit-license.org/
12905
12902
  */
12906
12903
 
12907
- const version = "0.10.13";
12904
+ const version = "0.10.14";
12908
12905
 
12909
12906
  function postProcess(block) {
12910
12907
  const labelMap = {};