katex 0.16.28 → 0.16.30
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 -3
- package/cli.js +3 -1
- package/contrib/auto-render/auto-render.js +5 -5
- package/contrib/auto-render/index.html +3 -2
- package/contrib/copy-tex/README.md +2 -2
- package/contrib/mathtex-script-type/README.md +5 -5
- package/contrib/mhchem/README.md +1 -1
- package/dist/README.md +3 -3
- package/dist/contrib/auto-render.js +4 -4
- package/dist/contrib/auto-render.min.js +1 -1
- package/dist/contrib/auto-render.mjs +2 -2
- package/dist/contrib/copy-tex.js +2 -2
- package/dist/contrib/copy-tex.min.js +1 -1
- package/dist/contrib/mathtex-script-type.min.js +1 -1
- package/dist/contrib/mhchem.min.js +1 -1
- package/dist/contrib/render-a11y-string.min.js +1 -1
- package/dist/katex-swap.css +7 -5
- package/dist/katex-swap.min.css +1 -1
- package/dist/katex.css +6 -4
- package/dist/katex.js +460 -555
- package/dist/katex.min.css +1 -1
- package/dist/katex.min.js +1 -1
- package/dist/katex.mjs +415 -508
- package/katex.js +2 -2
- package/package.json +3 -4
- package/src/MacroExpander.js +2 -2
- package/src/Parser.js +4 -3
- package/src/Settings.js +2 -2
- package/src/buildCommon.js +15 -33
- package/src/buildHTML.js +11 -9
- package/src/buildMathML.js +17 -15
- package/src/buildTree.js +5 -5
- package/src/delimiter.js +32 -40
- package/src/domTree.js +17 -17
- package/src/environments/array.js +40 -39
- package/src/environments/cd.js +10 -10
- package/src/functions/accent.js +17 -17
- package/src/functions/accentunder.js +8 -8
- package/src/functions/arrow.js +16 -16
- package/src/functions/color.js +4 -4
- package/src/functions/cr.js +4 -4
- package/src/functions/delimsizing.js +18 -19
- package/src/functions/enclose.js +15 -15
- package/src/functions/font.js +2 -3
- package/src/functions/genfrac.js +25 -20
- package/src/functions/hbox.js +4 -4
- package/src/functions/horizBrace.js +12 -12
- package/src/functions/href.js +2 -2
- package/src/functions/html.js +2 -2
- package/src/functions/htmlmathml.js +3 -2
- package/src/functions/includegraphics.js +2 -2
- package/src/functions/kern.js +4 -4
- package/src/functions/lap.js +11 -11
- package/src/functions/mathchoice.js +2 -2
- package/src/functions/mclass.js +10 -12
- package/src/functions/op.js +20 -20
- package/src/functions/operatorname.js +12 -12
- package/src/functions/ordgroup.js +3 -3
- package/src/functions/overline.js +8 -8
- package/src/functions/phantom.js +14 -14
- package/src/functions/pmb.js +4 -4
- package/src/functions/raisebox.js +4 -4
- package/src/functions/rule.js +5 -5
- package/src/functions/sizing.js +4 -4
- package/src/functions/smash.js +6 -6
- package/src/functions/sqrt.js +12 -12
- package/src/functions/styling.js +2 -2
- package/src/functions/supsub.js +13 -13
- package/src/functions/symbolsOp.js +4 -4
- package/src/functions/symbolsOrd.js +9 -9
- package/src/functions/symbolsSpacing.js +9 -9
- package/src/functions/tag.js +6 -6
- package/src/functions/text.js +2 -2
- package/src/functions/underline.js +8 -8
- package/src/functions/utils/assembleSupSub.js +9 -9
- package/src/functions/vcenter.js +4 -4
- package/src/functions/verb.js +7 -7
- package/src/macros.js +5 -2
- package/src/mathMLTree.js +5 -12
- package/src/stretchy.js +18 -28
- package/src/styles/fonts.scss +5 -3
- package/src/styles/katex-swap.scss +4 -1
- package/src/styles/katex.scss +6 -4
- package/src/utils.js +10 -41
package/src/functions/accent.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import defineFunction, {normalizeArgument} from "../defineFunction";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
3
|
+
import {makeOrd, makeSpan, makeVList, staticSvg, svgData} from "../buildCommon";
|
|
4
|
+
import {getBaseElem, isCharacterBox} from "../utils";
|
|
5
|
+
import {MathNode} from "../mathMLTree";
|
|
6
|
+
import {stretchyMathML, stretchySvg} from "../stretchy";
|
|
7
7
|
import {assertNodeType} from "../parseNode";
|
|
8
8
|
import {assertSpan, assertSymbolDomNode} from "../domTree";
|
|
9
9
|
import {makeEm} from "../units";
|
|
@@ -53,7 +53,7 @@ export const htmlBuilder: HtmlBuilderSupSub<"accent"> = (grp, options) => {
|
|
|
53
53
|
const body = html.buildGroup(base, options.havingCrampedStyle());
|
|
54
54
|
|
|
55
55
|
// Does the accent need to shift for the skew of a character?
|
|
56
|
-
const mustShift = group.isShifty &&
|
|
56
|
+
const mustShift = group.isShifty && isCharacterBox(base);
|
|
57
57
|
|
|
58
58
|
// Calculate the skew of the accent. This is based on the line "If the
|
|
59
59
|
// nucleus is not a single character, let s = 0; otherwise set s to the
|
|
@@ -64,7 +64,7 @@ export const htmlBuilder: HtmlBuilderSupSub<"accent"> = (grp, options) => {
|
|
|
64
64
|
if (mustShift) {
|
|
65
65
|
// If the base is a character box, then we want the skew of the
|
|
66
66
|
// innermost character. To do that, we find the innermost character:
|
|
67
|
-
const baseChar =
|
|
67
|
+
const baseChar = getBaseElem(base);
|
|
68
68
|
// Then, we render its group to get the symbol inside it
|
|
69
69
|
const baseGroup = html.buildGroup(baseChar, options.havingCrampedStyle());
|
|
70
70
|
// Finally, we pull the skew off of the symbol.
|
|
@@ -95,10 +95,10 @@ export const htmlBuilder: HtmlBuilderSupSub<"accent"> = (grp, options) => {
|
|
|
95
95
|
// render combining characters when not preceded by a character.
|
|
96
96
|
// So now we use an SVG.
|
|
97
97
|
// If Safari reforms, we should consider reverting to the glyph.
|
|
98
|
-
accent =
|
|
99
|
-
width =
|
|
98
|
+
accent = staticSvg("vec", options);
|
|
99
|
+
width = svgData.vec[1];
|
|
100
100
|
} else {
|
|
101
|
-
accent =
|
|
101
|
+
accent = makeOrd({mode: group.mode, text: group.label},
|
|
102
102
|
options, "textord");
|
|
103
103
|
accent = assertSymbolDomNode(accent);
|
|
104
104
|
// Remove the italic correction of the accent, because it only serves to
|
|
@@ -110,7 +110,7 @@ export const htmlBuilder: HtmlBuilderSupSub<"accent"> = (grp, options) => {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
accentBody =
|
|
113
|
+
accentBody = makeSpan(["accent-body"], [accent]);
|
|
114
114
|
|
|
115
115
|
// "Full" accents expand the width of the resulting symbol to be
|
|
116
116
|
// at least the width of the accent, and overlap directly onto the
|
|
@@ -140,7 +140,7 @@ export const htmlBuilder: HtmlBuilderSupSub<"accent"> = (grp, options) => {
|
|
|
140
140
|
accentBody.style.top = ".2em";
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
accentBody =
|
|
143
|
+
accentBody = makeVList({
|
|
144
144
|
positionType: "firstBaseline",
|
|
145
145
|
children: [
|
|
146
146
|
{type: "elem", elem: body},
|
|
@@ -150,9 +150,9 @@ export const htmlBuilder: HtmlBuilderSupSub<"accent"> = (grp, options) => {
|
|
|
150
150
|
}, options);
|
|
151
151
|
|
|
152
152
|
} else {
|
|
153
|
-
accentBody =
|
|
153
|
+
accentBody = stretchySvg(group, options);
|
|
154
154
|
|
|
155
|
-
accentBody =
|
|
155
|
+
accentBody = makeVList({
|
|
156
156
|
positionType: "firstBaseline",
|
|
157
157
|
children: [
|
|
158
158
|
{type: "elem", elem: body},
|
|
@@ -172,7 +172,7 @@ export const htmlBuilder: HtmlBuilderSupSub<"accent"> = (grp, options) => {
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
const accentWrap =
|
|
175
|
-
|
|
175
|
+
makeSpan(["mord", "accent"], [accentBody], options);
|
|
176
176
|
|
|
177
177
|
if (supSubGroup) {
|
|
178
178
|
// Here, we replace the "base" child of the supsub with our newly
|
|
@@ -195,10 +195,10 @@ export const htmlBuilder: HtmlBuilderSupSub<"accent"> = (grp, options) => {
|
|
|
195
195
|
const mathmlBuilder: MathMLBuilder<"accent"> = (group, options) => {
|
|
196
196
|
const accentNode =
|
|
197
197
|
group.isStretchy ?
|
|
198
|
-
|
|
199
|
-
new
|
|
198
|
+
stretchyMathML(group.label) :
|
|
199
|
+
new MathNode("mo", [mml.makeText(group.label, group.mode)]);
|
|
200
200
|
|
|
201
|
-
const node = new
|
|
201
|
+
const node = new MathNode(
|
|
202
202
|
"mover",
|
|
203
203
|
[mml.buildGroup(group.base, options), accentNode]);
|
|
204
204
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
// Horizontal overlap functions
|
|
3
3
|
import defineFunction from "../defineFunction";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
4
|
+
import {makeSpan, makeVList} from "../buildCommon";
|
|
5
|
+
import {MathNode} from "../mathMLTree";
|
|
6
|
+
import {stretchyMathML, stretchySvg} from "../stretchy";
|
|
7
7
|
|
|
8
8
|
import * as html from "../buildHTML";
|
|
9
9
|
import * as mml from "../buildMathML";
|
|
@@ -32,11 +32,11 @@ defineFunction({
|
|
|
32
32
|
// Treat under accents much like underlines.
|
|
33
33
|
const innerGroup = html.buildGroup(group.base, options);
|
|
34
34
|
|
|
35
|
-
const accentBody =
|
|
35
|
+
const accentBody = stretchySvg(group, options);
|
|
36
36
|
const kern = group.label === "\\utilde" ? 0.12 : 0;
|
|
37
37
|
|
|
38
38
|
// Generate the vlist, with the appropriate kerns
|
|
39
|
-
const vlist =
|
|
39
|
+
const vlist = makeVList({
|
|
40
40
|
positionType: "top",
|
|
41
41
|
positionData: innerGroup.height,
|
|
42
42
|
children: [
|
|
@@ -46,11 +46,11 @@ defineFunction({
|
|
|
46
46
|
],
|
|
47
47
|
}, options);
|
|
48
48
|
|
|
49
|
-
return
|
|
49
|
+
return makeSpan(["mord", "accentunder"], [vlist], options);
|
|
50
50
|
},
|
|
51
51
|
mathmlBuilder: (group, options) => {
|
|
52
|
-
const accentNode =
|
|
53
|
-
const node = new
|
|
52
|
+
const accentNode = stretchyMathML(group.label);
|
|
53
|
+
const node = new MathNode(
|
|
54
54
|
"munder",
|
|
55
55
|
[mml.buildGroup(group.base, options), accentNode]
|
|
56
56
|
);
|
package/src/functions/arrow.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import defineFunction from "../defineFunction";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
3
|
+
import {makeSpan, makeVList, wrapFragment} from "../buildCommon";
|
|
4
|
+
import {MathNode} from "../mathMLTree";
|
|
5
|
+
import {stretchyMathML, stretchySvg} from "../stretchy";
|
|
6
6
|
|
|
7
7
|
import * as html from "../buildHTML";
|
|
8
8
|
import * as mml from "../buildMathML";
|
|
@@ -11,7 +11,7 @@ import type {ParseNode} from "../parseNode";
|
|
|
11
11
|
|
|
12
12
|
// Helper function
|
|
13
13
|
const paddedNode = group => {
|
|
14
|
-
const node = new
|
|
14
|
+
const node = new MathNode("mpadded", group ? [group] : []);
|
|
15
15
|
node.setAttribute("width", "+0.6em");
|
|
16
16
|
node.setAttribute("lspace", "0.3em");
|
|
17
17
|
return node;
|
|
@@ -57,7 +57,7 @@ defineFunction({
|
|
|
57
57
|
// Some groups can return document fragments. Handle those by wrapping
|
|
58
58
|
// them in a span.
|
|
59
59
|
let newOptions = options.havingStyle(style.sup());
|
|
60
|
-
const upperGroup =
|
|
60
|
+
const upperGroup = wrapFragment(
|
|
61
61
|
html.buildGroup(group.body, newOptions, options), options);
|
|
62
62
|
const arrowPrefix = group.label.slice(0, 2) === "\\x" ? "x" : "cd";
|
|
63
63
|
upperGroup.classes.push(arrowPrefix + "-arrow-pad");
|
|
@@ -66,14 +66,14 @@ defineFunction({
|
|
|
66
66
|
if (group.below) {
|
|
67
67
|
// Build the lower group
|
|
68
68
|
newOptions = options.havingStyle(style.sub());
|
|
69
|
-
lowerGroup =
|
|
69
|
+
lowerGroup = wrapFragment(
|
|
70
70
|
html.buildGroup(group.below, newOptions, options), options);
|
|
71
71
|
lowerGroup.classes.push(arrowPrefix + "-arrow-pad");
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
const arrowBody =
|
|
74
|
+
const arrowBody = stretchySvg(group, options);
|
|
75
75
|
|
|
76
|
-
// Re shift: Note that
|
|
76
|
+
// Re shift: Note that stretchySvg returned arrowBody.depth = 0.
|
|
77
77
|
// The point we want on the math axis is at 0.5 * arrowBody.height.
|
|
78
78
|
const arrowShift = -options.fontMetrics().axisHeight +
|
|
79
79
|
0.5 * arrowBody.height;
|
|
@@ -90,7 +90,7 @@ defineFunction({
|
|
|
90
90
|
const lowerShift = -options.fontMetrics().axisHeight
|
|
91
91
|
+ lowerGroup.height + 0.5 * arrowBody.height
|
|
92
92
|
+ 0.111;
|
|
93
|
-
vlist =
|
|
93
|
+
vlist = makeVList({
|
|
94
94
|
positionType: "individualShift",
|
|
95
95
|
children: [
|
|
96
96
|
{type: "elem", elem: upperGroup, shift: upperShift},
|
|
@@ -99,7 +99,7 @@ defineFunction({
|
|
|
99
99
|
],
|
|
100
100
|
}, options);
|
|
101
101
|
} else {
|
|
102
|
-
vlist =
|
|
102
|
+
vlist = makeVList({
|
|
103
103
|
positionType: "individualShift",
|
|
104
104
|
children: [
|
|
105
105
|
{type: "elem", elem: upperGroup, shift: upperShift},
|
|
@@ -111,10 +111,10 @@ defineFunction({
|
|
|
111
111
|
// $FlowFixMe: Replace this with passing "svg-align" into makeVList.
|
|
112
112
|
vlist.children[0].children[0].children[1].classes.push("svg-align");
|
|
113
113
|
|
|
114
|
-
return
|
|
114
|
+
return makeSpan(["mrel", "x-arrow"], [vlist], options);
|
|
115
115
|
},
|
|
116
116
|
mathmlBuilder(group, options) {
|
|
117
|
-
const arrowNode =
|
|
117
|
+
const arrowNode = stretchyMathML(group.label);
|
|
118
118
|
arrowNode.setAttribute(
|
|
119
119
|
"minsize", group.label.charAt(0) === "x" ? "1.75em" : "3.0em"
|
|
120
120
|
);
|
|
@@ -124,20 +124,20 @@ defineFunction({
|
|
|
124
124
|
const upperNode = paddedNode(mml.buildGroup(group.body, options));
|
|
125
125
|
if (group.below) {
|
|
126
126
|
const lowerNode = paddedNode(mml.buildGroup(group.below, options));
|
|
127
|
-
node = new
|
|
127
|
+
node = new MathNode(
|
|
128
128
|
"munderover", [arrowNode, lowerNode, upperNode]
|
|
129
129
|
);
|
|
130
130
|
} else {
|
|
131
|
-
node = new
|
|
131
|
+
node = new MathNode("mover", [arrowNode, upperNode]);
|
|
132
132
|
}
|
|
133
133
|
} else if (group.below) {
|
|
134
134
|
const lowerNode = paddedNode(mml.buildGroup(group.below, options));
|
|
135
|
-
node = new
|
|
135
|
+
node = new MathNode("munder", [arrowNode, lowerNode]);
|
|
136
136
|
} else {
|
|
137
137
|
// This should never happen.
|
|
138
138
|
// Parser.js throws an error if there is no argument.
|
|
139
139
|
node = paddedNode();
|
|
140
|
-
node = new
|
|
140
|
+
node = new MathNode("mover", [arrowNode, node]);
|
|
141
141
|
}
|
|
142
142
|
return node;
|
|
143
143
|
},
|
package/src/functions/color.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import defineFunction, {ordargument} from "../defineFunction";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import {makeFragment} from "../buildCommon";
|
|
4
|
+
import {MathNode} from "../mathMLTree";
|
|
5
5
|
import {assertNodeType} from "../parseNode";
|
|
6
6
|
|
|
7
7
|
import type {AnyParseNode} from '../parseNode';
|
|
@@ -20,14 +20,14 @@ const htmlBuilder = (group, options) => {
|
|
|
20
20
|
// To accomplish this, we wrap the results in a fragment, so the inner
|
|
21
21
|
// elements will be able to directly interact with their neighbors. For
|
|
22
22
|
// example, `\color{red}{2 +} 3` has the same spacing as `2 + 3`
|
|
23
|
-
return
|
|
23
|
+
return makeFragment(elements);
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
const mathmlBuilder = (group, options) => {
|
|
27
27
|
const inner = mml.buildExpression(group.body,
|
|
28
28
|
options.withColor(group.color));
|
|
29
29
|
|
|
30
|
-
const node = new
|
|
30
|
+
const node = new MathNode("mstyle", inner);
|
|
31
31
|
|
|
32
32
|
node.setAttribute("mathcolor", group.color);
|
|
33
33
|
|
package/src/functions/cr.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// Row breaks within tabular environments, and line breaks at top level
|
|
3
3
|
|
|
4
4
|
import defineFunction from "../defineFunction";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import {makeSpan} from "../buildCommon";
|
|
6
|
+
import {MathNode} from "../mathMLTree";
|
|
7
7
|
import {calculateSize, makeEm} from "../units";
|
|
8
8
|
import {assertNodeType} from "../parseNode";
|
|
9
9
|
|
|
@@ -36,7 +36,7 @@ defineFunction({
|
|
|
36
36
|
// not within tabular/array environments.
|
|
37
37
|
|
|
38
38
|
htmlBuilder(group, options) {
|
|
39
|
-
const span =
|
|
39
|
+
const span = makeSpan(["mspace"], [], options);
|
|
40
40
|
if (group.newLine) {
|
|
41
41
|
span.classes.push("newline");
|
|
42
42
|
if (group.size) {
|
|
@@ -48,7 +48,7 @@ defineFunction({
|
|
|
48
48
|
},
|
|
49
49
|
|
|
50
50
|
mathmlBuilder(group, options) {
|
|
51
|
-
const node = new
|
|
51
|
+
const node = new MathNode("mspace");
|
|
52
52
|
if (group.newLine) {
|
|
53
53
|
node.setAttribute("linebreak", "newline");
|
|
54
54
|
if (group.size) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
import
|
|
2
|
+
import {makeSpan} from "../buildCommon";
|
|
3
3
|
import defineFunction from "../defineFunction";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import {makeLeftRightDelim, makeSizedDelim, sizeToMaxHeight} from "../delimiter";
|
|
5
|
+
import {MathNode} from "../mathMLTree";
|
|
6
6
|
import ParseError from "../ParseError";
|
|
7
7
|
import {assertNodeType, checkSymbolNodeType} from "../parseNode";
|
|
8
8
|
import {makeEm} from "../units";
|
|
@@ -34,7 +34,7 @@ const delimiterSizes = {
|
|
|
34
34
|
"\\Bigg" : {mclass: "mord", size: 4},
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
const delimiters = [
|
|
37
|
+
const delimiters = new Set([
|
|
38
38
|
"(", "\\lparen", ")", "\\rparen",
|
|
39
39
|
"[", "\\lbrack", "]", "\\rbrack",
|
|
40
40
|
"\\{", "\\lbrace", "\\}", "\\rbrace",
|
|
@@ -50,7 +50,7 @@ const delimiters = [
|
|
|
50
50
|
"\\downarrow", "\\Downarrow",
|
|
51
51
|
"\\updownarrow", "\\Updownarrow",
|
|
52
52
|
".",
|
|
53
|
-
];
|
|
53
|
+
]);
|
|
54
54
|
|
|
55
55
|
type IsMiddle = {delim: string, options: Options};
|
|
56
56
|
|
|
@@ -60,7 +60,7 @@ function checkDelimiter(
|
|
|
60
60
|
context: FunctionContext,
|
|
61
61
|
): SymbolParseNode {
|
|
62
62
|
const symDelim = checkSymbolNodeType(delim);
|
|
63
|
-
if (symDelim && delimiters.
|
|
63
|
+
if (symDelim && delimiters.has(symDelim.text)) {
|
|
64
64
|
return symDelim;
|
|
65
65
|
} else if (symDelim) {
|
|
66
66
|
throw new ParseError(
|
|
@@ -98,11 +98,10 @@ defineFunction({
|
|
|
98
98
|
if (group.delim === ".") {
|
|
99
99
|
// Empty delimiters still count as elements, even though they don't
|
|
100
100
|
// show anything.
|
|
101
|
-
return
|
|
101
|
+
return makeSpan([group.mclass]);
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
return delimiter.sizedDelim(
|
|
104
|
+
return makeSizedDelim(
|
|
106
105
|
group.delim, group.size, options, group.mode, [group.mclass]);
|
|
107
106
|
},
|
|
108
107
|
mathmlBuilder: (group) => {
|
|
@@ -112,7 +111,7 @@ defineFunction({
|
|
|
112
111
|
children.push(mml.makeText(group.delim, group.mode));
|
|
113
112
|
}
|
|
114
113
|
|
|
115
|
-
const node = new
|
|
114
|
+
const node = new MathNode("mo", children);
|
|
116
115
|
|
|
117
116
|
if (group.mclass === "mopen" ||
|
|
118
117
|
group.mclass === "mclose") {
|
|
@@ -126,7 +125,7 @@ defineFunction({
|
|
|
126
125
|
}
|
|
127
126
|
|
|
128
127
|
node.setAttribute("stretchy", "true");
|
|
129
|
-
const size = makeEm(
|
|
128
|
+
const size = makeEm(sizeToMaxHeight[group.size]);
|
|
130
129
|
node.setAttribute("minsize", size);
|
|
131
130
|
node.setAttribute("maxsize", size);
|
|
132
131
|
|
|
@@ -232,7 +231,7 @@ defineFunction({
|
|
|
232
231
|
} else {
|
|
233
232
|
// Otherwise, use leftRightDelim to generate the correct sized
|
|
234
233
|
// delimiter.
|
|
235
|
-
leftDelim =
|
|
234
|
+
leftDelim = makeLeftRightDelim(
|
|
236
235
|
group.left, innerHeight, innerDepth, options,
|
|
237
236
|
group.mode, ["mopen"]);
|
|
238
237
|
}
|
|
@@ -249,7 +248,7 @@ defineFunction({
|
|
|
249
248
|
const isMiddle: IsMiddle = middleDelim.isMiddle;
|
|
250
249
|
if (isMiddle) {
|
|
251
250
|
// Apply the options that were active when \middle was called
|
|
252
|
-
inner[i] =
|
|
251
|
+
inner[i] = makeLeftRightDelim(
|
|
253
252
|
isMiddle.delim, innerHeight, innerDepth,
|
|
254
253
|
isMiddle.options, group.mode, []);
|
|
255
254
|
}
|
|
@@ -263,21 +262,21 @@ defineFunction({
|
|
|
263
262
|
} else {
|
|
264
263
|
const colorOptions = group.rightColor ?
|
|
265
264
|
options.withColor(group.rightColor) : options;
|
|
266
|
-
rightDelim =
|
|
265
|
+
rightDelim = makeLeftRightDelim(
|
|
267
266
|
group.right, innerHeight, innerDepth, colorOptions,
|
|
268
267
|
group.mode, ["mclose"]);
|
|
269
268
|
}
|
|
270
269
|
// Add it to the end of the expression.
|
|
271
270
|
inner.push(rightDelim);
|
|
272
271
|
|
|
273
|
-
return
|
|
272
|
+
return makeSpan(["minner"], inner, options);
|
|
274
273
|
},
|
|
275
274
|
mathmlBuilder: (group, options) => {
|
|
276
275
|
assertParsed(group);
|
|
277
276
|
const inner = mml.buildExpression(group.body, options);
|
|
278
277
|
|
|
279
278
|
if (group.left !== ".") {
|
|
280
|
-
const leftNode = new
|
|
279
|
+
const leftNode = new MathNode(
|
|
281
280
|
"mo", [mml.makeText(group.left, group.mode)]);
|
|
282
281
|
|
|
283
282
|
leftNode.setAttribute("fence", "true");
|
|
@@ -286,7 +285,7 @@ defineFunction({
|
|
|
286
285
|
}
|
|
287
286
|
|
|
288
287
|
if (group.right !== ".") {
|
|
289
|
-
const rightNode = new
|
|
288
|
+
const rightNode = new MathNode(
|
|
290
289
|
"mo", [mml.makeText(group.right, group.mode)]);
|
|
291
290
|
|
|
292
291
|
rightNode.setAttribute("fence", "true");
|
|
@@ -326,7 +325,7 @@ defineFunction({
|
|
|
326
325
|
if (group.delim === ".") {
|
|
327
326
|
middleDelim = html.makeNullDelimiter(options, []);
|
|
328
327
|
} else {
|
|
329
|
-
middleDelim =
|
|
328
|
+
middleDelim = makeSizedDelim(
|
|
330
329
|
group.delim, 1, options,
|
|
331
330
|
group.mode, []);
|
|
332
331
|
|
|
@@ -348,7 +347,7 @@ defineFunction({
|
|
|
348
347
|
const textNode = (group.delim === "\\vert" || group.delim === "|")
|
|
349
348
|
? mml.makeText("|", "text")
|
|
350
349
|
: mml.makeText(group.delim, group.mode);
|
|
351
|
-
const middleNode = new
|
|
350
|
+
const middleNode = new MathNode("mo", [textNode]);
|
|
352
351
|
middleNode.setAttribute("fence", "true");
|
|
353
352
|
// MathML gives 5/18em spacing to each <mo> element.
|
|
354
353
|
// \middle should get delimiter spacing instead.
|
package/src/functions/enclose.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import defineFunction from "../defineFunction";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
3
|
+
import {makeSpan, makeSvgSpan, makeVList, wrapFragment} from "../buildCommon";
|
|
4
|
+
import {isCharacterBox} from "../utils";
|
|
5
|
+
import {MathNode} from "../mathMLTree";
|
|
6
|
+
import {stretchyEnclose} from "../stretchy";
|
|
7
7
|
import {phasePath} from "../svgGeometry";
|
|
8
8
|
import {PathNode, SvgNode} from "../domTree";
|
|
9
9
|
import {calculateSize, makeEm} from "../units";
|
|
@@ -17,7 +17,7 @@ const htmlBuilder = (group, options) => {
|
|
|
17
17
|
// \cancel, \bcancel, \xcancel, \sout, \fbox, \colorbox, \fcolorbox, \phase
|
|
18
18
|
// Some groups can return document fragments. Handle those by wrapping
|
|
19
19
|
// them in a span.
|
|
20
|
-
const inner =
|
|
20
|
+
const inner = wrapFragment(
|
|
21
21
|
html.buildGroup(group.body, options), options);
|
|
22
22
|
|
|
23
23
|
const label = group.label.slice(1);
|
|
@@ -30,10 +30,10 @@ const htmlBuilder = (group, options) => {
|
|
|
30
30
|
// We don't know the width of a group, so as a proxy, we test if
|
|
31
31
|
// the subject is a single character. This captures most of the
|
|
32
32
|
// subjects that should get the "tall" treatment.
|
|
33
|
-
const isSingleChar =
|
|
33
|
+
const isSingleChar = isCharacterBox(group.body);
|
|
34
34
|
|
|
35
35
|
if (label === "sout") {
|
|
36
|
-
img =
|
|
36
|
+
img = makeSpan(["stretchy", "sout"]);
|
|
37
37
|
img.height = options.fontMetrics().defaultRuleThickness / scale;
|
|
38
38
|
imgShift = -0.5 * options.fontMetrics().xHeight;
|
|
39
39
|
|
|
@@ -60,7 +60,7 @@ const htmlBuilder = (group, options) => {
|
|
|
60
60
|
"preserveAspectRatio": "xMinYMin slice",
|
|
61
61
|
});
|
|
62
62
|
// Wrap it in a span with overflow: hidden.
|
|
63
|
-
img =
|
|
63
|
+
img = makeSvgSpan(["hide-tail"], [svgNode], options);
|
|
64
64
|
img.style.height = makeEm(angleHeight);
|
|
65
65
|
imgShift = inner.depth + lineWeight + clearance;
|
|
66
66
|
|
|
@@ -101,7 +101,7 @@ const htmlBuilder = (group, options) => {
|
|
|
101
101
|
bottomPad = topPad;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
img =
|
|
104
|
+
img = stretchyEnclose(inner, label, topPad, bottomPad, options);
|
|
105
105
|
if (/fbox|boxed|fcolorbox/.test(label)) {
|
|
106
106
|
img.style.borderStyle = "solid";
|
|
107
107
|
img.style.borderWidth = makeEm(ruleThickness);
|
|
@@ -121,7 +121,7 @@ const htmlBuilder = (group, options) => {
|
|
|
121
121
|
|
|
122
122
|
let vlist;
|
|
123
123
|
if (group.backgroundColor) {
|
|
124
|
-
vlist =
|
|
124
|
+
vlist = makeVList({
|
|
125
125
|
positionType: "individualShift",
|
|
126
126
|
children: [
|
|
127
127
|
// Put the color background behind inner;
|
|
@@ -131,7 +131,7 @@ const htmlBuilder = (group, options) => {
|
|
|
131
131
|
}, options);
|
|
132
132
|
} else {
|
|
133
133
|
const classes = /cancel|phase/.test(label) ? ["svg-align"] : [];
|
|
134
|
-
vlist =
|
|
134
|
+
vlist = makeVList({
|
|
135
135
|
positionType: "individualShift",
|
|
136
136
|
children: [
|
|
137
137
|
// Write the \cancel stroke on top of inner.
|
|
@@ -159,16 +159,16 @@ const htmlBuilder = (group, options) => {
|
|
|
159
159
|
|
|
160
160
|
if (/cancel/.test(label) && !isSingleChar) {
|
|
161
161
|
// cancel does not create horiz space for its line extension.
|
|
162
|
-
return
|
|
162
|
+
return makeSpan(["mord", "cancel-lap"], [vlist], options);
|
|
163
163
|
} else {
|
|
164
|
-
return
|
|
164
|
+
return makeSpan(["mord"], [vlist], options);
|
|
165
165
|
}
|
|
166
166
|
};
|
|
167
167
|
|
|
168
168
|
const mathmlBuilder = (group, options) => {
|
|
169
169
|
let fboxsep = 0;
|
|
170
|
-
const node = new
|
|
171
|
-
|
|
170
|
+
const node = new MathNode(
|
|
171
|
+
group.label.includes("colorbox") ? "mpadded" : "menclose",
|
|
172
172
|
[mml.buildGroup(group.body, options)]
|
|
173
173
|
);
|
|
174
174
|
switch (group.label) {
|
package/src/functions/font.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import {binrelClass} from "./mclass";
|
|
5
5
|
import defineFunction, {normalizeArgument} from "../defineFunction";
|
|
6
|
-
import
|
|
6
|
+
import {isCharacterBox} from "../utils";
|
|
7
7
|
|
|
8
8
|
import * as html from "../buildHTML";
|
|
9
9
|
import * as mml from "../buildMathML";
|
|
@@ -71,7 +71,6 @@ defineFunction({
|
|
|
71
71
|
},
|
|
72
72
|
handler: ({parser}, args) => {
|
|
73
73
|
const body = args[0];
|
|
74
|
-
const isCharacterBox = utils.isCharacterBox(body);
|
|
75
74
|
// amsbsy.sty's \boldsymbol uses \binrel spacing to inherit the
|
|
76
75
|
// argument's bin|rel|ord status
|
|
77
76
|
return {
|
|
@@ -86,7 +85,7 @@ defineFunction({
|
|
|
86
85
|
body,
|
|
87
86
|
},
|
|
88
87
|
],
|
|
89
|
-
isCharacterBox: isCharacterBox,
|
|
88
|
+
isCharacterBox: isCharacterBox(body),
|
|
90
89
|
};
|
|
91
90
|
},
|
|
92
91
|
});
|