temml 0.10.17 → 0.10.19
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/dist/temml.cjs +13378 -13306
- package/dist/temml.js +11481 -11409
- package/dist/temml.min.js +1 -1
- package/dist/temml.mjs +13376 -13304
- package/dist/temmlPostProcess.js +1 -1
- package/package.json +1 -1
- package/src/buildMathML.js +22 -1
- package/src/functions/delimsizing.js +15 -3
- package/src/functions/hbox.js +5 -4
- package/src/functions/op.js +3 -1
- package/src/functions.js +1 -0
- package/src/macros.js +3 -2
- package/src/postProcess.js +1 -1
- package/src/symbols.js +12 -3
- package/temml.js +2 -2
package/dist/temmlPostProcess.js
CHANGED
package/package.json
CHANGED
package/src/buildMathML.js
CHANGED
@@ -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
|
|
@@ -115,6 +118,16 @@ const consolidateNumbers = expression => {
|
|
115
118
|
expression[nums[i].start].text += expression[j].text
|
116
119
|
}
|
117
120
|
expression.splice(nums[i].start + 1, nums[i].end - nums[i].start)
|
121
|
+
// Check if the <mn> is followed by a numeric base in a supsub, e.g. the "3" in 123^4
|
122
|
+
// If so, merge the first <mn> into the base.
|
123
|
+
if (expression.length > nums[i].start + 1) {
|
124
|
+
const nextTerm = expression[nums[i].start + 1];
|
125
|
+
if (nextTerm.type === "supsub" && nextTerm.base && nextTerm.base.type === "textord" &&
|
126
|
+
numberRegEx.test(nextTerm.base.text)) {
|
127
|
+
nextTerm.base.text = expression[nums[i].start].text + nextTerm.base.text
|
128
|
+
expression.splice(nums[i].start, 1)
|
129
|
+
}
|
130
|
+
}
|
118
131
|
}
|
119
132
|
}
|
120
133
|
|
@@ -126,6 +139,14 @@ export const makeRow = function(body) {
|
|
126
139
|
if (body.length === 1 && !(body[0] instanceof DocumentFragment)) {
|
127
140
|
return body[0];
|
128
141
|
} else {
|
142
|
+
// Suppress spacing on <mo> nodes at both ends of the row.
|
143
|
+
if (body[0] instanceof MathNode && body[0].type === "mo" && !body[0].attributes.fence) {
|
144
|
+
body[0].attributes.lspace = "0em"
|
145
|
+
}
|
146
|
+
const end = body.length - 1
|
147
|
+
if (body[end] instanceof MathNode && body[end].type === "mo" && !body[end].attributes.fence) {
|
148
|
+
body[end].attributes.rspace = "0em"
|
149
|
+
}
|
129
150
|
return new mathMLTree.MathNode("mrow", body);
|
130
151
|
}
|
131
152
|
};
|
@@ -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
|
177
|
-
|
178
|
-
//
|
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.
|
package/src/functions/hbox.js
CHANGED
@@ -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
|
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
|
27
|
-
|
26
|
+
const newStyle = style.withLevel(StyleLevel.TEXT)
|
27
|
+
const mrow = mml.buildExpressionRow(group.body, newStyle)
|
28
|
+
return mml.consolidateText(mrow)
|
28
29
|
}
|
29
30
|
});
|
package/src/functions/op.js
CHANGED
@@ -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
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",
|
@@ -437,6 +436,8 @@ defineMacro("\\quad", "\\hskip1em\\relax");
|
|
437
436
|
// \def\qquad{\hskip2em\relax}
|
438
437
|
defineMacro("\\qquad", "\\hskip2em\\relax");
|
439
438
|
|
439
|
+
defineMacro("\\AA", "\\TextOrMath{\\Angstrom}{\\mathring{A}}\\relax")
|
440
|
+
|
440
441
|
// \tag@in@display form of \tag
|
441
442
|
defineMacro("\\tag", "\\@ifstar\\tag@literal\\tag@paren");
|
442
443
|
defineMacro("\\tag@paren", "\\tag@literal{({#1})}");
|
package/src/postProcess.js
CHANGED
package/src/symbols.js
CHANGED
@@ -132,8 +132,8 @@ defineSymbol(math, textord, "\u2207", "\\nabla", true);
|
|
132
132
|
defineSymbol(math, textord, "\u266d", "\\flat", true);
|
133
133
|
defineSymbol(math, textord, "\u2113", "\\ell", true);
|
134
134
|
defineSymbol(math, textord, "\u266e", "\\natural", true);
|
135
|
-
defineSymbol(math, textord, "Å", "\\
|
136
|
-
defineSymbol(text, textord, "Å", "\\
|
135
|
+
defineSymbol(math, textord, "Å", "\\Angstrom", true);
|
136
|
+
defineSymbol(text, textord, "Å", "\\Angstrom", true);
|
137
137
|
defineSymbol(math, textord, "\u2663", "\\clubsuit", true);
|
138
138
|
defineSymbol(math, textord, "\u2667", "\\varclubsuit", true);
|
139
139
|
defineSymbol(math, textord, "\u2118", "\\wp", true);
|
@@ -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, "\
|
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 === "
|
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) {
|