temml 0.13.1 → 0.13.3
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/README.md +3 -4
- package/contrib/mhchem/mhchem.min.js +1 -1
- package/dist/Temml-Asana.css +16 -13
- package/dist/Temml-Latin-Modern.css +16 -13
- package/dist/Temml-Libertinus.css +16 -13
- package/dist/Temml-Local.css +16 -13
- package/dist/Temml-NotoSans.css +16 -13
- package/dist/Temml-STIX2.css +16 -13
- package/dist/temml.cjs +629 -500
- package/dist/temml.js +502 -373
- package/dist/temml.min.js +1 -1
- package/dist/temml.mjs +629 -500
- package/dist/temmlPostProcess.js +1 -1
- package/package.json +6 -4
- package/src/MacroExpander.js +2 -1
- package/src/Parser.js +5 -4
- package/src/Settings.js +1 -0
- package/src/environments/array.js +2 -2
- package/src/functions/bordermatrix.js +3 -5
- package/src/functions/cancelto.js +2 -0
- package/src/functions/color.js +1 -1
- package/src/functions/{delimsizing.js → delimiter.js} +139 -52
- package/src/functions/enclose.js +21 -2
- package/src/functions/font.js +14 -4
- package/src/functions/genfrac.js +32 -45
- package/src/functions/mclass.js +10 -2
- package/src/functions/op.js +1 -1
- package/src/functions/operatorname.js +9 -1
- package/src/functions/phantom.js +1 -1
- package/src/functions/symbolsOrd.js +2 -2
- package/src/functions.js +1 -1
- package/src/linebreaking.js +3 -10
- package/src/macros.js +1 -0
- package/src/parseNode.js +1 -1
- package/src/parseTree.js +20 -4
- package/src/postProcess.js +1 -1
- package/src/symbols.js +2 -3
package/src/functions/mclass.js
CHANGED
|
@@ -148,8 +148,16 @@ export const binrelClass = (arg) => {
|
|
|
148
148
|
const atom = arg.type === "ordgroup" && arg.body.length && arg.body.length === 1
|
|
149
149
|
? arg.body[0]
|
|
150
150
|
: arg;
|
|
151
|
-
if (atom.type === "atom"
|
|
152
|
-
|
|
151
|
+
if (atom.type === "atom") {
|
|
152
|
+
// BIN args are sometimes changed to OPEN, so check the original family.
|
|
153
|
+
const family = arg.body.length > 0 && arg.body[0].text && symbols.math[arg.body[0].text]
|
|
154
|
+
? symbols.math[arg.body[0].text].group
|
|
155
|
+
: atom.family
|
|
156
|
+
if (family === "bin" || family === "rel") {
|
|
157
|
+
return "m" + family;
|
|
158
|
+
} else {
|
|
159
|
+
return "mord";
|
|
160
|
+
}
|
|
153
161
|
} else {
|
|
154
162
|
return "mord";
|
|
155
163
|
}
|
package/src/functions/op.js
CHANGED
|
@@ -3,7 +3,7 @@ import defineMacro from "../defineMacro";
|
|
|
3
3
|
import * as mathMLTree from "../mathMLTree"
|
|
4
4
|
import { spaceCharacter } from "./kern"
|
|
5
5
|
import { ordTypes } from "./op"
|
|
6
|
-
import { isDelimiter } from "./
|
|
6
|
+
import { isDelimiter } from "./delimiter"
|
|
7
7
|
|
|
8
8
|
import * as mml from "../buildMathML"
|
|
9
9
|
|
|
@@ -22,6 +22,14 @@ const mathmlBuilder = (group, style) => {
|
|
|
22
22
|
if ((node.type === "mrow" || node.type === "mpadded") && node.children.length === 1 &&
|
|
23
23
|
node.children[0] instanceof mathMLTree.MathNode) {
|
|
24
24
|
node = node.children[0]
|
|
25
|
+
} else if (node.type === "mrow" && node.children.length === 2 &&
|
|
26
|
+
node.children[0] instanceof mathMLTree.MathNode &&
|
|
27
|
+
node.children[1] instanceof mathMLTree.MathNode &&
|
|
28
|
+
node.children[1].type === "mspace" && !node.children[1].attributes.width &&
|
|
29
|
+
node.children[1].children.length === 0) {
|
|
30
|
+
// This is a workaround for a Firefox bug that applies spacing to
|
|
31
|
+
// an <mi> with mathvariant="normal".
|
|
32
|
+
node = node.children[0];
|
|
25
33
|
}
|
|
26
34
|
switch (node.type) {
|
|
27
35
|
case "mi":
|
package/src/functions/phantom.js
CHANGED
|
@@ -67,7 +67,7 @@ defineFunction({
|
|
|
67
67
|
const inner = mml.buildExpression(ordargument(group.body), style);
|
|
68
68
|
const phantom = new mathMLTree.MathNode("mphantom", inner);
|
|
69
69
|
const node = new mathMLTree.MathNode("mpadded", [phantom]);
|
|
70
|
-
node.setAttribute("width", "
|
|
70
|
+
node.setAttribute("width", "0.1px");
|
|
71
71
|
return node;
|
|
72
72
|
}
|
|
73
73
|
});
|
|
@@ -41,8 +41,8 @@ defineFunctionBuilders({
|
|
|
41
41
|
node.setAttribute("mathvariant", "normal")
|
|
42
42
|
if (text.text.length === 1) {
|
|
43
43
|
// A Firefox bug will apply spacing here, but there should be none. Fix it.
|
|
44
|
-
|
|
45
|
-
node.
|
|
44
|
+
const mspace = new mathMLTree.MathNode("mspace", [])
|
|
45
|
+
node = new mathMLTree.MathNode("mrow", [node, mspace])
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
return node
|
package/src/functions.js
CHANGED
|
@@ -16,7 +16,7 @@ import "./functions/char";
|
|
|
16
16
|
import "./functions/color";
|
|
17
17
|
import "./functions/cr";
|
|
18
18
|
import "./functions/def";
|
|
19
|
-
import "./functions/
|
|
19
|
+
import "./functions/delimiter";
|
|
20
20
|
import "./functions/enclose";
|
|
21
21
|
import "./functions/environment";
|
|
22
22
|
import "./functions/envTag";
|
package/src/linebreaking.js
CHANGED
|
@@ -26,16 +26,12 @@ import { DocumentFragment } from "./tree"
|
|
|
26
26
|
* much of this module.
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
|
-
const openDelims = "([{⌊⌈⟨⟮⎰⟦⦃"
|
|
30
|
-
const closeDelims = ")]}⌋⌉⟩⟯⎱⟦⦄"
|
|
31
|
-
|
|
32
29
|
export default function setLineBreaks(expression, wrapMode, isDisplayMode) {
|
|
33
30
|
const mtrs = [];
|
|
34
31
|
let mrows = [];
|
|
35
32
|
let block = [];
|
|
36
33
|
let numTopLevelEquals = 0
|
|
37
34
|
let i = 0
|
|
38
|
-
let level = 0
|
|
39
35
|
while (i < expression.length) {
|
|
40
36
|
while (expression[i] instanceof DocumentFragment) {
|
|
41
37
|
expression.splice(i, 1, ...expression[i].children) // Expand the fragment.
|
|
@@ -58,13 +54,10 @@ export default function setLineBreaks(expression, wrapMode, isDisplayMode) {
|
|
|
58
54
|
}
|
|
59
55
|
block.push(node);
|
|
60
56
|
if (node.type && node.type === "mo" && node.children.length === 1 &&
|
|
57
|
+
!(node.attributes.form && node.attributes.form === "prefix") && // unary operators
|
|
61
58
|
!Object.prototype.hasOwnProperty.call(node.attributes, "movablelimits")) {
|
|
62
59
|
const ch = node.children[0].text
|
|
63
|
-
if (
|
|
64
|
-
level += 1
|
|
65
|
-
} else if (closeDelims.indexOf(ch) > -1) {
|
|
66
|
-
level -= 1
|
|
67
|
-
} else if (level === 0 && wrapMode === "=" && ch === "=") {
|
|
60
|
+
if (wrapMode === "=" && ch === "=") {
|
|
68
61
|
numTopLevelEquals += 1
|
|
69
62
|
if (numTopLevelEquals > 1) {
|
|
70
63
|
block.pop()
|
|
@@ -73,7 +66,7 @@ export default function setLineBreaks(expression, wrapMode, isDisplayMode) {
|
|
|
73
66
|
mrows.push(element)
|
|
74
67
|
block = [node];
|
|
75
68
|
}
|
|
76
|
-
} else if (
|
|
69
|
+
} else if (wrapMode === "tex") {
|
|
77
70
|
// Check if the following node is a \nobreak text node, e.g. "~""
|
|
78
71
|
const next = i < expression.length - 1 ? expression[i + 1] : null;
|
|
79
72
|
let glueIsFreeOfNobreak = true;
|
package/src/macros.js
CHANGED
|
@@ -694,6 +694,7 @@ defineMacro("\\upomega", "\\up@greek{\\omega}");
|
|
|
694
694
|
// cmll package
|
|
695
695
|
defineMacro("\\invamp", '\\mathbin{\\char"214b}')
|
|
696
696
|
defineMacro("\\parr", '\\mathbin{\\char"214b}')
|
|
697
|
+
defineMacro("\\upand", '\\mathbin{\\char"214b}') // STIX package
|
|
697
698
|
defineMacro("\\with", '\\mathbin{\\char"26}')
|
|
698
699
|
defineMacro("\\multimapinv", '\\mathrel{\\char"27dc}')
|
|
699
700
|
defineMacro("\\multimapboth", '\\mathrel{\\char"29df}')
|
package/src/parseNode.js
CHANGED
|
@@ -34,7 +34,7 @@ export function assertSymbolNodeType(node) {
|
|
|
34
34
|
* returns null.
|
|
35
35
|
*/
|
|
36
36
|
export function checkSymbolNodeType(node) {
|
|
37
|
-
if (node && (node.type === "atom" ||
|
|
37
|
+
if (node && (node.type === "atom" || node.type === "delimiter" ||
|
|
38
38
|
Object.prototype.hasOwnProperty.call(NON_ATOMS, node.type))) {
|
|
39
39
|
return node;
|
|
40
40
|
}
|
package/src/parseTree.js
CHANGED
|
@@ -8,11 +8,27 @@ const parseTree = function(toParse, settings) {
|
|
|
8
8
|
if (!(typeof toParse === "string" || toParse instanceof String)) {
|
|
9
9
|
throw new TypeError("Temml can only parse string typed expression")
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
let tree;
|
|
12
|
+
let parser;
|
|
13
|
+
try {
|
|
14
|
+
parser = new Parser(toParse, settings)
|
|
15
|
+
// Blank out any \df@tag to avoid spurious "Duplicate \tag" errors
|
|
16
|
+
delete parser.gullet.macros.current["\\df@tag"]
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
tree = parser.parse()
|
|
19
|
+
} catch (error) {
|
|
20
|
+
if (error.toString() === "ParseError: Unmatched delimiter") {
|
|
21
|
+
// Abandon the attempt to wrap delimiter pairs in an <mrow>.
|
|
22
|
+
// Try again, and put each delimiter into an <mo> element.
|
|
23
|
+
settings.wrapDelimiterPairs = false;
|
|
24
|
+
parser = new Parser(toParse, settings)
|
|
25
|
+
// Blank out any \df@tag to avoid spurious "Duplicate \tag" errors
|
|
26
|
+
delete parser.gullet.macros.current["\\df@tag"]
|
|
27
|
+
tree = parser.parse()
|
|
28
|
+
} else {
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
16
32
|
|
|
17
33
|
// LaTeX ignores a \tag placed outside an AMS environment.
|
|
18
34
|
if (!(tree.length > 0 && tree[0].type && tree[0].type === "array" && tree[0].addEqnNum)) {
|
package/src/postProcess.js
CHANGED
package/src/symbols.js
CHANGED
|
@@ -128,8 +128,7 @@ defineSymbol(math, textord, "\u2135", "\\aleph", true);
|
|
|
128
128
|
defineSymbol(math, textord, "\u2200", "\\forall", true);
|
|
129
129
|
defineSymbol(math, textord, "\u210f", "\\hbar", true);
|
|
130
130
|
defineSymbol(math, textord, "\u2203", "\\exists", true);
|
|
131
|
-
|
|
132
|
-
defineSymbol(math, bin, "\u2207", "\\nabla", true);
|
|
131
|
+
defineSymbol(math, open, "\u2207", "\\nabla", true);
|
|
133
132
|
defineSymbol(math, textord, "\u266d", "\\flat", true);
|
|
134
133
|
defineSymbol(math, textord, "\u2113", "\\ell", true);
|
|
135
134
|
defineSymbol(math, textord, "\u266e", "\\natural", true);
|
|
@@ -222,7 +221,7 @@ defineSymbol(math, mathord, "\u2295", "\\Earth");
|
|
|
222
221
|
|
|
223
222
|
// AMS Negated Binary Relations
|
|
224
223
|
defineSymbol(math, rel, "\u226e", "\\nless", true);
|
|
225
|
-
// Symbol names
|
|
224
|
+
// Symbol names preceded by "@" each have a corresponding macro.
|
|
226
225
|
defineSymbol(math, rel, "\u2a87", "\\lneq", true);
|
|
227
226
|
defineSymbol(math, rel, "\u2268", "\\lneqq", true);
|
|
228
227
|
defineSymbol(math, rel, "\u2268\ufe00", "\\lvertneqq");
|