temml 0.10.29 → 0.10.30

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  | Library | Minified JavaScript + CSS |
4
4
  |:--------------|:-------------------------:|
5
- | Temml | 157 KB |
5
+ | Temml | 158 KB |
6
6
  | MathJax 2.7.5 | 338 KB |
7
7
  | KaTeX | 280 KB |
8
8
  | TeXZilla | 168 KB |
9
9
 
10
10
  As a futher advantage, Temml can use local system fonts. The minimum Temml installation serves a font file that is only 10kb. Sadly, Chromium has some rendering bugs when using system fonts. It
11
- work better with the Latin Modern font, a 380 KB file.
11
+ works better with the Latin Modern font, a 380 KB file.
12
12
 
13
13
  Temml’s coverage of LaTeX functions is as good as MathJax, slightly better than KaTeX 0.16.0 and substantially better than TeXZilla. See a [detailed coverage comparison](https://temml.org/docs/en/comparison.html).
14
14
 
package/dist/temml.cjs CHANGED
@@ -3391,6 +3391,7 @@ defineFunction({
3391
3391
  type: "color",
3392
3392
  mode: parser.mode,
3393
3393
  color,
3394
+ isTextColor: true,
3394
3395
  body: ordargument(body)
3395
3396
  }
3396
3397
  },
@@ -3423,6 +3424,7 @@ defineFunction({
3423
3424
  type: "color",
3424
3425
  mode: parser.mode,
3425
3426
  color,
3427
+ isTextColor: false,
3426
3428
  body
3427
3429
  }
3428
3430
  },
@@ -3866,10 +3868,8 @@ function checkDelimiter(delim, context) {
3866
3868
  if (symDelim && delimiters.includes(symDelim.text)) {
3867
3869
  // If a character is not in the MathML operator dictionary, it will not stretch.
3868
3870
  // Replace such characters w/characters that will stretch.
3869
- if (["/", "\u2044"].includes(symDelim.text)) { symDelim.text = "\u2215"; }
3870
3871
  if (["<", "\\lt"].includes(symDelim.text)) { symDelim.text = "⟨"; }
3871
3872
  if ([">", "\\gt"].includes(symDelim.text)) { symDelim.text = "⟩"; }
3872
- if (symDelim.text === "\\backslash") { symDelim.text = "\u2216"; }
3873
3873
  return symDelim;
3874
3874
  } else if (symDelim) {
3875
3875
  throw new ParseError(`Invalid delimiter '${symDelim.text}' after '${context.funcName}'`, delim);
@@ -3878,6 +3878,9 @@ function checkDelimiter(delim, context) {
3878
3878
  }
3879
3879
  }
3880
3880
 
3881
+ // / \
3882
+ const needExplicitStretch = ["\u002F", "\u005C", "\\backslash", "\\vert", "|"];
3883
+
3881
3884
  defineFunction({
3882
3885
  type: "delimsizing",
3883
3886
  names: [
@@ -3930,8 +3933,7 @@ defineFunction({
3930
3933
  // defaults.
3931
3934
  node.setAttribute("fence", "false");
3932
3935
  }
3933
- if (group.delim === "\u2216" || group.delim === "\\vert" ||
3934
- group.delim === "|" || group.delim.indexOf("arrow") > -1) {
3936
+ if (needExplicitStretch.includes(group.delim) || group.delim.indexOf("arrow") > -1) {
3935
3937
  // We have to explicitly set stretchy to true.
3936
3938
  node.setAttribute("stretchy", "true");
3937
3939
  }
@@ -4017,7 +4019,7 @@ defineFunction({
4017
4019
  const leftNode = new mathMLTree.MathNode("mo", [makeText(group.left, group.mode)]);
4018
4020
  leftNode.setAttribute("fence", "true");
4019
4021
  leftNode.setAttribute("form", "prefix");
4020
- if (group.left === "\u2216" || group.left.indexOf("arrow") > -1) {
4022
+ if (group.left === "/" || group.left === "\u005C" || group.left.indexOf("arrow") > -1) {
4021
4023
  leftNode.setAttribute("stretchy", "true");
4022
4024
  }
4023
4025
  inner.unshift(leftNode);
@@ -4029,6 +4031,15 @@ defineFunction({
4029
4031
  if (group.right === "\u2216" || group.right.indexOf("arrow") > -1) {
4030
4032
  rightNode.setAttribute("stretchy", "true");
4031
4033
  }
4034
+ if (group.body.length > 0) {
4035
+ const lastElement = group.body[group.body.length - 1];
4036
+ if (lastElement.type === "color" && !lastElement.isTextColor) {
4037
+ // \color is a switch. If the last element is of type "color" then
4038
+ // the user set the \color switch and left it on.
4039
+ // A \right delimiter turns the switch off, but the delimiter itself gets the color.
4040
+ rightNode.setAttribute("mathcolor", lastElement.color);
4041
+ }
4042
+ }
4032
4043
  inner.push(rightNode);
4033
4044
 
4034
4045
  return makeRow(inner);
@@ -13491,7 +13502,7 @@ class Style {
13491
13502
  * https://mit-license.org/
13492
13503
  */
13493
13504
 
13494
- const version = "0.10.29";
13505
+ const version = "0.10.30";
13495
13506
 
13496
13507
  function postProcess(block) {
13497
13508
  const labelMap = {};
package/dist/temml.js CHANGED
@@ -3392,6 +3392,7 @@ var temml = (function () {
3392
3392
  type: "color",
3393
3393
  mode: parser.mode,
3394
3394
  color,
3395
+ isTextColor: true,
3395
3396
  body: ordargument(body)
3396
3397
  }
3397
3398
  },
@@ -3424,6 +3425,7 @@ var temml = (function () {
3424
3425
  type: "color",
3425
3426
  mode: parser.mode,
3426
3427
  color,
3428
+ isTextColor: false,
3427
3429
  body
3428
3430
  }
3429
3431
  },
@@ -3867,10 +3869,8 @@ var temml = (function () {
3867
3869
  if (symDelim && delimiters.includes(symDelim.text)) {
3868
3870
  // If a character is not in the MathML operator dictionary, it will not stretch.
3869
3871
  // Replace such characters w/characters that will stretch.
3870
- if (["/", "\u2044"].includes(symDelim.text)) { symDelim.text = "\u2215"; }
3871
3872
  if (["<", "\\lt"].includes(symDelim.text)) { symDelim.text = "⟨"; }
3872
3873
  if ([">", "\\gt"].includes(symDelim.text)) { symDelim.text = "⟩"; }
3873
- if (symDelim.text === "\\backslash") { symDelim.text = "\u2216"; }
3874
3874
  return symDelim;
3875
3875
  } else if (symDelim) {
3876
3876
  throw new ParseError(`Invalid delimiter '${symDelim.text}' after '${context.funcName}'`, delim);
@@ -3879,6 +3879,9 @@ var temml = (function () {
3879
3879
  }
3880
3880
  }
3881
3881
 
3882
+ // / \
3883
+ const needExplicitStretch = ["\u002F", "\u005C", "\\backslash", "\\vert", "|"];
3884
+
3882
3885
  defineFunction({
3883
3886
  type: "delimsizing",
3884
3887
  names: [
@@ -3931,8 +3934,7 @@ var temml = (function () {
3931
3934
  // defaults.
3932
3935
  node.setAttribute("fence", "false");
3933
3936
  }
3934
- if (group.delim === "\u2216" || group.delim === "\\vert" ||
3935
- group.delim === "|" || group.delim.indexOf("arrow") > -1) {
3937
+ if (needExplicitStretch.includes(group.delim) || group.delim.indexOf("arrow") > -1) {
3936
3938
  // We have to explicitly set stretchy to true.
3937
3939
  node.setAttribute("stretchy", "true");
3938
3940
  }
@@ -4018,7 +4020,7 @@ var temml = (function () {
4018
4020
  const leftNode = new mathMLTree.MathNode("mo", [makeText(group.left, group.mode)]);
4019
4021
  leftNode.setAttribute("fence", "true");
4020
4022
  leftNode.setAttribute("form", "prefix");
4021
- if (group.left === "\u2216" || group.left.indexOf("arrow") > -1) {
4023
+ if (group.left === "/" || group.left === "\u005C" || group.left.indexOf("arrow") > -1) {
4022
4024
  leftNode.setAttribute("stretchy", "true");
4023
4025
  }
4024
4026
  inner.unshift(leftNode);
@@ -4030,6 +4032,15 @@ var temml = (function () {
4030
4032
  if (group.right === "\u2216" || group.right.indexOf("arrow") > -1) {
4031
4033
  rightNode.setAttribute("stretchy", "true");
4032
4034
  }
4035
+ if (group.body.length > 0) {
4036
+ const lastElement = group.body[group.body.length - 1];
4037
+ if (lastElement.type === "color" && !lastElement.isTextColor) {
4038
+ // \color is a switch. If the last element is of type "color" then
4039
+ // the user set the \color switch and left it on.
4040
+ // A \right delimiter turns the switch off, but the delimiter itself gets the color.
4041
+ rightNode.setAttribute("mathcolor", lastElement.color);
4042
+ }
4043
+ }
4033
4044
  inner.push(rightNode);
4034
4045
 
4035
4046
  return makeRow(inner);
@@ -11578,7 +11589,7 @@ var temml = (function () {
11578
11589
  * https://mit-license.org/
11579
11590
  */
11580
11591
 
11581
- const version = "0.10.29";
11592
+ const version = "0.10.30";
11582
11593
 
11583
11594
  function postProcess(block) {
11584
11595
  const labelMap = {};