temml 0.11.3 → 0.11.4

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
@@ -6464,7 +6464,7 @@ const mathmlBuilder$9 = function(group, style) {
6464
6464
  const numColumns = group.body[0].length;
6465
6465
  // Fill out a short row with empty <mtd> elements.
6466
6466
  for (let k = 0; k < numColumns - rw.length; k++) {
6467
- row.push(new mathMLTree.MathNode("mtd", [], style));
6467
+ row.push(new mathMLTree.MathNode("mtd", [], [], style));
6468
6468
  }
6469
6469
  if (group.autoTag) {
6470
6470
  const tag = group.tags[i];
@@ -6924,7 +6924,9 @@ defineEnvironment({
6924
6924
  }
6925
6925
  }
6926
6926
  const res = parseArray(context.parser, payload, "text");
6927
- res.cols = new Array(res.body[0].length).fill({ type: "align", align: colAlign });
6927
+ res.cols = res.body.length > 0
6928
+ ? new Array(res.body[0].length).fill({ type: "align", align: colAlign })
6929
+ : [];
6928
6930
  const [arraystretch, arraycolsep] = arrayGaps(context.parser.gullet.macros);
6929
6931
  res.arraystretch = arraystretch;
6930
6932
  if (arraycolsep && !(arraycolsep === 6 && arraycolsep === "pt")) {
@@ -6953,7 +6955,9 @@ defineEnvironment({
6953
6955
  handler(context) {
6954
6956
  const payload = { cols: [], envClasses: ["bordermatrix"] };
6955
6957
  const res = parseArray(context.parser, payload, "text");
6956
- res.cols = new Array(res.body[0].length).fill({ type: "align", align: "c" });
6958
+ res.cols = res.body.length > 0
6959
+ ? new Array(res.body[0].length).fill({ type: "align", align: "c" })
6960
+ : [];
6957
6961
  res.envClasses = [];
6958
6962
  res.arraystretch = 1;
6959
6963
  if (context.envName === "matrix") { return res}
@@ -7387,6 +7391,9 @@ const mathmlBuilder$8 = (group, style) => {
7387
7391
  // So instead of wrapping the group in an <mstyle>, we apply
7388
7392
  // the color individually to each node and return a document fragment.
7389
7393
  let expr = buildExpression(group.body, style.withColor(group.color));
7394
+ if (expr.length === 0) {
7395
+ expr.push(new mathMLTree.MathNode("mrow"));
7396
+ }
7390
7397
  expr = expr.map(e => {
7391
7398
  e.style.color = group.color;
7392
7399
  return e
@@ -8473,17 +8480,20 @@ const mathmlBuilder$6 = (group, style) => {
8473
8480
  // Check if it is possible to consolidate elements into a single <mi> element.
8474
8481
  if (isLongVariableName(group, font)) {
8475
8482
  // This is a \mathrm{…} group. It gets special treatment because symbolsOrd.js
8476
- // wraps <mi> elements with <mrow>s to work around a Firefox bug.
8477
- const mi = mathGroup.children[0].children[0];
8483
+ // wraps <mi> elements with <mpadded>s to work around a Firefox bug.
8484
+ const mi = mathGroup.children[0].children[0].children
8485
+ ? mathGroup.children[0].children[0]
8486
+ : mathGroup.children[0];
8478
8487
  delete mi.attributes.mathvariant;
8479
8488
  for (let i = 1; i < mathGroup.children.length; i++) {
8480
8489
  mi.children[0].text += mathGroup.children[i].children[0].children
8481
8490
  ? mathGroup.children[i].children[0].children[0].text
8482
8491
  : mathGroup.children[i].children[0].text;
8483
8492
  }
8484
- // Wrap in a <mrow> to prevent the same Firefox bug.
8485
- const bogus = new mathMLTree.MathNode("mtext", new mathMLTree.TextNode("\u200b"));
8486
- return new mathMLTree.MathNode("mrow", [bogus, mi])
8493
+ // Wrap in a <mpadded> to prevent the same Firefox bug.
8494
+ const mpadded = new mathMLTree.MathNode("mpadded", [mi]);
8495
+ mpadded.setAttribute("lspace", "0");
8496
+ return mpadded
8487
8497
  }
8488
8498
  let canConsolidate = mathGroup.children[0].type === "mo";
8489
8499
  for (let i = 1; i < mathGroup.children.length; i++) {
@@ -13951,7 +13961,7 @@ class Style {
13951
13961
  * https://mit-license.org/
13952
13962
  */
13953
13963
 
13954
- const version = "0.11.03";
13964
+ const version = "0.11.04";
13955
13965
 
13956
13966
  function postProcess(block) {
13957
13967
  const labelMap = {};
@@ -11,7 +11,7 @@
11
11
  * https://mit-license.org/
12
12
  */
13
13
 
14
- const version = "0.11.03";
14
+ const version = "0.11.04";
15
15
 
16
16
  function postProcess(block) {
17
17
  const labelMap = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "temml",
3
- "version": "0.11.03",
3
+ "version": "0.11.04",
4
4
  "description": "TeX to MathML conversion in JavaScript.",
5
5
  "main": "dist/temml.js",
6
6
  "engines": {
@@ -295,7 +295,7 @@ const mathmlBuilder = function(group, style) {
295
295
  const numColumns = group.body[0].length
296
296
  // Fill out a short row with empty <mtd> elements.
297
297
  for (let k = 0; k < numColumns - rw.length; k++) {
298
- row.push(new mathMLTree.MathNode("mtd", [], style))
298
+ row.push(new mathMLTree.MathNode("mtd", [], [], style))
299
299
  }
300
300
  if (group.autoTag) {
301
301
  const tag = group.tags[i];
@@ -757,7 +757,9 @@ defineEnvironment({
757
757
  }
758
758
  }
759
759
  const res = parseArray(context.parser, payload, "text")
760
- res.cols = new Array(res.body[0].length).fill({ type: "align", align: colAlign })
760
+ res.cols = res.body.length > 0
761
+ ? new Array(res.body[0].length).fill({ type: "align", align: colAlign })
762
+ : [];
761
763
  const [arraystretch, arraycolsep] = arrayGaps(context.parser.gullet.macros)
762
764
  res.arraystretch = arraystretch
763
765
  if (arraycolsep && !(arraycolsep === 6 && arraycolsep === "pt")) {
@@ -786,7 +788,9 @@ defineEnvironment({
786
788
  handler(context) {
787
789
  const payload = { cols: [], envClasses: ["bordermatrix"] }
788
790
  const res = parseArray(context.parser, payload, "text")
789
- res.cols = new Array(res.body[0].length).fill({ type: "align", align: "c" })
791
+ res.cols = res.body.length > 0
792
+ ? new Array(res.body[0].length).fill({ type: "align", align: "c" })
793
+ : [];
790
794
  res.envClasses = [];
791
795
  res.arraystretch = 1
792
796
  if (context.envName === "matrix") { return res}
@@ -156,6 +156,9 @@ const mathmlBuilder = (group, style) => {
156
156
  // So instead of wrapping the group in an <mstyle>, we apply
157
157
  // the color individually to each node and return a document fragment.
158
158
  let expr = mml.buildExpression(group.body, style.withColor(group.color))
159
+ if (expr.length === 0) {
160
+ expr.push(new mathMLTree.MathNode("mrow"))
161
+ }
159
162
  expr = expr.map(e => {
160
163
  e.style.color = group.color
161
164
  return e
@@ -30,17 +30,20 @@ const mathmlBuilder = (group, style) => {
30
30
  // Check if it is possible to consolidate elements into a single <mi> element.
31
31
  if (isLongVariableName(group, font)) {
32
32
  // This is a \mathrm{…} group. It gets special treatment because symbolsOrd.js
33
- // wraps <mi> elements with <mrow>s to work around a Firefox bug.
34
- const mi = mathGroup.children[0].children[0];
33
+ // wraps <mi> elements with <mpadded>s to work around a Firefox bug.
34
+ const mi = mathGroup.children[0].children[0].children
35
+ ? mathGroup.children[0].children[0]
36
+ : mathGroup.children[0];
35
37
  delete mi.attributes.mathvariant
36
38
  for (let i = 1; i < mathGroup.children.length; i++) {
37
39
  mi.children[0].text += mathGroup.children[i].children[0].children
38
40
  ? mathGroup.children[i].children[0].children[0].text
39
41
  : mathGroup.children[i].children[0].text
40
42
  }
41
- // Wrap in a <mrow> to prevent the same Firefox bug.
42
- const bogus = new mathMLTree.MathNode("mtext", new mathMLTree.TextNode("\u200b"))
43
- return new mathMLTree.MathNode("mrow", [bogus, mi])
43
+ // Wrap in a <mpadded> to prevent the same Firefox bug.
44
+ const mpadded = new mathMLTree.MathNode("mpadded", [mi])
45
+ mpadded.setAttribute("lspace", "0")
46
+ return mpadded
44
47
  }
45
48
  let canConsolidate = mathGroup.children[0].type === "mo"
46
49
  for (let i = 1; i < mathGroup.children.length; i++) {
@@ -5,7 +5,7 @@
5
5
  * https://mit-license.org/
6
6
  */
7
7
 
8
- export const version = "0.11.03";
8
+ export const version = "0.11.04";
9
9
 
10
10
  export function postProcess(block) {
11
11
  const labelMap = {}