temml 0.10.29 → 0.10.31

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);
@@ -12494,6 +12505,7 @@ class Parser {
12494
12505
  */
12495
12506
  parseExpression(breakOnInfix, breakOnTokenText, breakOnMiddle) {
12496
12507
  const body = [];
12508
+ this.prevAtomType = "";
12497
12509
  // Keep adding atoms to the body until we can't parse any more atoms (either
12498
12510
  // we reached the end, a }, or a \right)
12499
12511
  while (true) {
@@ -13491,7 +13503,7 @@ class Style {
13491
13503
  * https://mit-license.org/
13492
13504
  */
13493
13505
 
13494
- const version = "0.10.29";
13506
+ const version = "0.10.31";
13495
13507
 
13496
13508
  function postProcess(block) {
13497
13509
  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);
@@ -10581,6 +10592,7 @@ var temml = (function () {
10581
10592
  */
10582
10593
  parseExpression(breakOnInfix, breakOnTokenText, breakOnMiddle) {
10583
10594
  const body = [];
10595
+ this.prevAtomType = "";
10584
10596
  // Keep adding atoms to the body until we can't parse any more atoms (either
10585
10597
  // we reached the end, a }, or a \right)
10586
10598
  while (true) {
@@ -11578,7 +11590,7 @@ var temml = (function () {
11578
11590
  * https://mit-license.org/
11579
11591
  */
11580
11592
 
11581
- const version = "0.10.29";
11593
+ const version = "0.10.31";
11582
11594
 
11583
11595
  function postProcess(block) {
11584
11596
  const labelMap = {};