katex 0.10.1 → 0.12.0
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 +141 -0
- package/LICENSE +1 -1
- package/README.md +6 -6
- package/cli.js +0 -0
- package/contrib/auto-render/auto-render.js +12 -3
- package/contrib/copy-tex/README.md +3 -5
- package/contrib/mathtex-script-type/README.md +12 -14
- package/contrib/mhchem/README.md +3 -1
- package/contrib/render-a11y-string/render-a11y-string.js +712 -0
- package/contrib/render-a11y-string/test/render-a11y-string-spec.js +526 -0
- package/dist/README.md +6 -6
- package/dist/contrib/auto-render.js +14 -3
- package/dist/contrib/auto-render.min.js +1 -1
- package/dist/contrib/auto-render.mjs +14 -3
- package/dist/contrib/mhchem.min.js +1 -1
- package/dist/contrib/render-a11y-string.js +870 -0
- package/dist/contrib/render-a11y-string.min.js +1 -0
- package/dist/contrib/render-a11y-string.mjs +753 -0
- 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 +34 -10
- package/dist/katex.js +2906 -2115
- package/dist/katex.min.css +1 -1
- package/dist/katex.min.js +1 -1
- package/dist/katex.mjs +2809 -2020
- package/package.json +12 -11
- package/src/Lexer.js +1 -0
- package/src/MacroExpander.js +39 -10
- package/src/Options.js +15 -75
- package/src/Parser.js +152 -115
- package/src/Settings.js +70 -7
- package/src/Token.js +2 -0
- package/src/buildCommon.js +24 -90
- package/src/buildHTML.js +31 -31
- package/src/buildMathML.js +52 -9
- package/src/buildTree.js +13 -6
- package/src/defineFunction.js +7 -22
- package/src/delimiter.js +66 -27
- package/src/domTree.js +71 -4
- package/src/environments/array.js +235 -25
- package/src/fontMetrics.js +11 -2
- package/src/functions/accent.js +9 -9
- package/src/functions/accentunder.js +2 -2
- package/src/functions/arrow.js +15 -5
- package/src/functions/color.js +9 -38
- package/src/functions/def.js +184 -0
- package/src/functions/delimsizing.js +32 -8
- package/src/functions/enclose.js +33 -6
- package/src/functions/font.js +4 -1
- package/src/functions/genfrac.js +39 -27
- package/src/functions/horizBrace.js +6 -7
- package/src/functions/href.js +16 -0
- package/src/functions/html.js +102 -0
- package/src/functions/includegraphics.js +153 -0
- package/src/functions/lap.js +4 -7
- package/src/functions/math.js +1 -5
- package/src/functions/mclass.js +41 -2
- package/src/functions/op.js +27 -111
- package/src/functions/operatorname.js +136 -92
- package/src/functions/ordgroup.js +1 -1
- package/src/functions/overline.js +3 -2
- package/src/functions/phantom.js +5 -2
- package/src/functions/raisebox.js +4 -16
- package/src/functions/rule.js +20 -9
- package/src/functions/styling.js +0 -9
- package/src/functions/supsub.js +27 -7
- package/src/functions/symbolsOp.js +4 -0
- package/src/functions/tag.js +20 -4
- package/src/functions/text.js +4 -3
- package/src/functions/underline.js +3 -2
- package/src/functions/utils/assembleSupSub.js +110 -0
- package/src/functions.js +3 -0
- package/src/katex.less +45 -9
- package/src/macros.js +259 -98
- package/src/mathMLTree.js +6 -4
- package/src/parseNode.js +37 -57
- package/src/stretchy.js +3 -1
- package/src/svgGeometry.js +136 -44
- package/src/symbols.js +52 -69
- package/src/tree.js +2 -2
- package/src/types.js +2 -1
- package/src/unicodeAccents.js +3 -1
- package/src/unicodeSymbols.js +30 -321
- package/src/utils.js +10 -0
- package/src/wide-character.js +2 -2
- package/src/unicodeMake.js +0 -70
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import buildCommon from "../../buildCommon";
|
|
3
|
+
import * as html from "../../buildHTML";
|
|
4
|
+
import type {StyleInterface} from "../../Style";
|
|
5
|
+
import type Options from "../../Options";
|
|
6
|
+
import type {DomSpan, SymbolNode} from "../../domTree";
|
|
7
|
+
import type {AnyParseNode} from "../../parseNode";
|
|
8
|
+
|
|
9
|
+
// For an operator with limits, assemble the base, sup, and sub into a span.
|
|
10
|
+
|
|
11
|
+
export const assembleSupSub = (
|
|
12
|
+
base: DomSpan | SymbolNode,
|
|
13
|
+
supGroup: ?AnyParseNode,
|
|
14
|
+
subGroup: ?AnyParseNode,
|
|
15
|
+
options: Options,
|
|
16
|
+
style: StyleInterface,
|
|
17
|
+
slant: number,
|
|
18
|
+
baseShift: number,
|
|
19
|
+
): DomSpan => {
|
|
20
|
+
base = buildCommon.makeSpan([], [base]);
|
|
21
|
+
let sub;
|
|
22
|
+
let sup;
|
|
23
|
+
// We manually have to handle the superscripts and subscripts. This,
|
|
24
|
+
// aside from the kern calculations, is copied from supsub.
|
|
25
|
+
if (supGroup) {
|
|
26
|
+
const elem = html.buildGroup(
|
|
27
|
+
supGroup, options.havingStyle(style.sup()), options);
|
|
28
|
+
|
|
29
|
+
sup = {
|
|
30
|
+
elem,
|
|
31
|
+
kern: Math.max(
|
|
32
|
+
options.fontMetrics().bigOpSpacing1,
|
|
33
|
+
options.fontMetrics().bigOpSpacing3 - elem.depth),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (subGroup) {
|
|
38
|
+
const elem = html.buildGroup(
|
|
39
|
+
subGroup, options.havingStyle(style.sub()), options);
|
|
40
|
+
|
|
41
|
+
sub = {
|
|
42
|
+
elem,
|
|
43
|
+
kern: Math.max(
|
|
44
|
+
options.fontMetrics().bigOpSpacing2,
|
|
45
|
+
options.fontMetrics().bigOpSpacing4 - elem.height),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Build the final group as a vlist of the possible subscript, base,
|
|
50
|
+
// and possible superscript.
|
|
51
|
+
let finalGroup;
|
|
52
|
+
if (sup && sub) {
|
|
53
|
+
const bottom = options.fontMetrics().bigOpSpacing5 +
|
|
54
|
+
sub.elem.height + sub.elem.depth +
|
|
55
|
+
sub.kern +
|
|
56
|
+
base.depth + baseShift;
|
|
57
|
+
|
|
58
|
+
finalGroup = buildCommon.makeVList({
|
|
59
|
+
positionType: "bottom",
|
|
60
|
+
positionData: bottom,
|
|
61
|
+
children: [
|
|
62
|
+
{type: "kern", size: options.fontMetrics().bigOpSpacing5},
|
|
63
|
+
{type: "elem", elem: sub.elem, marginLeft: -slant + "em"},
|
|
64
|
+
{type: "kern", size: sub.kern},
|
|
65
|
+
{type: "elem", elem: base},
|
|
66
|
+
{type: "kern", size: sup.kern},
|
|
67
|
+
{type: "elem", elem: sup.elem, marginLeft: slant + "em"},
|
|
68
|
+
{type: "kern", size: options.fontMetrics().bigOpSpacing5},
|
|
69
|
+
],
|
|
70
|
+
}, options);
|
|
71
|
+
} else if (sub) {
|
|
72
|
+
const top = base.height - baseShift;
|
|
73
|
+
|
|
74
|
+
// Shift the limits by the slant of the symbol. Note
|
|
75
|
+
// that we are supposed to shift the limits by 1/2 of the slant,
|
|
76
|
+
// but since we are centering the limits adding a full slant of
|
|
77
|
+
// margin will shift by 1/2 that.
|
|
78
|
+
finalGroup = buildCommon.makeVList({
|
|
79
|
+
positionType: "top",
|
|
80
|
+
positionData: top,
|
|
81
|
+
children: [
|
|
82
|
+
{type: "kern", size: options.fontMetrics().bigOpSpacing5},
|
|
83
|
+
{type: "elem", elem: sub.elem, marginLeft: -slant + "em"},
|
|
84
|
+
{type: "kern", size: sub.kern},
|
|
85
|
+
{type: "elem", elem: base},
|
|
86
|
+
],
|
|
87
|
+
}, options);
|
|
88
|
+
} else if (sup) {
|
|
89
|
+
const bottom = base.depth + baseShift;
|
|
90
|
+
|
|
91
|
+
finalGroup = buildCommon.makeVList({
|
|
92
|
+
positionType: "bottom",
|
|
93
|
+
positionData: bottom,
|
|
94
|
+
children: [
|
|
95
|
+
{type: "elem", elem: base},
|
|
96
|
+
{type: "kern", size: sup.kern},
|
|
97
|
+
{type: "elem", elem: sup.elem, marginLeft: slant + "em"},
|
|
98
|
+
{type: "kern", size: options.fontMetrics().bigOpSpacing5},
|
|
99
|
+
],
|
|
100
|
+
}, options);
|
|
101
|
+
} else {
|
|
102
|
+
// This case probably shouldn't occur (this would mean the
|
|
103
|
+
// supsub was sending us a group with no superscript or
|
|
104
|
+
// subscript) but be safe.
|
|
105
|
+
return base;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return buildCommon.makeSpan(
|
|
109
|
+
["mop", "op-limits"], [finalGroup], options);
|
|
110
|
+
};
|
package/src/functions.js
CHANGED
|
@@ -13,6 +13,7 @@ import "./functions/arrow";
|
|
|
13
13
|
import "./functions/char";
|
|
14
14
|
import "./functions/color";
|
|
15
15
|
import "./functions/cr";
|
|
16
|
+
import "./functions/def";
|
|
16
17
|
import "./functions/delimsizing";
|
|
17
18
|
import "./functions/enclose";
|
|
18
19
|
import "./functions/environment";
|
|
@@ -20,7 +21,9 @@ import "./functions/font";
|
|
|
20
21
|
import "./functions/genfrac";
|
|
21
22
|
import "./functions/horizBrace";
|
|
22
23
|
import "./functions/href";
|
|
24
|
+
import "./functions/html";
|
|
23
25
|
import "./functions/htmlmathml";
|
|
26
|
+
import "./functions/includegraphics";
|
|
24
27
|
import "./functions/kern";
|
|
25
28
|
import "./functions/lap";
|
|
26
29
|
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;
|
|
@@ -14,10 +17,17 @@
|
|
|
14
17
|
// Prevent a rendering bug that misplaces \vec in Chrome.
|
|
15
18
|
text-rendering: auto;
|
|
16
19
|
|
|
20
|
+
// Insulate fraction bars and rules from CSS that sets border-color.
|
|
21
|
+
border-color: currentColor;
|
|
22
|
+
|
|
17
23
|
// Prevent background resetting on elements in Windows's high-contrast
|
|
18
24
|
// mode, while still allowing background/foreground setting on root .katex
|
|
19
25
|
* { -ms-high-contrast-adjust: none !important; }
|
|
20
26
|
|
|
27
|
+
.katex-version::after {
|
|
28
|
+
content: @version;
|
|
29
|
+
}
|
|
30
|
+
|
|
21
31
|
.katex-mathml {
|
|
22
32
|
// Accessibility hack to only show to screen readers
|
|
23
33
|
// Found at: http://a11yproject.com/posts/how-to-hide-content/
|
|
@@ -74,7 +84,7 @@
|
|
|
74
84
|
}
|
|
75
85
|
|
|
76
86
|
// Math fonts.
|
|
77
|
-
.
|
|
87
|
+
.mathnormal {
|
|
78
88
|
font-family: KaTeX_Math;
|
|
79
89
|
font-style: italic;
|
|
80
90
|
}
|
|
@@ -161,6 +171,7 @@
|
|
|
161
171
|
.vlist-t {
|
|
162
172
|
display: inline-table;
|
|
163
173
|
table-layout: fixed;
|
|
174
|
+
border-collapse: collapse;
|
|
164
175
|
}
|
|
165
176
|
|
|
166
177
|
.vlist-r {
|
|
@@ -207,6 +218,29 @@
|
|
|
207
218
|
min-width: 2px;
|
|
208
219
|
}
|
|
209
220
|
|
|
221
|
+
.vbox {
|
|
222
|
+
display: -ms-inline-flexbox;
|
|
223
|
+
display: inline-flex;
|
|
224
|
+
-ms-flex-direction: column;
|
|
225
|
+
flex-direction: column;
|
|
226
|
+
align-items: baseline;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.hbox {
|
|
230
|
+
display: -ms-inline-flexbox;
|
|
231
|
+
display: inline-flex;
|
|
232
|
+
-ms-flex-direction: row;
|
|
233
|
+
flex-direction: row;
|
|
234
|
+
width: 100%;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.thinbox {
|
|
238
|
+
display: inline-flex;
|
|
239
|
+
flex-direction: row;
|
|
240
|
+
width: 0;
|
|
241
|
+
max-width: 0; // necessary for Safari
|
|
242
|
+
}
|
|
243
|
+
|
|
210
244
|
.msupsub {
|
|
211
245
|
text-align: left;
|
|
212
246
|
}
|
|
@@ -297,8 +331,6 @@
|
|
|
297
331
|
|
|
298
332
|
.sizing,
|
|
299
333
|
.fontsize-ensurer {
|
|
300
|
-
display: inline-block;
|
|
301
|
-
|
|
302
334
|
@size1: 0.5;
|
|
303
335
|
@size2: 0.6;
|
|
304
336
|
@size3: 0.7;
|
|
@@ -402,15 +434,10 @@
|
|
|
402
434
|
.mtable {
|
|
403
435
|
.vertical-separator {
|
|
404
436
|
display: inline-block;
|
|
405
|
-
margin
|
|
406
|
-
border-right: 0.05em solid;
|
|
437
|
+
// margin and border-right are set in Javascript
|
|
407
438
|
min-width: 1px; // Prevent Chrome from omitting a line.
|
|
408
439
|
}
|
|
409
440
|
|
|
410
|
-
.vs-dashed {
|
|
411
|
-
border-right: 0.05em dashed;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
441
|
.arraycolsep {
|
|
415
442
|
display: inline-block;
|
|
416
443
|
}
|
|
@@ -464,6 +491,14 @@
|
|
|
464
491
|
stroke-opacity: 1;
|
|
465
492
|
}
|
|
466
493
|
|
|
494
|
+
img {
|
|
495
|
+
border-style: none;
|
|
496
|
+
min-width: 0;
|
|
497
|
+
min-height: 0;
|
|
498
|
+
max-width: none;
|
|
499
|
+
max-height: none;
|
|
500
|
+
}
|
|
501
|
+
|
|
467
502
|
// Define CSS for image whose width will match its span width.
|
|
468
503
|
.stretchy {
|
|
469
504
|
width: 100%;
|
|
@@ -586,4 +621,5 @@
|
|
|
586
621
|
// Flush-left display math
|
|
587
622
|
.katex-display.fleqn > .katex {
|
|
588
623
|
text-align: left;
|
|
624
|
+
padding-left: 2em;
|
|
589
625
|
}
|