temml 0.10.12 → 0.10.14
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/Temml-Asana.css +8 -4
- package/dist/Temml-Latin-Modern.css +8 -4
- package/dist/Temml-Libertinus.css +8 -4
- package/dist/Temml-Local.css +8 -4
- package/dist/Temml-STIX2.css +8 -4
- package/dist/temml.cjs +126 -102
- package/dist/temml.js +126 -102
- package/dist/temml.min.js +1 -1
- package/dist/temml.mjs +126 -102
- package/dist/temmlPostProcess.js +1 -1
- package/package.json +4 -1
- package/src/buildMathML.js +4 -1
- package/src/functions/arrow.js +50 -24
- package/src/functions/delimsizing.js +2 -3
- package/src/functions/enclose.js +13 -13
- package/src/functions/raise.js +7 -7
- package/src/linebreaking.js +45 -48
- package/src/macros.js +1 -4
- package/src/postProcess.js +1 -1
- package/src/symbols.js +2 -0
package/src/functions/raise.js
CHANGED
@@ -5,8 +5,6 @@ import { assertNodeType } from "../parseNode"
|
|
5
5
|
import { calculateSize } from "../units"
|
6
6
|
import * as mml from "../buildMathML"
|
7
7
|
|
8
|
-
const sign = num => num >= 0 ? "+" : "-"
|
9
|
-
|
10
8
|
// \raise, \lower, and \raisebox
|
11
9
|
|
12
10
|
const mathmlBuilder = (group, style) => {
|
@@ -14,11 +12,13 @@ const mathmlBuilder = (group, style) => {
|
|
14
12
|
const node = new mathMLTree.MathNode("mpadded", [mml.buildGroup(group.body, newStyle)])
|
15
13
|
const dy = calculateSize(group.dy, style)
|
16
14
|
node.setAttribute("voffset", dy.number + dy.unit)
|
17
|
-
|
18
|
-
//
|
19
|
-
|
20
|
-
|
21
|
-
|
15
|
+
// Add padding, which acts to increase height in Chromium.
|
16
|
+
// TODO: Figure out some way to change height in Firefox w/o breaking Chromium.
|
17
|
+
if (dy.number > 0) {
|
18
|
+
node.style.padding = dy.number + dy.unit + " 0 0 0"
|
19
|
+
} else {
|
20
|
+
node.style.padding = "0 0 " + Math.abs(dy.number) + dy.unit + " 0"
|
21
|
+
}
|
22
22
|
return node
|
23
23
|
}
|
24
24
|
|
package/src/linebreaking.js
CHANGED
@@ -26,13 +26,16 @@ import { DocumentFragment } from "./tree"
|
|
26
26
|
* much of this module.
|
27
27
|
*/
|
28
28
|
|
29
|
+
const openDelims = "([{⌊⌈⟨⟮⎰⟦⦃"
|
30
|
+
const closeDelims = ")]}⌋⌉⟩⟯⎱⟦⦄"
|
31
|
+
|
29
32
|
export default function setLineBreaks(expression, wrapMode, isDisplayMode) {
|
30
33
|
const mtrs = [];
|
31
34
|
let mrows = [];
|
32
35
|
let block = [];
|
33
36
|
let numTopLevelEquals = 0
|
34
|
-
let canBeBIN = false // The first node cannot be an infix binary operator.
|
35
37
|
let i = 0
|
38
|
+
let level = 0
|
36
39
|
while (i < expression.length) {
|
37
40
|
while (expression[i] instanceof DocumentFragment) {
|
38
41
|
expression.splice(i, 1, ...expression[i].children) // Expand the fragment.
|
@@ -55,7 +58,12 @@ export default function setLineBreaks(expression, wrapMode, isDisplayMode) {
|
|
55
58
|
}
|
56
59
|
block.push(node);
|
57
60
|
if (node.type && node.type === "mo" && node.children.length === 1) {
|
58
|
-
|
61
|
+
const ch = node.children[0].text
|
62
|
+
if (openDelims.indexOf(ch) > -1) {
|
63
|
+
level += 1
|
64
|
+
} else if (closeDelims.indexOf(ch) > -1) {
|
65
|
+
level -= 1
|
66
|
+
} else if (level === 0 && wrapMode === "=" && ch === "=") {
|
59
67
|
numTopLevelEquals += 1
|
60
68
|
if (numTopLevelEquals > 1) {
|
61
69
|
block.pop()
|
@@ -64,59 +72,48 @@ export default function setLineBreaks(expression, wrapMode, isDisplayMode) {
|
|
64
72
|
mrows.push(element)
|
65
73
|
block = [node];
|
66
74
|
}
|
67
|
-
} else if (wrapMode === "tex") {
|
68
|
-
//
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
75
|
+
} else if (level === 0 && wrapMode === "tex") {
|
76
|
+
// Check if the following node is a \nobreak text node, e.g. "~""
|
77
|
+
const next = i < expression.length - 1 ? expression[i + 1] : null;
|
78
|
+
let glueIsFreeOfNobreak = true;
|
79
|
+
if (
|
80
|
+
!(
|
81
|
+
next &&
|
82
|
+
next.type === "mtext" &&
|
83
|
+
next.attributes.linebreak &&
|
84
|
+
next.attributes.linebreak === "nobreak"
|
85
|
+
)
|
86
|
+
) {
|
87
|
+
// We may need to start a new block.
|
88
|
+
// First, put any post-operator glue on same line as operator.
|
89
|
+
for (let j = i + 1; j < expression.length; j++) {
|
90
|
+
const nd = expression[j];
|
91
|
+
if (
|
92
|
+
nd.type &&
|
93
|
+
nd.type === "mspace" &&
|
94
|
+
!(nd.attributes.linebreak && nd.attributes.linebreak === "newline")
|
95
|
+
) {
|
96
|
+
block.push(nd);
|
97
|
+
i += 1;
|
85
98
|
if (
|
86
|
-
nd.
|
87
|
-
nd.
|
88
|
-
|
99
|
+
nd.attributes &&
|
100
|
+
nd.attributes.linebreak &&
|
101
|
+
nd.attributes.linebreak === "nobreak"
|
89
102
|
) {
|
90
|
-
|
91
|
-
i += 1;
|
92
|
-
if (
|
93
|
-
nd.attributes &&
|
94
|
-
nd.attributes.linebreak &&
|
95
|
-
nd.attributes.linebreak === "nobreak"
|
96
|
-
) {
|
97
|
-
glueIsFreeOfNobreak = false;
|
98
|
-
}
|
99
|
-
} else {
|
100
|
-
break;
|
103
|
+
glueIsFreeOfNobreak = false;
|
101
104
|
}
|
105
|
+
} else {
|
106
|
+
break;
|
102
107
|
}
|
103
108
|
}
|
104
|
-
if (glueIsFreeOfNobreak) {
|
105
|
-
// Start a new block. (Insert a soft linebreak.)
|
106
|
-
const element = new mathMLTree.MathNode("mrow", block)
|
107
|
-
mrows.push(element)
|
108
|
-
block = [];
|
109
|
-
}
|
110
|
-
canBeBIN = false
|
111
109
|
}
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
110
|
+
if (glueIsFreeOfNobreak) {
|
111
|
+
// Start a new block. (Insert a soft linebreak.)
|
112
|
+
const element = new mathMLTree.MathNode("mrow", block)
|
113
|
+
mrows.push(element)
|
114
|
+
block = [];
|
115
|
+
}
|
117
116
|
}
|
118
|
-
} else {
|
119
|
-
canBeBIN = true
|
120
117
|
}
|
121
118
|
i += 1
|
122
119
|
}
|
package/src/macros.js
CHANGED
@@ -238,9 +238,6 @@ defineMacro("\u22ee", "\\vdots");
|
|
238
238
|
//\newcommand{\substack}[1]{\subarray{c}#1\endsubarray}
|
239
239
|
defineMacro("\\substack", "\\begin{subarray}{c}#1\\end{subarray}");
|
240
240
|
|
241
|
-
// \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}}
|
242
|
-
defineMacro("\\boxed", "\\fbox{$\\displaystyle{#1}$}");
|
243
|
-
|
244
241
|
// \def\iff{\DOTSB\;\Longleftrightarrow\;}
|
245
242
|
// \def\implies{\DOTSB\;\Longrightarrow\;}
|
246
243
|
// \def\impliedby{\DOTSB\;\Longleftarrow\;}
|
@@ -489,7 +486,7 @@ defineMacro(
|
|
489
486
|
defineMacro(
|
490
487
|
"\\Temml",
|
491
488
|
// eslint-disable-next-line max-len
|
492
|
-
"\\textrm{T}\\kern-0.2em\\lower{0.2em}\\textrm{E}\\kern-0.08em{\\textrm{M}\\kern-0.08em\\raise{0.2em}\\textrm{M}\\kern-0.08em\\textrm{L}}"
|
489
|
+
"\\textrm{T}\\kern-0.2em\\lower{0.2em}{\\textrm{E}}\\kern-0.08em{\\textrm{M}\\kern-0.08em\\raise{0.2em}\\textrm{M}\\kern-0.08em\\textrm{L}}"
|
493
490
|
);
|
494
491
|
|
495
492
|
// \DeclareRobustCommand\hspace{\@ifstar\@hspacer\@hspace}
|
package/src/postProcess.js
CHANGED
package/src/symbols.js
CHANGED
@@ -209,6 +209,7 @@ defineSymbol(math, rel, "\u21c1", "\\rightharpoondown", true);
|
|
209
209
|
defineSymbol(math, rel, "\u2196", "\\nwarrow", true);
|
210
210
|
defineSymbol(math, rel, "\u21cc", "\\rightleftharpoons", true);
|
211
211
|
defineSymbol(math, mathord, "\u21af", "\\lightning", true);
|
212
|
+
defineSymbol(math, mathord, "\u220E", "\\QED", true);
|
212
213
|
defineSymbol(math, mathord, "\u2030", "\\permil", true);
|
213
214
|
defineSymbol(text, textord, "\u2030", "\\permil");
|
214
215
|
|
@@ -355,6 +356,7 @@ defineSymbol(math, rel, "\u2ab7", "\\precapprox", true);
|
|
355
356
|
defineSymbol(math, rel, "\u22b2", "\\vartriangleleft");
|
356
357
|
defineSymbol(math, rel, "\u22b4", "\\trianglelefteq");
|
357
358
|
defineSymbol(math, rel, "\u22a8", "\\vDash", true);
|
359
|
+
defineSymbol(math, rel, "\u22ab", "\\VDash", true);
|
358
360
|
defineSymbol(math, rel, "\u22aa", "\\Vvdash", true);
|
359
361
|
defineSymbol(math, rel, "\u2323", "\\smallsmile");
|
360
362
|
defineSymbol(math, rel, "\u2322", "\\smallfrown");
|