katex 0.10.1 → 0.10.2
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/CHANGELOG.md +51 -0
- package/README.md +4 -4
- package/cli.js +0 -0
- package/contrib/copy-tex/README.md +3 -3
- package/contrib/mathtex-script-type/README.md +5 -5
- package/contrib/mhchem/README.md +1 -1
- package/dist/README.md +4 -4
- package/dist/fonts/KaTeX_AMS-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_AMS-Regular.woff +0 -0
- package/dist/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.woff +0 -0
- package/dist/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Bold.woff +0 -0
- package/dist/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.woff +0 -0
- package/dist/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Italic.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Italic.woff +0 -0
- package/dist/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/dist/fonts/KaTeX_Main-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Main-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.woff +0 -0
- package/dist/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/dist/fonts/KaTeX_Math-Italic.ttf +0 -0
- package/dist/fonts/KaTeX_Math-Italic.woff +0 -0
- package/dist/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.woff +0 -0
- package/dist/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Script-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Script-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size1-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size1-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size2-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size2-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size3-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size3-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Size4-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Size4-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.woff +0 -0
- package/dist/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/dist/katex.css +10 -0
- package/dist/katex.js +541 -249
- package/dist/katex.min.css +1 -1
- package/dist/katex.min.js +1 -1
- package/dist/katex.mjs +418 -198
- package/package.json +1 -1
- package/src/Options.js +11 -75
- package/src/buildMathML.js +13 -3
- package/src/domTree.js +63 -0
- package/src/environments/array.js +118 -2
- package/src/fontMetrics.js +3 -2
- package/src/functions/arrow.js +15 -5
- package/src/functions/color.js +2 -37
- package/src/functions/delimsizing.js +12 -2
- package/src/functions/enclose.js +15 -3
- package/src/functions/genfrac.js +31 -12
- package/src/functions/includegraphics.js +146 -0
- package/src/functions/mclass.js +1 -0
- package/src/functions/op.js +18 -10
- package/src/functions/phantom.js +5 -2
- package/src/functions/rule.js +20 -9
- package/src/functions/supsub.js +6 -2
- package/src/functions/symbolsOp.js +4 -0
- package/src/functions/tag.js +20 -4
- package/src/functions/text.js +4 -2
- package/src/functions.js +2 -0
- package/src/katex.less +15 -0
- package/src/macros.js +144 -27
- package/src/mathMLTree.js +1 -1
- package/src/parseNode.js +20 -1
- package/src/stretchy.js +3 -1
- package/src/symbols.js +15 -15
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import defineFunction from "../defineFunction";
|
|
3
|
+
import type {Measurement} from "../units";
|
|
4
|
+
import {calculateSize, validUnit} from "../units";
|
|
5
|
+
import ParseError from "../ParseError";
|
|
6
|
+
import {Img} from "../domTree";
|
|
7
|
+
import mathMLTree from "../mathMLTree";
|
|
8
|
+
import {assertNodeType} from "../parseNode";
|
|
9
|
+
import type {CssStyle} from "../domTree";
|
|
10
|
+
|
|
11
|
+
const sizeData = function(str: string): Measurement {
|
|
12
|
+
if (/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(str)) {
|
|
13
|
+
// str is a number with no unit specified.
|
|
14
|
+
// default unit is bp, per graphix package.
|
|
15
|
+
return {number: +str, unit: "bp"};
|
|
16
|
+
} else {
|
|
17
|
+
const match = (/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/).exec(str);
|
|
18
|
+
if (!match) {
|
|
19
|
+
throw new ParseError("Invalid size: '" + str
|
|
20
|
+
+ "' in \\includegraphics");
|
|
21
|
+
}
|
|
22
|
+
const data = {
|
|
23
|
+
number: +(match[1] + match[2]), // sign + magnitude, cast to number
|
|
24
|
+
unit: match[3],
|
|
25
|
+
};
|
|
26
|
+
if (!validUnit(data)) {
|
|
27
|
+
throw new ParseError("Invalid unit: '" + data.unit
|
|
28
|
+
+ "' in \\includegraphics.");
|
|
29
|
+
}
|
|
30
|
+
return data;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
defineFunction({
|
|
35
|
+
type: "includegraphics",
|
|
36
|
+
names: ["\\includegraphics"],
|
|
37
|
+
props: {
|
|
38
|
+
numArgs: 1,
|
|
39
|
+
numOptionalArgs: 1,
|
|
40
|
+
argTypes: ["raw", "url"],
|
|
41
|
+
allowedInText: false,
|
|
42
|
+
},
|
|
43
|
+
handler: ({parser}, args, optArgs) => {
|
|
44
|
+
let width = {number: 0, unit: "em"};
|
|
45
|
+
let height = {number: 0.9, unit: "em"}; // sorta character sized.
|
|
46
|
+
let totalheight = {number: 0, unit: "em"};
|
|
47
|
+
let alt = "";
|
|
48
|
+
|
|
49
|
+
if (optArgs[0]) {
|
|
50
|
+
const attributeStr = assertNodeType(optArgs[0], "raw").string;
|
|
51
|
+
|
|
52
|
+
// Parser.js does not parse key/value pairs. We get a string.
|
|
53
|
+
const attributes = attributeStr.split(",");
|
|
54
|
+
for (let i = 0; i < attributes.length; i++) {
|
|
55
|
+
const keyVal = attributes[i].split("=");
|
|
56
|
+
if (keyVal.length === 2) {
|
|
57
|
+
const str = keyVal[1].trim();
|
|
58
|
+
switch (keyVal[0].trim()) {
|
|
59
|
+
case "alt":
|
|
60
|
+
alt = str;
|
|
61
|
+
break;
|
|
62
|
+
case "width":
|
|
63
|
+
width = sizeData(str);
|
|
64
|
+
break;
|
|
65
|
+
case "height":
|
|
66
|
+
height = sizeData(str);
|
|
67
|
+
break;
|
|
68
|
+
case "totalheight":
|
|
69
|
+
totalheight = sizeData(str);
|
|
70
|
+
break;
|
|
71
|
+
default:
|
|
72
|
+
throw new ParseError("Invalid key: '" + keyVal[0] +
|
|
73
|
+
"' in \\includegraphics.");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const src = assertNodeType(args[0], "url").url;
|
|
80
|
+
|
|
81
|
+
if (alt === "") {
|
|
82
|
+
// No alt given. Use the file name. Strip away the path.
|
|
83
|
+
alt = src;
|
|
84
|
+
alt = alt.replace(/^.*[\\/]/, '');
|
|
85
|
+
alt = alt.substring(0, alt.lastIndexOf('.'));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
type: "includegraphics",
|
|
90
|
+
mode: parser.mode,
|
|
91
|
+
alt: alt,
|
|
92
|
+
width: width,
|
|
93
|
+
height: height,
|
|
94
|
+
totalheight: totalheight,
|
|
95
|
+
src: src,
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
htmlBuilder: (group, options) => {
|
|
99
|
+
const height = calculateSize(group.height, options);
|
|
100
|
+
let depth = 0;
|
|
101
|
+
|
|
102
|
+
if (group.totalheight.number > 0) {
|
|
103
|
+
depth = calculateSize(group.totalheight, options) - height;
|
|
104
|
+
depth = Number(depth.toFixed(2));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
let width = 0;
|
|
108
|
+
if (group.width.number > 0) {
|
|
109
|
+
width = calculateSize(group.width, options);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const style: CssStyle = {height: height + depth + "em"};
|
|
113
|
+
if (width > 0) {
|
|
114
|
+
style.width = width + "em";
|
|
115
|
+
}
|
|
116
|
+
if (depth > 0) {
|
|
117
|
+
style.verticalAlign = -depth + "em";
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const node = new Img(group.src, group.alt, style);
|
|
121
|
+
node.height = height;
|
|
122
|
+
node.depth = depth;
|
|
123
|
+
|
|
124
|
+
return node;
|
|
125
|
+
},
|
|
126
|
+
mathmlBuilder: (group, options) => {
|
|
127
|
+
const node = new mathMLTree.MathNode("mglyph", []);
|
|
128
|
+
node.setAttribute("alt", group.alt);
|
|
129
|
+
|
|
130
|
+
const height = calculateSize(group.height, options);
|
|
131
|
+
let depth = 0;
|
|
132
|
+
if (group.totalheight.number > 0) {
|
|
133
|
+
depth = calculateSize(group.totalheight, options) - height;
|
|
134
|
+
depth = depth.toFixed(2);
|
|
135
|
+
node.setAttribute("valign", "-" + depth + "em");
|
|
136
|
+
}
|
|
137
|
+
node.setAttribute("height", height + depth + "em");
|
|
138
|
+
|
|
139
|
+
if (group.width.number > 0) {
|
|
140
|
+
const width = calculateSize(group.width, options);
|
|
141
|
+
node.setAttribute("width", width + "em");
|
|
142
|
+
}
|
|
143
|
+
node.setAttribute("src", group.src);
|
|
144
|
+
return node;
|
|
145
|
+
},
|
|
146
|
+
});
|
package/src/functions/mclass.js
CHANGED
package/src/functions/op.js
CHANGED
|
@@ -14,6 +14,11 @@ import * as mml from "../buildMathML";
|
|
|
14
14
|
import type {HtmlBuilderSupSub, MathMLBuilder} from "../defineFunction";
|
|
15
15
|
import type {ParseNode} from "../parseNode";
|
|
16
16
|
|
|
17
|
+
// Most operators have a large successor symbol, but these don't.
|
|
18
|
+
const noSuccessor = [
|
|
19
|
+
"\\smallint",
|
|
20
|
+
];
|
|
21
|
+
|
|
17
22
|
// NOTE: Unlike most `htmlBuilder`s, this one handles not only "op", but also
|
|
18
23
|
// "supsub" since some of them (like \int) can affect super/subscripting.
|
|
19
24
|
export const htmlBuilder: HtmlBuilderSupSub<"op"> = (grp, options) => {
|
|
@@ -37,11 +42,6 @@ export const htmlBuilder: HtmlBuilderSupSub<"op"> = (grp, options) => {
|
|
|
37
42
|
|
|
38
43
|
const style = options.style;
|
|
39
44
|
|
|
40
|
-
// Most operators have a large successor symbol, but these don't.
|
|
41
|
-
const noSuccessor = [
|
|
42
|
-
"\\smallint",
|
|
43
|
-
];
|
|
44
|
-
|
|
45
45
|
let large = false;
|
|
46
46
|
if (style.size === Style.DISPLAY.size &&
|
|
47
47
|
group.symbol &&
|
|
@@ -237,12 +237,13 @@ export const htmlBuilder: HtmlBuilderSupSub<"op"> = (grp, options) => {
|
|
|
237
237
|
const mathmlBuilder: MathMLBuilder<"op"> = (group, options) => {
|
|
238
238
|
let node;
|
|
239
239
|
|
|
240
|
-
// TODO(emily): handle big operators using the `largeop` attribute
|
|
241
|
-
|
|
242
240
|
if (group.symbol) {
|
|
243
241
|
// This is a symbol. Just add the symbol.
|
|
244
242
|
node = new mathMLTree.MathNode(
|
|
245
243
|
"mo", [mml.makeText(group.name, group.mode)]);
|
|
244
|
+
if (utils.contains(noSuccessor, group.name)) {
|
|
245
|
+
node.setAttribute("largeop", "false");
|
|
246
|
+
}
|
|
246
247
|
} else if (group.body) {
|
|
247
248
|
// This is an operator with children. Add them.
|
|
248
249
|
node = new mathMLTree.MathNode(
|
|
@@ -254,13 +255,15 @@ const mathmlBuilder: MathMLBuilder<"op"> = (group, options) => {
|
|
|
254
255
|
// operators, like \limsup.
|
|
255
256
|
node = new mathMLTree.MathNode(
|
|
256
257
|
"mi", [new mathMLTree.TextNode(group.name.slice(1))]);
|
|
257
|
-
|
|
258
258
|
// Append an <mo>⁡</mo>.
|
|
259
259
|
// ref: https://www.w3.org/TR/REC-MathML/chap3_2.html#sec3.2.4
|
|
260
260
|
const operator = new mathMLTree.MathNode("mo",
|
|
261
261
|
[mml.makeText("\u2061", "text")]);
|
|
262
|
-
|
|
263
|
-
|
|
262
|
+
if (group.parentIsSupSub) {
|
|
263
|
+
node = new mathMLTree.MathNode("mo", [node, operator]);
|
|
264
|
+
} else {
|
|
265
|
+
node = mathMLTree.newDocumentFragment([node, operator]);
|
|
266
|
+
}
|
|
264
267
|
}
|
|
265
268
|
|
|
266
269
|
return node;
|
|
@@ -302,6 +305,7 @@ defineFunction({
|
|
|
302
305
|
type: "op",
|
|
303
306
|
mode: parser.mode,
|
|
304
307
|
limits: true,
|
|
308
|
+
parentIsSupSub: false,
|
|
305
309
|
symbol: true,
|
|
306
310
|
name: fName,
|
|
307
311
|
};
|
|
@@ -324,6 +328,7 @@ defineFunction({
|
|
|
324
328
|
type: "op",
|
|
325
329
|
mode: parser.mode,
|
|
326
330
|
limits: false,
|
|
331
|
+
parentIsSupSub: false,
|
|
327
332
|
symbol: false,
|
|
328
333
|
body: ordargument(body),
|
|
329
334
|
};
|
|
@@ -363,6 +368,7 @@ defineFunction({
|
|
|
363
368
|
type: "op",
|
|
364
369
|
mode: parser.mode,
|
|
365
370
|
limits: false,
|
|
371
|
+
parentIsSupSub: false,
|
|
366
372
|
symbol: false,
|
|
367
373
|
name: funcName,
|
|
368
374
|
};
|
|
@@ -385,6 +391,7 @@ defineFunction({
|
|
|
385
391
|
type: "op",
|
|
386
392
|
mode: parser.mode,
|
|
387
393
|
limits: true,
|
|
394
|
+
parentIsSupSub: false,
|
|
388
395
|
symbol: false,
|
|
389
396
|
name: funcName,
|
|
390
397
|
};
|
|
@@ -412,6 +419,7 @@ defineFunction({
|
|
|
412
419
|
type: "op",
|
|
413
420
|
mode: parser.mode,
|
|
414
421
|
limits: false,
|
|
422
|
+
parentIsSupSub: false,
|
|
415
423
|
symbol: true,
|
|
416
424
|
name: fName,
|
|
417
425
|
};
|
package/src/functions/phantom.js
CHANGED
|
@@ -76,8 +76,10 @@ defineFunction({
|
|
|
76
76
|
},
|
|
77
77
|
mathmlBuilder: (group, options) => {
|
|
78
78
|
const inner = mml.buildExpression(ordargument(group.body), options);
|
|
79
|
-
const
|
|
79
|
+
const phantom = new mathMLTree.MathNode("mphantom", inner);
|
|
80
|
+
const node = new mathMLTree.MathNode("mpadded", [phantom]);
|
|
80
81
|
node.setAttribute("height", "0px");
|
|
82
|
+
node.setAttribute("depth", "0px");
|
|
81
83
|
return node;
|
|
82
84
|
},
|
|
83
85
|
});
|
|
@@ -107,7 +109,8 @@ defineFunction({
|
|
|
107
109
|
},
|
|
108
110
|
mathmlBuilder: (group, options) => {
|
|
109
111
|
const inner = mml.buildExpression(ordargument(group.body), options);
|
|
110
|
-
const
|
|
112
|
+
const phantom = new mathMLTree.MathNode("mphantom", inner);
|
|
113
|
+
const node = new mathMLTree.MathNode("mpadded", [phantom]);
|
|
111
114
|
node.setAttribute("width", "0px");
|
|
112
115
|
return node;
|
|
113
116
|
},
|
package/src/functions/rule.js
CHANGED
|
@@ -30,13 +30,9 @@ defineFunction({
|
|
|
30
30
|
const rule = buildCommon.makeSpan(["mord", "rule"], [], options);
|
|
31
31
|
|
|
32
32
|
// Calculate the shift, width, and height of the rule, and account for units
|
|
33
|
-
let shift = 0;
|
|
34
|
-
if (group.shift) {
|
|
35
|
-
shift = calculateSize(group.shift, options);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
33
|
const width = calculateSize(group.width, options);
|
|
39
34
|
const height = calculateSize(group.height, options);
|
|
35
|
+
const shift = (group.shift) ? calculateSize(group.shift, options) : 0;
|
|
40
36
|
|
|
41
37
|
// Style the rule to the right size
|
|
42
38
|
rule.style.borderRightWidth = width + "em";
|
|
@@ -55,10 +51,25 @@ defineFunction({
|
|
|
55
51
|
return rule;
|
|
56
52
|
},
|
|
57
53
|
mathmlBuilder(group, options) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const
|
|
54
|
+
const width = calculateSize(group.width, options);
|
|
55
|
+
const height = calculateSize(group.height, options);
|
|
56
|
+
const shift = (group.shift) ? calculateSize(group.shift, options) : 0;
|
|
57
|
+
const color = options.color && options.getColor() || "black";
|
|
58
|
+
|
|
59
|
+
const rule = new mathMLTree.MathNode("mspace");
|
|
60
|
+
rule.setAttribute("mathbackground", color);
|
|
61
|
+
rule.setAttribute("width", width + "em");
|
|
62
|
+
rule.setAttribute("height", height + "em");
|
|
63
|
+
|
|
64
|
+
const wrapper = new mathMLTree.MathNode("mpadded", [rule]);
|
|
65
|
+
if (shift >= 0) {
|
|
66
|
+
wrapper.setAttribute("height", "+" + shift + "em");
|
|
67
|
+
} else {
|
|
68
|
+
wrapper.setAttribute("height", shift + "em");
|
|
69
|
+
wrapper.setAttribute("depth", "+" + (-shift) + "em");
|
|
70
|
+
}
|
|
71
|
+
wrapper.setAttribute("voffset", shift + "em");
|
|
61
72
|
|
|
62
|
-
return
|
|
73
|
+
return wrapper;
|
|
63
74
|
},
|
|
64
75
|
});
|
package/src/functions/supsub.js
CHANGED
|
@@ -201,6 +201,10 @@ defineFunctionBuilders({
|
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
+
if (group.base && group.base.type === "op") {
|
|
205
|
+
group.base.parentIsSupSub = true;
|
|
206
|
+
}
|
|
207
|
+
|
|
204
208
|
const children = [mml.buildGroup(group.base, options)];
|
|
205
209
|
|
|
206
210
|
if (group.sub) {
|
|
@@ -217,7 +221,7 @@ defineFunctionBuilders({
|
|
|
217
221
|
} else if (!group.sub) {
|
|
218
222
|
const base = group.base;
|
|
219
223
|
if (base && base.type === "op" && base.limits &&
|
|
220
|
-
options.style === Style.DISPLAY) {
|
|
224
|
+
(options.style === Style.DISPLAY || base.alwaysHandleSupSub)) {
|
|
221
225
|
nodeType = "mover";
|
|
222
226
|
} else {
|
|
223
227
|
nodeType = "msup";
|
|
@@ -225,7 +229,7 @@ defineFunctionBuilders({
|
|
|
225
229
|
} else if (!group.sup) {
|
|
226
230
|
const base = group.base;
|
|
227
231
|
if (base && base.type === "op" && base.limits &&
|
|
228
|
-
options.style === Style.DISPLAY) {
|
|
232
|
+
(options.style === Style.DISPLAY || base.alwaysHandleSupSub)) {
|
|
229
233
|
nodeType = "munder";
|
|
230
234
|
} else {
|
|
231
235
|
nodeType = "msub";
|
|
@@ -23,6 +23,10 @@ defineFunctionBuilders({
|
|
|
23
23
|
}
|
|
24
24
|
} else if (group.family === "punct") {
|
|
25
25
|
node.setAttribute("separator", "true");
|
|
26
|
+
} else if (group.family === "open" || group.family === "close") {
|
|
27
|
+
// Delims built here should not stretch vertically.
|
|
28
|
+
// See delimsizing.js for stretchy delims.
|
|
29
|
+
node.setAttribute("stretchy", "false");
|
|
26
30
|
}
|
|
27
31
|
return node;
|
|
28
32
|
},
|
package/src/functions/tag.js
CHANGED
|
@@ -4,21 +4,37 @@ import mathMLTree from "../mathMLTree";
|
|
|
4
4
|
|
|
5
5
|
import * as mml from "../buildMathML";
|
|
6
6
|
|
|
7
|
+
const pad = () => {
|
|
8
|
+
const padNode = new mathMLTree.MathNode("mtd", []);
|
|
9
|
+
padNode.setAttribute("width", "50%");
|
|
10
|
+
return padNode;
|
|
11
|
+
};
|
|
12
|
+
|
|
7
13
|
defineFunctionBuilders({
|
|
8
14
|
type: "tag",
|
|
9
15
|
mathmlBuilder(group, options) {
|
|
10
16
|
const table = new mathMLTree.MathNode("mtable", [
|
|
11
|
-
new mathMLTree.MathNode("
|
|
17
|
+
new mathMLTree.MathNode("mtr", [
|
|
18
|
+
pad(),
|
|
12
19
|
new mathMLTree.MathNode("mtd", [
|
|
13
|
-
mml.buildExpressionRow(group.
|
|
20
|
+
mml.buildExpressionRow(group.body, options),
|
|
14
21
|
]),
|
|
22
|
+
pad(),
|
|
15
23
|
new mathMLTree.MathNode("mtd", [
|
|
16
|
-
mml.buildExpressionRow(group.
|
|
24
|
+
mml.buildExpressionRow(group.tag, options),
|
|
17
25
|
]),
|
|
18
26
|
]),
|
|
19
27
|
]);
|
|
20
|
-
table.setAttribute("
|
|
28
|
+
table.setAttribute("width", "100%");
|
|
21
29
|
return table;
|
|
30
|
+
|
|
31
|
+
// TODO: Left-aligned tags.
|
|
32
|
+
// Currently, the group and options passed here do not contain
|
|
33
|
+
// enough info to set tag alignment. `leqno` is in Settings but it is
|
|
34
|
+
// not passed to Options. On the HTML side, leqno is
|
|
35
|
+
// set by a CSS class applied in buildTree.js. That would have worked
|
|
36
|
+
// in MathML if browsers supported <mlabeledtr>. Since they don't, we
|
|
37
|
+
// need to rewrite the way this function is called.
|
|
22
38
|
},
|
|
23
39
|
});
|
|
24
40
|
|
package/src/functions/text.js
CHANGED
|
@@ -13,10 +13,12 @@ const textFontFamilies = {
|
|
|
13
13
|
|
|
14
14
|
const textFontWeights = {
|
|
15
15
|
"\\textbf": "textbf",
|
|
16
|
+
"\\textmd": "textmd",
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
const textFontShapes = {
|
|
19
20
|
"\\textit": "textit",
|
|
21
|
+
"\\textup": "textup",
|
|
20
22
|
};
|
|
21
23
|
|
|
22
24
|
const optionsWithFont = (group, options) => {
|
|
@@ -39,9 +41,9 @@ defineFunction({
|
|
|
39
41
|
// Font families
|
|
40
42
|
"\\text", "\\textrm", "\\textsf", "\\texttt", "\\textnormal",
|
|
41
43
|
// Font weights
|
|
42
|
-
"\\textbf",
|
|
44
|
+
"\\textbf", "\\textmd",
|
|
43
45
|
// Font Shapes
|
|
44
|
-
"\\textit",
|
|
46
|
+
"\\textit", "\\textup",
|
|
45
47
|
],
|
|
46
48
|
props: {
|
|
47
49
|
numArgs: 1,
|
package/src/functions.js
CHANGED
|
@@ -21,6 +21,8 @@ import "./functions/genfrac";
|
|
|
21
21
|
import "./functions/horizBrace";
|
|
22
22
|
import "./functions/href";
|
|
23
23
|
import "./functions/htmlmathml";
|
|
24
|
+
// Disabled until https://github.com/KaTeX/KaTeX/pull/1794 is merged.
|
|
25
|
+
// import "./functions/includegraphics";
|
|
24
26
|
import "./functions/kern";
|
|
25
27
|
import "./functions/lap";
|
|
26
28
|
import "./functions/math";
|
package/src/katex.less
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
// The mu unit is defined as 1/18 em
|
|
5
5
|
@mu: 1/18em;
|
|
6
6
|
|
|
7
|
+
// The version is dynamically set from package.json via webpack.common.js
|
|
8
|
+
@version: "";
|
|
9
|
+
|
|
7
10
|
.katex {
|
|
8
11
|
font: normal 1.21em KaTeX_Main, Times New Roman, serif;
|
|
9
12
|
line-height: 1.2;
|
|
@@ -18,6 +21,10 @@
|
|
|
18
21
|
// mode, while still allowing background/foreground setting on root .katex
|
|
19
22
|
* { -ms-high-contrast-adjust: none !important; }
|
|
20
23
|
|
|
24
|
+
.katex-version::after {
|
|
25
|
+
content: @version;
|
|
26
|
+
}
|
|
27
|
+
|
|
21
28
|
.katex-mathml {
|
|
22
29
|
// Accessibility hack to only show to screen readers
|
|
23
30
|
// Found at: http://a11yproject.com/posts/how-to-hide-content/
|
|
@@ -464,6 +471,14 @@
|
|
|
464
471
|
stroke-opacity: 1;
|
|
465
472
|
}
|
|
466
473
|
|
|
474
|
+
img {
|
|
475
|
+
border-style: none;
|
|
476
|
+
min-width: 0;
|
|
477
|
+
min-height: 0;
|
|
478
|
+
max-width: none;
|
|
479
|
+
max-height: none;
|
|
480
|
+
}
|
|
481
|
+
|
|
467
482
|
// Define CSS for image whose width will match its span width.
|
|
468
483
|
.stretchy {
|
|
469
484
|
width: 100%;
|