temml 0.10.17 → 0.10.18

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,7 +14,7 @@
14
14
  * https://mit-license.org/
15
15
  */
16
16
 
17
- const version = "0.10.17";
17
+ const version = "0.10.18";
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.17",
3
+ "version": "0.10.18",
4
4
  "description": "TeX to MathML conversion in JavaScript.",
5
5
  "main": "dist/temml.js",
6
6
  "engines": {
@@ -36,7 +36,7 @@ export const makeText = function(text, mode, style) {
36
36
 
37
37
  export const consolidateText = mrow => {
38
38
  // If possible, consolidate adjacent <mtext> elements into a single element.
39
- if (mrow.type !== "mrow") { return mrow }
39
+ if (mrow.type !== "mrow" && mrow.type !== "mstyle") { return mrow }
40
40
  if (mrow.children.length === 0) { return mrow } // empty group, e.g., \text{}
41
41
  if (!mrow.children[0].attributes || mrow.children[0].type !== "mtext") { return mrow }
42
42
  const variant = mrow.children[0].attributes.mathvariant || ""
@@ -73,6 +73,9 @@ export const consolidateText = mrow => {
73
73
  if (L > 0 && mtext.children[0].text.charAt(L - 1) === " ") {
74
74
  mtext.children[0].text = mtext.children[0].text.slice(0, -1) + "\u00a0"
75
75
  }
76
+ for (const [key, value] of Object.entries(mrow.attributes)) {
77
+ mtext.attributes[key] = value
78
+ }
76
79
  return mtext
77
80
  }
78
81
 
@@ -126,6 +129,14 @@ export const makeRow = function(body) {
126
129
  if (body.length === 1 && !(body[0] instanceof DocumentFragment)) {
127
130
  return body[0];
128
131
  } else {
132
+ // Suppress spacing on <mo> nodes at both ends of the row.
133
+ if (body[0] instanceof MathNode && body[0].type === "mo" && !body[0].attributes.fence) {
134
+ body[0].attributes.lspace = "0em"
135
+ }
136
+ const end = body.length - 1
137
+ if (body[end] instanceof MathNode && body[end].type === "mo" && !body[end].attributes.fence) {
138
+ body[end].attributes.rspace = "0em"
139
+ }
129
140
  return new mathMLTree.MathNode("mrow", body);
130
141
  }
131
142
  };
@@ -38,6 +38,10 @@ export const delimiters = [
38
38
  "\\lbrace",
39
39
  "\\}",
40
40
  "\\rbrace",
41
+ "⦇",
42
+ "\\llparenthesis",
43
+ "⦈",
44
+ "\\rrparenthesis",
41
45
  "\\lfloor",
42
46
  "\\rfloor",
43
47
  "\u230a",
@@ -52,6 +56,14 @@ export const delimiters = [
52
56
  "\u27e8",
53
57
  "\\rangle",
54
58
  "\u27e9",
59
+ "\\lAngle",
60
+ "\u27ea",
61
+ "\\rAngle",
62
+ "\u27eb",
63
+ "\\llangle",
64
+ "⦉",
65
+ "\\rrangle",
66
+ "⦊",
55
67
  "\\lt",
56
68
  "\\gt",
57
69
  "\\lvert",
@@ -173,9 +185,9 @@ defineFunction({
173
185
  // defaults.
174
186
  node.setAttribute("fence", "false");
175
187
  }
176
- if (group.delim === "\u2216" || group.delim.indexOf("arrow") > -1) {
177
- // \backslash is not in the operator dictionary,
178
- // so we have to explicitly set stretchy to true.
188
+ if (group.delim === "\u2216" || group.delim === "\\vert" ||
189
+ group.delim === "|" || group.delim.indexOf("arrow") > -1) {
190
+ // We have to explicitly set stretchy to true.
179
191
  node.setAttribute("stretchy", "true")
180
192
  }
181
193
  node.setAttribute("symmetric", "true"); // Needed for tall arrows in Firefox.
@@ -1,10 +1,10 @@
1
1
  import defineFunction, { ordargument } from "../defineFunction";
2
2
  import { StyleLevel } from "../constants"
3
- import mathMLTree from "../mathMLTree";
4
3
  import * as mml from "../buildMathML";
5
4
 
6
5
  // \hbox is provided for compatibility with LaTeX functions that act on a box.
7
- // This function by itself doesn't do anything but prevent a soft line break.
6
+ // This function by itself doesn't do anything but set scriptlevel to \textstyle
7
+ // and prevent a soft line break.
8
8
 
9
9
  defineFunction({
10
10
  type: "hbox",
@@ -23,7 +23,8 @@ defineFunction({
23
23
  };
24
24
  },
25
25
  mathmlBuilder(group, style) {
26
- const newOptions = style.withLevel(StyleLevel.TEXT)
27
- return new mathMLTree.MathNode("mrow", mml.buildExpression(group.body, newOptions));
26
+ const newStyle = style.withLevel(StyleLevel.TEXT)
27
+ const mrow = mml.buildExpressionRow(group.body, newStyle)
28
+ return mml.consolidateText(mrow)
28
29
  }
29
30
  });
@@ -71,7 +71,8 @@ const singleCharBigOps = {
71
71
  "\u2a02": "\\bigotimes",
72
72
  "\u2a04": "\\biguplus",
73
73
  "\u2a05": "\\bigsqcap",
74
- "\u2a06": "\\bigsqcup"
74
+ "\u2a06": "\\bigsqcup",
75
+ "\u2a09": "\\bigtimes"
75
76
  };
76
77
 
77
78
  defineFunction({
@@ -91,6 +92,7 @@ defineFunction({
91
92
  "\\bigodot",
92
93
  "\\bigsqcap",
93
94
  "\\bigsqcup",
95
+ "\\bigtimes",
94
96
  "\\smallint",
95
97
  "\u220F",
96
98
  "\u2210",
package/src/functions.js CHANGED
@@ -21,6 +21,7 @@ import "./functions/environment";
21
21
  import "./functions/envTag";
22
22
  import "./functions/font";
23
23
  import "./functions/genfrac";
24
+ import "./functions/hbox";
24
25
  import "./functions/horizBrace";
25
26
  import "./functions/href";
26
27
  import "./functions/html";
package/src/macros.js CHANGED
@@ -191,8 +191,6 @@ defineMacro("\\surd", '\\sqrt{\\vphantom{|}}')
191
191
  // See comment for \oplus in symbols.js.
192
192
  defineMacro("\u2295", "\\oplus")
193
193
 
194
- defineMacro("\\hbox", "\\text{#1}");
195
-
196
194
  // Per TeXbook p.122, "/" gets zero operator spacing.
197
195
  // And MDN recommends using U+2044 instead of / for inline
198
196
  defineMacro("/", "{\u2044}")
@@ -275,6 +273,7 @@ const dotsByToken = {
275
273
  "\\bigodot": "\\dotsb",
276
274
  "\\bigsqcap": "\\dotsb",
277
275
  "\\bigsqcup": "\\dotsb",
276
+ "\\bigtimes": "\\dotsb",
278
277
  "\\And": "\\dotsb",
279
278
  "\\longrightarrow": "\\dotsb",
280
279
  "\\Longrightarrow": "\\dotsb",
@@ -8,7 +8,7 @@
8
8
  * https://mit-license.org/
9
9
  */
10
10
 
11
- export const version = "0.10.17";
11
+ export const version = "0.10.18";
12
12
 
13
13
  export function postProcess(block) {
14
14
  const labelMap = {}
package/src/symbols.js CHANGED
@@ -556,7 +556,7 @@ defineSymbol(math, open, "\u00ac", "\\lnot");
556
556
  defineSymbol(math, textord, "\u22a4", "\\top");
557
557
  defineSymbol(math, textord, "\u22a5", "\\bot");
558
558
  defineSymbol(math, textord, "\u2205", "\\emptyset");
559
- defineSymbol(math, textord, "\u00f8", "\\varnothing");
559
+ defineSymbol(math, textord, "\u2300", "\\varnothing");
560
560
  defineSymbol(math, mathord, "\u03b1", "\\alpha", true);
561
561
  defineSymbol(math, mathord, "\u03b2", "\\beta", true);
562
562
  defineSymbol(math, mathord, "\u03b3", "\\gamma", true);
@@ -617,6 +617,8 @@ defineSymbol(math, bin, "\u2228", "\\vee", true);
617
617
  defineSymbol(math, open, "\u27e6", "\\llbracket", true); // stmaryrd/semantic packages
618
618
  defineSymbol(math, close, "\u27e7", "\\rrbracket", true);
619
619
  defineSymbol(math, open, "\u27e8", "\\langle", true);
620
+ defineSymbol(math, open, "\u27ea", "\\lAngle", true);
621
+ defineSymbol(math, open, "\u2989", "\\llangle", true);
620
622
  defineSymbol(math, open, "|", "\\lvert");
621
623
  defineSymbol(math, open, "\u2016", "\\lVert");
622
624
  defineSymbol(math, textord, "!", "\\oc"); // cmll package
@@ -628,6 +630,8 @@ defineSymbol(math, close, "?", "?");
628
630
  defineSymbol(math, close, "!", "!");
629
631
  defineSymbol(math, close, "‼", "‼");
630
632
  defineSymbol(math, close, "\u27e9", "\\rangle", true);
633
+ defineSymbol(math, close, "\u27eb", "\\rAngle", true);
634
+ defineSymbol(math, close, "\u298a", "\\rrangle", true);
631
635
  defineSymbol(math, close, "|", "\\rvert");
632
636
  defineSymbol(math, close, "\u2016", "\\rVert");
633
637
  defineSymbol(math, open, "\u2983", "\\lBrace", true); // stmaryrd/semantic packages
@@ -709,6 +713,8 @@ defineSymbol(math, close, "]", "\\rbrack", true);
709
713
  defineSymbol(text, textord, "]", "\\rbrack", true);
710
714
  defineSymbol(math, open, "(", "\\lparen", true);
711
715
  defineSymbol(math, close, ")", "\\rparen", true);
716
+ defineSymbol(math, open, "⦇", "\\llparenthesis", true);
717
+ defineSymbol(math, close, "⦈", "\\rrparenthesis", true);
712
718
  defineSymbol(text, textord, "<", "\\textless", true); // in T1 fontenc
713
719
  defineSymbol(text, textord, ">", "\\textgreater", true); // in T1 fontenc
714
720
  defineSymbol(math, open, "\u230a", "\\lfloor", true);
@@ -746,6 +752,7 @@ defineSymbol(math, op, "\u2211", "\\sum");
746
752
  defineSymbol(math, op, "\u2a02", "\\bigotimes");
747
753
  defineSymbol(math, op, "\u2a01", "\\bigoplus");
748
754
  defineSymbol(math, op, "\u2a00", "\\bigodot");
755
+ defineSymbol(math, op, "\u2a09", "\\bigtimes");
749
756
  defineSymbol(math, op, "\u222e", "\\oint");
750
757
  defineSymbol(math, op, "\u222f", "\\oiint");
751
758
  defineSymbol(math, op, "\u2230", "\\oiiint");
@@ -865,6 +872,8 @@ defineSymbol(text, textord, "\u20ac", "\\euro", true);
865
872
  defineSymbol(text, textord, "\u20ac", "\\texteuro");
866
873
  defineSymbol(math, textord, "\u00a9", "\\copyright", true);
867
874
  defineSymbol(text, textord, "\u00a9", "\\textcopyright");
875
+ defineSymbol(math, textord, "\u2300", "\\diameter", true);
876
+ defineSymbol(text, textord, "\u2300", "\\diameter");
868
877
 
869
878
  // Italic Greek
870
879
  defineSymbol(math, textord, "𝛤", "\\varGamma");
package/temml.js CHANGED
@@ -25,9 +25,9 @@ import { postProcess, version } from "./src/postProcess";
25
25
  * Parse and build an expression, and place that expression in the DOM node
26
26
  * given.
27
27
  */
28
- let render = function(expression, baseNode, options) {
28
+ let render = function(expression, baseNode, options = {}) {
29
29
  baseNode.textContent = "";
30
- const alreadyInMathElement = baseNode.tagName === "MATH"
30
+ const alreadyInMathElement = baseNode.tagName.toLowerCase() === "math"
31
31
  if (alreadyInMathElement) { options.wrap = "none" }
32
32
  const math = renderToMathMLTree(expression, options)
33
33
  if (alreadyInMathElement) {