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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import {defineFunctionBuilders} from "../defineFunction";
|
|
3
|
-
import
|
|
3
|
+
import {makeFragment, makeSpan} from "../buildCommon";
|
|
4
4
|
|
|
5
5
|
import * as html from "../buildHTML";
|
|
6
6
|
import * as mml from "../buildMathML";
|
|
@@ -9,10 +9,10 @@ defineFunctionBuilders({
|
|
|
9
9
|
type: "ordgroup",
|
|
10
10
|
htmlBuilder(group, options) {
|
|
11
11
|
if (group.semisimple) {
|
|
12
|
-
return
|
|
12
|
+
return makeFragment(
|
|
13
13
|
html.buildExpression(group.body, options, false));
|
|
14
14
|
}
|
|
15
|
-
return
|
|
15
|
+
return makeSpan(
|
|
16
16
|
["mord"], html.buildExpression(group.body, options, true), options);
|
|
17
17
|
},
|
|
18
18
|
mathmlBuilder(group, options) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import defineFunction from "../defineFunction";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import {makeLineSpan, makeSpan, makeVList} from "../buildCommon";
|
|
4
|
+
import {MathNode, TextNode} from "../mathMLTree";
|
|
5
5
|
|
|
6
6
|
import * as html from "../buildHTML";
|
|
7
7
|
import * as mml from "../buildMathML";
|
|
@@ -28,11 +28,11 @@ defineFunction({
|
|
|
28
28
|
options.havingCrampedStyle());
|
|
29
29
|
|
|
30
30
|
// Create the line above the body
|
|
31
|
-
const line =
|
|
31
|
+
const line = makeLineSpan("overline-line", options);
|
|
32
32
|
|
|
33
33
|
// Generate the vlist, with the appropriate kerns
|
|
34
34
|
const defaultRuleThickness = options.fontMetrics().defaultRuleThickness;
|
|
35
|
-
const vlist =
|
|
35
|
+
const vlist = makeVList({
|
|
36
36
|
positionType: "firstBaseline",
|
|
37
37
|
children: [
|
|
38
38
|
{type: "elem", elem: innerGroup},
|
|
@@ -42,14 +42,14 @@ defineFunction({
|
|
|
42
42
|
],
|
|
43
43
|
}, options);
|
|
44
44
|
|
|
45
|
-
return
|
|
45
|
+
return makeSpan(["mord", "overline"], [vlist], options);
|
|
46
46
|
},
|
|
47
47
|
mathmlBuilder(group, options) {
|
|
48
|
-
const operator = new
|
|
49
|
-
"mo", [new
|
|
48
|
+
const operator = new MathNode(
|
|
49
|
+
"mo", [new TextNode("\u203e")]);
|
|
50
50
|
operator.setAttribute("stretchy", "true");
|
|
51
51
|
|
|
52
|
-
const node = new
|
|
52
|
+
const node = new MathNode(
|
|
53
53
|
"mover",
|
|
54
54
|
[mml.buildGroup(group.body, options), operator]);
|
|
55
55
|
node.setAttribute("accent", "true");
|
package/src/functions/phantom.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import defineFunction, {ordargument} from "../defineFunction";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import {makeFragment, makeSpan, makeVList} from "../buildCommon";
|
|
4
|
+
import {MathNode} from "../mathMLTree";
|
|
5
5
|
|
|
6
6
|
import * as html from "../buildHTML";
|
|
7
7
|
import * as mml from "../buildMathML";
|
|
@@ -30,11 +30,11 @@ defineFunction({
|
|
|
30
30
|
|
|
31
31
|
// \phantom isn't supposed to affect the elements it contains.
|
|
32
32
|
// See "color" for more details.
|
|
33
|
-
return
|
|
33
|
+
return makeFragment(elements);
|
|
34
34
|
},
|
|
35
35
|
mathmlBuilder: (group, options) => {
|
|
36
36
|
const inner = mml.buildExpression(group.body, options);
|
|
37
|
-
return new
|
|
37
|
+
return new MathNode("mphantom", inner);
|
|
38
38
|
},
|
|
39
39
|
});
|
|
40
40
|
|
|
@@ -54,7 +54,7 @@ defineFunction({
|
|
|
54
54
|
};
|
|
55
55
|
},
|
|
56
56
|
htmlBuilder: (group, options) => {
|
|
57
|
-
let node =
|
|
57
|
+
let node = makeSpan(
|
|
58
58
|
[], [html.buildGroup(group.body, options.withPhantom())]);
|
|
59
59
|
node.height = 0;
|
|
60
60
|
node.depth = 0;
|
|
@@ -66,18 +66,18 @@ defineFunction({
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
// See smash for comment re: use of makeVList
|
|
69
|
-
node =
|
|
69
|
+
node = makeVList({
|
|
70
70
|
positionType: "firstBaseline",
|
|
71
71
|
children: [{type: "elem", elem: node}],
|
|
72
72
|
}, options);
|
|
73
73
|
|
|
74
74
|
// For spacing, TeX treats \smash as a math group (same spacing as ord).
|
|
75
|
-
return
|
|
75
|
+
return makeSpan(["mord"], [node], options);
|
|
76
76
|
},
|
|
77
77
|
mathmlBuilder: (group, options) => {
|
|
78
78
|
const inner = mml.buildExpression(ordargument(group.body), options);
|
|
79
|
-
const phantom = new
|
|
80
|
-
const node = new
|
|
79
|
+
const phantom = new MathNode("mphantom", inner);
|
|
80
|
+
const node = new MathNode("mpadded", [phantom]);
|
|
81
81
|
node.setAttribute("height", "0px");
|
|
82
82
|
node.setAttribute("depth", "0px");
|
|
83
83
|
return node;
|
|
@@ -100,17 +100,17 @@ defineFunction({
|
|
|
100
100
|
};
|
|
101
101
|
},
|
|
102
102
|
htmlBuilder: (group, options) => {
|
|
103
|
-
const inner =
|
|
103
|
+
const inner = makeSpan(
|
|
104
104
|
["inner"],
|
|
105
105
|
[html.buildGroup(group.body, options.withPhantom())]);
|
|
106
|
-
const fix =
|
|
107
|
-
return
|
|
106
|
+
const fix = makeSpan(["fix"], []);
|
|
107
|
+
return makeSpan(
|
|
108
108
|
["mord", "rlap"], [inner, fix], options);
|
|
109
109
|
},
|
|
110
110
|
mathmlBuilder: (group, options) => {
|
|
111
111
|
const inner = mml.buildExpression(ordargument(group.body), options);
|
|
112
|
-
const phantom = new
|
|
113
|
-
const node = new
|
|
112
|
+
const phantom = new MathNode("mphantom", inner);
|
|
113
|
+
const node = new MathNode("mpadded", [phantom]);
|
|
114
114
|
node.setAttribute("width", "0px");
|
|
115
115
|
return node;
|
|
116
116
|
},
|
package/src/functions/pmb.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import defineFunction, {ordargument} from "../defineFunction";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import {makeSpan} from "../buildCommon";
|
|
4
|
+
import {MathNode} from "../mathMLTree";
|
|
5
5
|
import * as html from "../buildHTML";
|
|
6
6
|
import * as mml from "../buildMathML";
|
|
7
7
|
import {binrelClass} from "./mclass";
|
|
@@ -30,14 +30,14 @@ defineFunction({
|
|
|
30
30
|
},
|
|
31
31
|
htmlBuilder(group: ParseNode<"pmb">, options) {
|
|
32
32
|
const elements = html.buildExpression(group.body, options, true);
|
|
33
|
-
const node =
|
|
33
|
+
const node = makeSpan([group.mclass], elements, options);
|
|
34
34
|
node.style.textShadow = "0.02em 0.01em 0.04px";
|
|
35
35
|
return node;
|
|
36
36
|
},
|
|
37
37
|
mathmlBuilder(group: ParseNode<"pmb">, style) {
|
|
38
38
|
const inner = mml.buildExpression(group.body, style);
|
|
39
39
|
// Wrap with an <mstyle> element.
|
|
40
|
-
const node = new
|
|
40
|
+
const node = new MathNode("mstyle", inner);
|
|
41
41
|
node.setAttribute("style", "text-shadow: 0.02em 0.01em 0.04px");
|
|
42
42
|
return node;
|
|
43
43
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import defineFunction from "../defineFunction";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import {makeVList} from "../buildCommon";
|
|
4
|
+
import {MathNode} from "../mathMLTree";
|
|
5
5
|
import {assertNodeType} from "../parseNode";
|
|
6
6
|
import {calculateSize} from "../units";
|
|
7
7
|
|
|
@@ -30,14 +30,14 @@ defineFunction({
|
|
|
30
30
|
htmlBuilder(group, options) {
|
|
31
31
|
const body = html.buildGroup(group.body, options);
|
|
32
32
|
const dy = calculateSize(group.dy, options);
|
|
33
|
-
return
|
|
33
|
+
return makeVList({
|
|
34
34
|
positionType: "shift",
|
|
35
35
|
positionData: -dy,
|
|
36
36
|
children: [{type: "elem", elem: body}],
|
|
37
37
|
}, options);
|
|
38
38
|
},
|
|
39
39
|
mathmlBuilder(group, options) {
|
|
40
|
-
const node = new
|
|
40
|
+
const node = new MathNode(
|
|
41
41
|
"mpadded", [mml.buildGroup(group.body, options)]);
|
|
42
42
|
const dy = group.dy.number + group.dy.unit;
|
|
43
43
|
node.setAttribute("voffset", dy);
|
package/src/functions/rule.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
import
|
|
2
|
+
import {makeSpan} from "../buildCommon";
|
|
3
3
|
import defineFunction from "../defineFunction";
|
|
4
|
-
import
|
|
4
|
+
import {MathNode} from "../mathMLTree";
|
|
5
5
|
import {assertNodeType} from "../parseNode";
|
|
6
6
|
import {calculateSize, makeEm} from "../units";
|
|
7
7
|
|
|
@@ -29,7 +29,7 @@ defineFunction({
|
|
|
29
29
|
},
|
|
30
30
|
htmlBuilder(group, options) {
|
|
31
31
|
// Make an empty span for the rule
|
|
32
|
-
const rule =
|
|
32
|
+
const rule = makeSpan(["mord", "rule"], [], options);
|
|
33
33
|
|
|
34
34
|
// Calculate the shift, width, and height of the rule, and account for units
|
|
35
35
|
const width = calculateSize(group.width, options);
|
|
@@ -58,12 +58,12 @@ defineFunction({
|
|
|
58
58
|
const shift = (group.shift) ? calculateSize(group.shift, options) : 0;
|
|
59
59
|
const color = options.color && options.getColor() || "black";
|
|
60
60
|
|
|
61
|
-
const rule = new
|
|
61
|
+
const rule = new MathNode("mspace");
|
|
62
62
|
rule.setAttribute("mathbackground", color);
|
|
63
63
|
rule.setAttribute("width", makeEm(width));
|
|
64
64
|
rule.setAttribute("height", makeEm(height));
|
|
65
65
|
|
|
66
|
-
const wrapper = new
|
|
66
|
+
const wrapper = new MathNode("mpadded", [rule]);
|
|
67
67
|
if (shift >= 0) {
|
|
68
68
|
wrapper.setAttribute("height", makeEm(shift));
|
|
69
69
|
} else {
|
package/src/functions/sizing.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
import
|
|
2
|
+
import {makeFragment} from "../buildCommon";
|
|
3
3
|
import defineFunction from "../defineFunction";
|
|
4
|
-
import
|
|
4
|
+
import {MathNode} from "../mathMLTree";
|
|
5
5
|
import {makeEm} from "../units";
|
|
6
6
|
|
|
7
7
|
import * as html from "../buildHTML";
|
|
@@ -38,7 +38,7 @@ export function sizingGroup(
|
|
|
38
38
|
inner[i].depth *= multiplier;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
return
|
|
41
|
+
return makeFragment(inner);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
const sizeFuncs = [
|
|
@@ -77,7 +77,7 @@ defineFunction({
|
|
|
77
77
|
const newOptions = options.havingSize(group.size);
|
|
78
78
|
const inner = mml.buildExpression(group.body, newOptions);
|
|
79
79
|
|
|
80
|
-
const node = new
|
|
80
|
+
const node = new MathNode("mstyle", inner);
|
|
81
81
|
|
|
82
82
|
// TODO(emily): This doesn't produce the correct size for nested size
|
|
83
83
|
// changes, because we don't keep state of what style we're currently
|
package/src/functions/smash.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
// smash, with optional [tb], as in AMS
|
|
3
3
|
import defineFunction from "../defineFunction";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import {makeSpan, makeVList} from "../buildCommon";
|
|
5
|
+
import {MathNode} from "../mathMLTree";
|
|
6
6
|
import {assertNodeType} from "../parseNode";
|
|
7
7
|
|
|
8
8
|
import * as html from "../buildHTML";
|
|
@@ -54,7 +54,7 @@ defineFunction({
|
|
|
54
54
|
};
|
|
55
55
|
},
|
|
56
56
|
htmlBuilder: (group, options) => {
|
|
57
|
-
const node =
|
|
57
|
+
const node = makeSpan(
|
|
58
58
|
[], [html.buildGroup(group.body, options)]);
|
|
59
59
|
|
|
60
60
|
if (!group.smashHeight && !group.smashDepth) {
|
|
@@ -85,16 +85,16 @@ defineFunction({
|
|
|
85
85
|
// makeVList applies "display: table-cell", which prevents the browser
|
|
86
86
|
// from acting on that line height. So we'll call makeVList now.
|
|
87
87
|
|
|
88
|
-
const smashedNode =
|
|
88
|
+
const smashedNode = makeVList({
|
|
89
89
|
positionType: "firstBaseline",
|
|
90
90
|
children: [{type: "elem", elem: node}],
|
|
91
91
|
}, options);
|
|
92
92
|
|
|
93
93
|
// For spacing, TeX treats \hphantom as a math group (same spacing as ord).
|
|
94
|
-
return
|
|
94
|
+
return makeSpan(["mord"], [smashedNode], options);
|
|
95
95
|
},
|
|
96
96
|
mathmlBuilder: (group, options) => {
|
|
97
|
-
const node = new
|
|
97
|
+
const node = new MathNode(
|
|
98
98
|
"mpadded", [mml.buildGroup(group.body, options)]);
|
|
99
99
|
|
|
100
100
|
if (group.smashHeight) {
|
package/src/functions/sqrt.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 {makeSqrtImage} from "../delimiter";
|
|
6
6
|
import Style from "../Style";
|
|
7
7
|
import {makeEm} from "../units";
|
|
8
8
|
|
|
@@ -39,7 +39,7 @@ defineFunction({
|
|
|
39
39
|
|
|
40
40
|
// Some groups can return document fragments. Handle those by wrapping
|
|
41
41
|
// them in a span.
|
|
42
|
-
inner =
|
|
42
|
+
inner = wrapFragment(inner, options);
|
|
43
43
|
|
|
44
44
|
// Calculate the minimum size for the \surd delimiter
|
|
45
45
|
const metrics = options.fontMetrics();
|
|
@@ -58,7 +58,7 @@ defineFunction({
|
|
|
58
58
|
|
|
59
59
|
// Create a sqrt SVG of the required minimum size
|
|
60
60
|
const {span: img, ruleWidth, advanceWidth} =
|
|
61
|
-
|
|
61
|
+
makeSqrtImage(minDelimiterHeight, options);
|
|
62
62
|
|
|
63
63
|
const delimDepth = img.height - ruleWidth;
|
|
64
64
|
|
|
@@ -74,7 +74,7 @@ defineFunction({
|
|
|
74
74
|
inner.style.paddingLeft = makeEm(advanceWidth);
|
|
75
75
|
|
|
76
76
|
// Overlay the image and the argument.
|
|
77
|
-
const body =
|
|
77
|
+
const body = makeVList({
|
|
78
78
|
positionType: "firstBaseline",
|
|
79
79
|
children: [
|
|
80
80
|
{type: "elem", elem: inner, wrapperClasses: ["svg-align"]},
|
|
@@ -85,7 +85,7 @@ defineFunction({
|
|
|
85
85
|
}, options);
|
|
86
86
|
|
|
87
87
|
if (!group.index) {
|
|
88
|
-
return
|
|
88
|
+
return makeSpan(["mord", "sqrt"], [body], options);
|
|
89
89
|
} else {
|
|
90
90
|
// Handle the optional root index
|
|
91
91
|
|
|
@@ -98,28 +98,28 @@ defineFunction({
|
|
|
98
98
|
const toShift = 0.6 * (body.height - body.depth);
|
|
99
99
|
|
|
100
100
|
// Build a VList with the superscript shifted up correctly
|
|
101
|
-
const rootVList =
|
|
101
|
+
const rootVList = makeVList({
|
|
102
102
|
positionType: "shift",
|
|
103
103
|
positionData: -toShift,
|
|
104
104
|
children: [{type: "elem", elem: rootm}],
|
|
105
105
|
}, options);
|
|
106
106
|
// Add a class surrounding it so we can add on the appropriate
|
|
107
107
|
// kerning
|
|
108
|
-
const rootVListWrap =
|
|
108
|
+
const rootVListWrap = makeSpan(["root"], [rootVList]);
|
|
109
109
|
|
|
110
|
-
return
|
|
110
|
+
return makeSpan(["mord", "sqrt"],
|
|
111
111
|
[rootVListWrap, body], options);
|
|
112
112
|
}
|
|
113
113
|
},
|
|
114
114
|
mathmlBuilder(group, options) {
|
|
115
115
|
const {body, index} = group;
|
|
116
116
|
return index ?
|
|
117
|
-
new
|
|
117
|
+
new MathNode(
|
|
118
118
|
"mroot", [
|
|
119
119
|
mml.buildGroup(body, options),
|
|
120
120
|
mml.buildGroup(index, options),
|
|
121
121
|
]) :
|
|
122
|
-
new
|
|
122
|
+
new MathNode(
|
|
123
123
|
"msqrt", [mml.buildGroup(body, options)]);
|
|
124
124
|
},
|
|
125
125
|
});
|
package/src/functions/styling.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import defineFunction from "../defineFunction";
|
|
3
|
-
import
|
|
3
|
+
import {MathNode} from "../mathMLTree";
|
|
4
4
|
import Style from "../Style";
|
|
5
5
|
import {sizingGroup} from "./sizing";
|
|
6
6
|
|
|
@@ -54,7 +54,7 @@ defineFunction({
|
|
|
54
54
|
|
|
55
55
|
const inner = mml.buildExpression(group.body, newOptions);
|
|
56
56
|
|
|
57
|
-
const node = new
|
|
57
|
+
const node = new MathNode("mstyle", inner);
|
|
58
58
|
|
|
59
59
|
const styleAttributes = {
|
|
60
60
|
"display": ["0", "true"],
|
package/src/functions/supsub.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import {defineFunctionBuilders} from "../defineFunction";
|
|
3
|
-
import
|
|
3
|
+
import {makeSpan, makeVList} from "../buildCommon";
|
|
4
4
|
import {SymbolNode} from "../domTree";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import {isCharacterBox} from "../utils";
|
|
6
|
+
import {MathNode} from "../mathMLTree";
|
|
7
7
|
import {makeEm} from "../units";
|
|
8
8
|
import Style from "../Style";
|
|
9
9
|
|
|
@@ -45,7 +45,7 @@ const htmlBuilderDelegate = function(
|
|
|
45
45
|
(options.style.size === Style.DISPLAY.size || base.limits);
|
|
46
46
|
return delegate ? operatorname.htmlBuilder : null;
|
|
47
47
|
} else if (base.type === "accent") {
|
|
48
|
-
return
|
|
48
|
+
return isCharacterBox(base.base) ? accent.htmlBuilder : null;
|
|
49
49
|
} else if (base.type === "horizBrace") {
|
|
50
50
|
const isSup = !group.sub;
|
|
51
51
|
return isSup === base.isOver ? horizBrace.htmlBuilder : null;
|
|
@@ -80,11 +80,11 @@ defineFunctionBuilders({
|
|
|
80
80
|
let supShift = 0;
|
|
81
81
|
let subShift = 0;
|
|
82
82
|
|
|
83
|
-
const
|
|
83
|
+
const isCharBox = valueBase && isCharacterBox(valueBase);
|
|
84
84
|
if (valueSup) {
|
|
85
85
|
const newOptions = options.havingStyle(options.style.sup());
|
|
86
86
|
supm = html.buildGroup(valueSup, newOptions, options);
|
|
87
|
-
if (!
|
|
87
|
+
if (!isCharBox) {
|
|
88
88
|
supShift = base.height - newOptions.fontMetrics().supDrop
|
|
89
89
|
* newOptions.sizeMultiplier / options.sizeMultiplier;
|
|
90
90
|
}
|
|
@@ -93,7 +93,7 @@ defineFunctionBuilders({
|
|
|
93
93
|
if (valueSub) {
|
|
94
94
|
const newOptions = options.havingStyle(options.style.sub());
|
|
95
95
|
subm = html.buildGroup(valueSub, newOptions, options);
|
|
96
|
-
if (!
|
|
96
|
+
if (!isCharBox) {
|
|
97
97
|
subShift = base.depth + newOptions.fontMetrics().subDrop
|
|
98
98
|
* newOptions.sizeMultiplier / options.sizeMultiplier;
|
|
99
99
|
}
|
|
@@ -153,7 +153,7 @@ defineFunctionBuilders({
|
|
|
153
153
|
{type: "elem", elem: supm, shift: -supShift, marginRight},
|
|
154
154
|
];
|
|
155
155
|
|
|
156
|
-
supsub =
|
|
156
|
+
supsub = makeVList({
|
|
157
157
|
positionType: "individualShift",
|
|
158
158
|
children: vlistElem,
|
|
159
159
|
}, options);
|
|
@@ -166,7 +166,7 @@ defineFunctionBuilders({
|
|
|
166
166
|
const vlistElem =
|
|
167
167
|
[{type: "elem", elem: subm, marginLeft, marginRight}];
|
|
168
168
|
|
|
169
|
-
supsub =
|
|
169
|
+
supsub = makeVList({
|
|
170
170
|
positionType: "shift",
|
|
171
171
|
positionData: subShift,
|
|
172
172
|
children: vlistElem,
|
|
@@ -176,7 +176,7 @@ defineFunctionBuilders({
|
|
|
176
176
|
supShift = Math.max(supShift, minSupShift,
|
|
177
177
|
supm.depth + 0.25 * metrics.xHeight);
|
|
178
178
|
|
|
179
|
-
supsub =
|
|
179
|
+
supsub = makeVList({
|
|
180
180
|
positionType: "shift",
|
|
181
181
|
positionData: -supShift,
|
|
182
182
|
children: [{type: "elem", elem: supm, marginRight}],
|
|
@@ -187,8 +187,8 @@ defineFunctionBuilders({
|
|
|
187
187
|
|
|
188
188
|
// Wrap the supsub vlist in a span.msupsub to reset text-align.
|
|
189
189
|
const mclass = html.getTypeOfDomTree(base, "right") || "mord";
|
|
190
|
-
return
|
|
191
|
-
[base,
|
|
190
|
+
return makeSpan([mclass],
|
|
191
|
+
[base, makeSpan(["msupsub"], [supsub])],
|
|
192
192
|
options);
|
|
193
193
|
},
|
|
194
194
|
mathmlBuilder(group, options) {
|
|
@@ -261,7 +261,7 @@ defineFunctionBuilders({
|
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
263
|
|
|
264
|
-
return new
|
|
264
|
+
return new MathNode(nodeType, children);
|
|
265
265
|
},
|
|
266
266
|
});
|
|
267
267
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import {defineFunctionBuilders} from "../defineFunction";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import {mathsym} from "../buildCommon";
|
|
4
|
+
import {MathNode} from "../mathMLTree";
|
|
5
5
|
|
|
6
6
|
import * as mml from "../buildMathML";
|
|
7
7
|
|
|
@@ -10,11 +10,11 @@ import * as mml from "../buildMathML";
|
|
|
10
10
|
defineFunctionBuilders({
|
|
11
11
|
type: "atom",
|
|
12
12
|
htmlBuilder(group, options) {
|
|
13
|
-
return
|
|
13
|
+
return mathsym(
|
|
14
14
|
group.text, group.mode, options, ["m" + group.family]);
|
|
15
15
|
},
|
|
16
16
|
mathmlBuilder(group, options) {
|
|
17
|
-
const node = new
|
|
17
|
+
const node = new MathNode(
|
|
18
18
|
"mo", [mml.makeText(group.text, group.mode)]);
|
|
19
19
|
if (group.family === "bin") {
|
|
20
20
|
const variant = mml.getVariant(group, options);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import {defineFunctionBuilders} from "../defineFunction";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import {makeOrd} from "../buildCommon";
|
|
4
|
+
import {MathNode} from "../mathMLTree";
|
|
5
5
|
|
|
6
6
|
import * as mml from "../buildMathML";
|
|
7
7
|
|
|
@@ -19,10 +19,10 @@ const defaultVariant: {[string]: string} = {
|
|
|
19
19
|
defineFunctionBuilders({
|
|
20
20
|
type: "mathord",
|
|
21
21
|
htmlBuilder(group, options) {
|
|
22
|
-
return
|
|
22
|
+
return makeOrd(group, options, "mathord");
|
|
23
23
|
},
|
|
24
24
|
mathmlBuilder(group: ParseNode<"mathord">, options) {
|
|
25
|
-
const node = new
|
|
25
|
+
const node = new MathNode(
|
|
26
26
|
"mi",
|
|
27
27
|
[mml.makeText(group.text, group.mode, options)]);
|
|
28
28
|
|
|
@@ -37,7 +37,7 @@ defineFunctionBuilders({
|
|
|
37
37
|
defineFunctionBuilders({
|
|
38
38
|
type: "textord",
|
|
39
39
|
htmlBuilder(group, options) {
|
|
40
|
-
return
|
|
40
|
+
return makeOrd(group, options, "textord");
|
|
41
41
|
},
|
|
42
42
|
mathmlBuilder(group: ParseNode<"textord">, options) {
|
|
43
43
|
const text = mml.makeText(group.text, group.mode, options);
|
|
@@ -45,13 +45,13 @@ defineFunctionBuilders({
|
|
|
45
45
|
|
|
46
46
|
let node;
|
|
47
47
|
if (group.mode === 'text') {
|
|
48
|
-
node = new
|
|
48
|
+
node = new MathNode("mtext", [text]);
|
|
49
49
|
} else if (/[0-9]/.test(group.text)) {
|
|
50
|
-
node = new
|
|
50
|
+
node = new MathNode("mn", [text]);
|
|
51
51
|
} else if (group.text === "\\prime") {
|
|
52
|
-
node = new
|
|
52
|
+
node = new MathNode("mo", [text]);
|
|
53
53
|
} else {
|
|
54
|
-
node = new
|
|
54
|
+
node = new MathNode("mi", [text]);
|
|
55
55
|
}
|
|
56
56
|
if (variant !== defaultVariant[node.type]) {
|
|
57
57
|
node.setAttribute("mathvariant", variant);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import {defineFunctionBuilders} from "../defineFunction";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import {mathsym, makeOrd, makeSpan} from "../buildCommon";
|
|
4
|
+
import {MathNode, TextNode} from "../mathMLTree";
|
|
5
5
|
import ParseError from "../ParseError";
|
|
6
6
|
|
|
7
7
|
// A map of CSS-based spacing functions to their CSS class.
|
|
@@ -38,17 +38,17 @@ defineFunctionBuilders({
|
|
|
38
38
|
// things has an entry in the symbols table, so these will be turned
|
|
39
39
|
// into appropriate outputs.
|
|
40
40
|
if (group.mode === "text") {
|
|
41
|
-
const ord =
|
|
41
|
+
const ord = makeOrd(group, options, "textord");
|
|
42
42
|
ord.classes.push(className);
|
|
43
43
|
return ord;
|
|
44
44
|
} else {
|
|
45
|
-
return
|
|
46
|
-
[
|
|
45
|
+
return makeSpan(["mspace", className],
|
|
46
|
+
[mathsym(group.text, group.mode, options)],
|
|
47
47
|
options);
|
|
48
48
|
}
|
|
49
49
|
} else if (cssSpace.hasOwnProperty(group.text)) {
|
|
50
50
|
// Spaces based on just a CSS class.
|
|
51
|
-
return
|
|
51
|
+
return makeSpan(
|
|
52
52
|
["mspace", cssSpace[group.text]],
|
|
53
53
|
[], options);
|
|
54
54
|
} else {
|
|
@@ -59,11 +59,11 @@ defineFunctionBuilders({
|
|
|
59
59
|
let node;
|
|
60
60
|
|
|
61
61
|
if (regularSpace.hasOwnProperty(group.text)) {
|
|
62
|
-
node = new
|
|
63
|
-
"mtext", [new
|
|
62
|
+
node = new MathNode(
|
|
63
|
+
"mtext", [new TextNode("\u00a0")]);
|
|
64
64
|
} else if (cssSpace.hasOwnProperty(group.text)) {
|
|
65
65
|
// CSS-based MathML spaces (\nobreak, \allowbreak) are ignored
|
|
66
|
-
return new
|
|
66
|
+
return new MathNode("mspace");
|
|
67
67
|
} else {
|
|
68
68
|
throw new ParseError(`Unknown type of space "${group.text}"`);
|
|
69
69
|
}
|
package/src/functions/tag.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import {defineFunctionBuilders} from "../defineFunction";
|
|
3
|
-
import
|
|
3
|
+
import {MathNode} from "../mathMLTree";
|
|
4
4
|
|
|
5
5
|
import * as mml from "../buildMathML";
|
|
6
6
|
|
|
7
7
|
const pad = () => {
|
|
8
|
-
const padNode = new
|
|
8
|
+
const padNode = new MathNode("mtd", []);
|
|
9
9
|
padNode.setAttribute("width", "50%");
|
|
10
10
|
return padNode;
|
|
11
11
|
};
|
|
@@ -13,14 +13,14 @@ const pad = () => {
|
|
|
13
13
|
defineFunctionBuilders({
|
|
14
14
|
type: "tag",
|
|
15
15
|
mathmlBuilder(group, options) {
|
|
16
|
-
const table = new
|
|
17
|
-
new
|
|
16
|
+
const table = new MathNode("mtable", [
|
|
17
|
+
new MathNode("mtr", [
|
|
18
18
|
pad(),
|
|
19
|
-
new
|
|
19
|
+
new MathNode("mtd", [
|
|
20
20
|
mml.buildExpressionRow(group.body, options),
|
|
21
21
|
]),
|
|
22
22
|
pad(),
|
|
23
|
-
new
|
|
23
|
+
new MathNode("mtd", [
|
|
24
24
|
mml.buildExpressionRow(group.tag, options),
|
|
25
25
|
]),
|
|
26
26
|
]),
|
package/src/functions/text.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import defineFunction, {ordargument} from "../defineFunction";
|
|
3
|
-
import
|
|
3
|
+
import {makeSpan} from "../buildCommon";
|
|
4
4
|
|
|
5
5
|
import * as html from "../buildHTML";
|
|
6
6
|
import * as mml from "../buildMathML";
|
|
@@ -67,7 +67,7 @@ defineFunction({
|
|
|
67
67
|
htmlBuilder(group, options) {
|
|
68
68
|
const newOptions = optionsWithFont(group, options);
|
|
69
69
|
const inner = html.buildExpression(group.body, newOptions, true);
|
|
70
|
-
return
|
|
70
|
+
return makeSpan(["mord", "text"], inner, newOptions);
|
|
71
71
|
},
|
|
72
72
|
mathmlBuilder(group, options) {
|
|
73
73
|
const newOptions = optionsWithFont(group, options);
|