temml 0.10.29 → 0.10.30

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
@@ -3389,6 +3389,7 @@ defineFunction({
3389
3389
  type: "color",
3390
3390
  mode: parser.mode,
3391
3391
  color,
3392
+ isTextColor: true,
3392
3393
  body: ordargument(body)
3393
3394
  }
3394
3395
  },
@@ -3421,6 +3422,7 @@ defineFunction({
3421
3422
  type: "color",
3422
3423
  mode: parser.mode,
3423
3424
  color,
3425
+ isTextColor: false,
3424
3426
  body
3425
3427
  }
3426
3428
  },
@@ -3864,10 +3866,8 @@ function checkDelimiter(delim, context) {
3864
3866
  if (symDelim && delimiters.includes(symDelim.text)) {
3865
3867
  // If a character is not in the MathML operator dictionary, it will not stretch.
3866
3868
  // Replace such characters w/characters that will stretch.
3867
- if (["/", "\u2044"].includes(symDelim.text)) { symDelim.text = "\u2215"; }
3868
3869
  if (["<", "\\lt"].includes(symDelim.text)) { symDelim.text = "⟨"; }
3869
3870
  if ([">", "\\gt"].includes(symDelim.text)) { symDelim.text = "⟩"; }
3870
- if (symDelim.text === "\\backslash") { symDelim.text = "\u2216"; }
3871
3871
  return symDelim;
3872
3872
  } else if (symDelim) {
3873
3873
  throw new ParseError(`Invalid delimiter '${symDelim.text}' after '${context.funcName}'`, delim);
@@ -3876,6 +3876,9 @@ function checkDelimiter(delim, context) {
3876
3876
  }
3877
3877
  }
3878
3878
 
3879
+ // / \
3880
+ const needExplicitStretch = ["\u002F", "\u005C", "\\backslash", "\\vert", "|"];
3881
+
3879
3882
  defineFunction({
3880
3883
  type: "delimsizing",
3881
3884
  names: [
@@ -3928,8 +3931,7 @@ defineFunction({
3928
3931
  // defaults.
3929
3932
  node.setAttribute("fence", "false");
3930
3933
  }
3931
- if (group.delim === "\u2216" || group.delim === "\\vert" ||
3932
- group.delim === "|" || group.delim.indexOf("arrow") > -1) {
3934
+ if (needExplicitStretch.includes(group.delim) || group.delim.indexOf("arrow") > -1) {
3933
3935
  // We have to explicitly set stretchy to true.
3934
3936
  node.setAttribute("stretchy", "true");
3935
3937
  }
@@ -4015,7 +4017,7 @@ defineFunction({
4015
4017
  const leftNode = new mathMLTree.MathNode("mo", [makeText(group.left, group.mode)]);
4016
4018
  leftNode.setAttribute("fence", "true");
4017
4019
  leftNode.setAttribute("form", "prefix");
4018
- if (group.left === "\u2216" || group.left.indexOf("arrow") > -1) {
4020
+ if (group.left === "/" || group.left === "\u005C" || group.left.indexOf("arrow") > -1) {
4019
4021
  leftNode.setAttribute("stretchy", "true");
4020
4022
  }
4021
4023
  inner.unshift(leftNode);
@@ -4027,6 +4029,15 @@ defineFunction({
4027
4029
  if (group.right === "\u2216" || group.right.indexOf("arrow") > -1) {
4028
4030
  rightNode.setAttribute("stretchy", "true");
4029
4031
  }
4032
+ if (group.body.length > 0) {
4033
+ const lastElement = group.body[group.body.length - 1];
4034
+ if (lastElement.type === "color" && !lastElement.isTextColor) {
4035
+ // \color is a switch. If the last element is of type "color" then
4036
+ // the user set the \color switch and left it on.
4037
+ // A \right delimiter turns the switch off, but the delimiter itself gets the color.
4038
+ rightNode.setAttribute("mathcolor", lastElement.color);
4039
+ }
4040
+ }
4030
4041
  inner.push(rightNode);
4031
4042
 
4032
4043
  return makeRow(inner);
@@ -13489,7 +13500,7 @@ class Style {
13489
13500
  * https://mit-license.org/
13490
13501
  */
13491
13502
 
13492
- const version = "0.10.29";
13503
+ const version = "0.10.30";
13493
13504
 
13494
13505
  function postProcess(block) {
13495
13506
  const labelMap = {};
@@ -14,7 +14,7 @@
14
14
  * https://mit-license.org/
15
15
  */
16
16
 
17
- const version = "0.10.29";
17
+ const version = "0.10.30";
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.29",
3
+ "version": "0.10.30",
4
4
  "description": "TeX to MathML conversion in JavaScript.",
5
5
  "main": "dist/temml.js",
6
6
  "engines": {
@@ -29,12 +29,12 @@
29
29
  "license": "MIT",
30
30
  "devDependencies": {
31
31
  "@eslint/eslintrc": "^3.1.0",
32
- "@eslint/js": "^9.9.0",
33
- "eslint": "^9.9.0",
32
+ "@eslint/js": "^9.11.1",
33
+ "eslint": "^9.11.1",
34
34
  "esm": "^3.2.25",
35
35
  "globals": "^15.9.0",
36
- "rollup": "^4.20.0",
37
- "terser": "^5.31.6"
36
+ "rollup": "^4.22.4",
37
+ "terser": "^5.34.0"
38
38
  },
39
39
  "scripts": {
40
40
  "lint": "eslint temml.js src",
@@ -186,6 +186,7 @@ defineFunction({
186
186
  type: "color",
187
187
  mode: parser.mode,
188
188
  color,
189
+ isTextColor: true,
189
190
  body: ordargument(body)
190
191
  }
191
192
  },
@@ -218,6 +219,7 @@ defineFunction({
218
219
  type: "color",
219
220
  mode: parser.mode,
220
221
  color,
222
+ isTextColor: false,
221
223
  body
222
224
  }
223
225
  },
@@ -118,10 +118,8 @@ function checkDelimiter(delim, context) {
118
118
  if (symDelim && delimiters.includes(symDelim.text)) {
119
119
  // If a character is not in the MathML operator dictionary, it will not stretch.
120
120
  // Replace such characters w/characters that will stretch.
121
- if (["/", "\u2044"].includes(symDelim.text)) { symDelim.text = "\u2215" }
122
121
  if (["<", "\\lt"].includes(symDelim.text)) { symDelim.text = "⟨" }
123
122
  if ([">", "\\gt"].includes(symDelim.text)) { symDelim.text = "⟩" }
124
- if (symDelim.text === "\\backslash") { symDelim.text = "\u2216" }
125
123
  return symDelim;
126
124
  } else if (symDelim) {
127
125
  throw new ParseError(`Invalid delimiter '${symDelim.text}' after '${context.funcName}'`, delim);
@@ -130,6 +128,9 @@ function checkDelimiter(delim, context) {
130
128
  }
131
129
  }
132
130
 
131
+ // / \
132
+ const needExplicitStretch = ["\u002F", "\u005C", "\\backslash", "\\vert", "|"];
133
+
133
134
  defineFunction({
134
135
  type: "delimsizing",
135
136
  names: [
@@ -182,8 +183,7 @@ defineFunction({
182
183
  // defaults.
183
184
  node.setAttribute("fence", "false");
184
185
  }
185
- if (group.delim === "\u2216" || group.delim === "\\vert" ||
186
- group.delim === "|" || group.delim.indexOf("arrow") > -1) {
186
+ if (needExplicitStretch.includes(group.delim) || group.delim.indexOf("arrow") > -1) {
187
187
  // We have to explicitly set stretchy to true.
188
188
  node.setAttribute("stretchy", "true")
189
189
  }
@@ -269,7 +269,7 @@ defineFunction({
269
269
  const leftNode = new mathMLTree.MathNode("mo", [mml.makeText(group.left, group.mode)]);
270
270
  leftNode.setAttribute("fence", "true")
271
271
  leftNode.setAttribute("form", "prefix")
272
- if (group.left === "\u2216" || group.left.indexOf("arrow") > -1) {
272
+ if (group.left === "/" || group.left === "\u005C" || group.left.indexOf("arrow") > -1) {
273
273
  leftNode.setAttribute("stretchy", "true")
274
274
  }
275
275
  inner.unshift(leftNode)
@@ -281,6 +281,15 @@ defineFunction({
281
281
  if (group.right === "\u2216" || group.right.indexOf("arrow") > -1) {
282
282
  rightNode.setAttribute("stretchy", "true")
283
283
  }
284
+ if (group.body.length > 0) {
285
+ const lastElement = group.body[group.body.length - 1];
286
+ if (lastElement.type === "color" && !lastElement.isTextColor) {
287
+ // \color is a switch. If the last element is of type "color" then
288
+ // the user set the \color switch and left it on.
289
+ // A \right delimiter turns the switch off, but the delimiter itself gets the color.
290
+ rightNode.setAttribute("mathcolor", lastElement.color);
291
+ }
292
+ }
284
293
  inner.push(rightNode)
285
294
 
286
295
  return mml.makeRow(inner);
@@ -8,7 +8,7 @@
8
8
  * https://mit-license.org/
9
9
  */
10
10
 
11
- export const version = "0.10.29";
11
+ export const version = "0.10.30";
12
12
 
13
13
  export function postProcess(block) {
14
14
  const labelMap = {}