katex 0.16.32 → 0.16.34
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/contrib/auto-render/{auto-render.js → auto-render.ts} +41 -19
- package/contrib/auto-render/{splitAtDelimiters.js → splitAtDelimiters.ts} +18 -4
- package/contrib/auto-render/test/{auto-render-spec.js → auto-render-spec.ts} +10 -2
- package/contrib/copy-tex/README.md +2 -2
- package/contrib/copy-tex/{copy-tex.js → copy-tex.ts} +4 -6
- package/contrib/copy-tex/{katex2tex.js → katex2tex.ts} +2 -3
- package/contrib/mathtex-script-type/README.md +5 -5
- package/contrib/mhchem/README.md +1 -1
- package/contrib/render-a11y-string/{render-a11y-string.js → render-a11y-string.ts} +18 -33
- package/contrib/render-a11y-string/test/{render-a11y-string-spec.js → render-a11y-string-spec.ts} +0 -1
- package/dist/README.md +3 -3
- package/dist/contrib/auto-render.js +24 -57
- package/dist/contrib/auto-render.min.js +1 -1
- package/dist/contrib/auto-render.mjs +16586 -210
- package/dist/contrib/copy-tex.js +23 -37
- package/dist/contrib/copy-tex.min.js +1 -1
- package/dist/contrib/copy-tex.mjs +77 -95
- package/dist/contrib/mathtex-script-type.js +0 -3
- package/dist/contrib/mathtex-script-type.mjs +16427 -4
- package/dist/contrib/mhchem.js +55 -303
- package/dist/contrib/mhchem.mjs +12884 -723
- package/dist/contrib/render-a11y-string.js +13 -108
- package/dist/contrib/render-a11y-string.min.js +1 -1
- package/dist/contrib/render-a11y-string.mjs +17020 -760
- package/dist/katex-swap.css +2 -1
- package/dist/katex-swap.min.css +1 -1
- package/dist/katex.css +2 -1
- package/dist/katex.js +4547 -5680
- package/dist/katex.min.css +1 -1
- package/dist/katex.min.js +1 -1
- package/dist/katex.mjs +11854 -13828
- package/{katex.js → katex.ts} +8 -5
- package/package.json +34 -31
- package/src/{Lexer.js → Lexer.ts} +1 -2
- package/src/{MacroExpander.js → MacroExpander.ts} +11 -15
- package/src/{Namespace.js → Namespace.ts} +4 -6
- package/src/{Options.js → Options.ts} +7 -12
- package/src/{ParseError.js → ParseError.ts} +16 -26
- package/src/{Parser.js → Parser.ts} +68 -56
- package/src/{Settings.js → Settings.ts} +70 -70
- package/src/{SourceLocation.js → SourceLocation.ts} +6 -7
- package/src/{Style.js → Style.ts} +4 -5
- package/src/{Token.js → Token.ts} +8 -6
- package/src/{buildCommon.js → buildCommon.ts} +62 -55
- package/src/{buildHTML.js → buildHTML.ts} +29 -25
- package/src/{buildMathML.js → buildMathML.ts} +15 -13
- package/src/{buildTree.js → buildTree.ts} +1 -2
- package/src/{defineEnvironment.js → defineEnvironment.ts} +26 -27
- package/src/{defineFunction.js → defineFunction.ts} +54 -56
- package/src/{defineMacro.js → defineMacro.ts} +12 -13
- package/src/{delimiter.js → delimiter.ts} +19 -17
- package/src/{domTree.js → domTree.ts} +94 -103
- package/src/environments/{array.js → array.ts} +109 -99
- package/src/environments/{cd.js → cd.ts} +9 -11
- package/src/{environments.js → environments.ts} +0 -1
- package/src/{fontMetrics.js → fontMetrics.ts} +10 -12
- package/src/fontMetricsData.d.ts +3 -0
- package/src/functions/{accent.js → accent.ts} +1 -2
- package/src/functions/{accentunder.js → accentunder.ts} +0 -1
- package/src/functions/{arrow.js → arrow.ts} +4 -6
- package/src/functions/{char.js → char.ts} +0 -1
- package/src/functions/{color.js → color.ts} +5 -6
- package/src/functions/{cr.js → cr.ts} +0 -1
- package/src/functions/{def.js → def.ts} +9 -7
- package/src/functions/{delimsizing.js → delimsizing.ts} +11 -9
- package/src/functions/{enclose.js → enclose.ts} +3 -4
- package/src/functions/{environment.js → environment.ts} +2 -3
- package/src/functions/{font.js → font.ts} +4 -4
- package/src/functions/{genfrac.js → genfrac.ts} +14 -15
- package/src/functions/{hbox.js → hbox.ts} +0 -1
- package/src/functions/{horizBrace.js → horizBrace.ts} +4 -5
- package/src/functions/{href.js → href.ts} +4 -4
- package/src/functions/{html.js → html.ts} +3 -3
- package/src/functions/{htmlmathml.js → htmlmathml.ts} +0 -1
- package/src/functions/{includegraphics.js → includegraphics.ts} +0 -1
- package/src/functions/{kern.js → kern.ts} +0 -1
- package/src/functions/{lap.js → lap.ts} +0 -1
- package/src/functions/{math.js → math.ts} +0 -1
- package/src/functions/{mathchoice.js → mathchoice.ts} +2 -2
- package/src/functions/{mclass.js → mclass.ts} +5 -6
- package/src/functions/{op.js → op.ts} +9 -11
- package/src/functions/{operatorname.js → operatorname.ts} +4 -7
- package/src/functions/{ordgroup.js → ordgroup.ts} +0 -2
- package/src/functions/{overline.js → overline.ts} +0 -1
- package/src/functions/{phantom.js → phantom.ts} +0 -1
- package/src/functions/{pmb.js → pmb.ts} +0 -1
- package/src/functions/{raisebox.js → raisebox.ts} +0 -1
- package/src/functions/{relax.js → relax.ts} +0 -1
- package/src/functions/{rule.js → rule.ts} +0 -1
- package/src/functions/{sizing.js → sizing.ts} +0 -1
- package/src/functions/{smash.js → smash.ts} +2 -4
- package/src/functions/{sqrt.js → sqrt.ts} +0 -1
- package/src/functions/{styling.js → styling.ts} +3 -3
- package/src/functions/{supsub.js → supsub.ts} +6 -8
- package/src/functions/{symbolsOp.js → symbolsOp.ts} +0 -2
- package/src/functions/{symbolsOrd.js → symbolsOrd.ts} +1 -2
- package/src/functions/{symbolsSpacing.js → symbolsSpacing.ts} +2 -3
- package/src/functions/{tag.js → tag.ts} +0 -2
- package/src/functions/{text.js → text.ts} +7 -6
- package/src/functions/{underline.js → underline.ts} +0 -1
- package/src/functions/utils/{assembleSupSub.js → assembleSupSub.ts} +2 -3
- package/src/functions/{vcenter.js → vcenter.ts} +0 -2
- package/src/functions/{verb.js → verb.ts} +0 -1
- package/src/{functions.js → functions.ts} +0 -1
- package/src/{macros.js → macros.ts} +10 -8
- package/src/{mathMLTree.js → mathMLTree.ts} +5 -6
- package/src/parseNode.ts +522 -0
- package/src/{parseTree.js → parseTree.ts} +5 -3
- package/src/{spacingData.js → spacingData.ts} +11 -12
- package/src/{stretchy.js → stretchy.ts} +7 -7
- package/src/styles/katex-swap.scss +1 -4
- package/src/styles/katex.scss +9 -0
- package/src/{svgGeometry.js → svgGeometry.ts} +1 -2
- package/src/{symbols.js → symbols.ts} +6 -6
- package/src/{tree.js → tree.ts} +5 -7
- package/src/{types.js → types.ts} +1 -2
- package/src/unicodeAccents.js +4 -1
- package/src/{unicodeScripts.js → unicodeScripts.ts} +1 -3
- package/src/{unicodeSupOrSub.js → unicodeSupOrSub.ts} +1 -1
- package/src/unicodeSymbols.js +4 -3
- package/src/{units.js → units.ts} +2 -4
- package/src/{utils.js → utils.ts} +2 -3
- package/src/{wide-character.js → wide-character.ts} +8 -10
- package/types/katex.d.ts +13 -12
- package/src/parseNode.js +0 -523
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import defineFunction, {ordargument} from "../defineFunction";
|
|
3
2
|
import defineMacro from "../defineMacro";
|
|
4
3
|
import {makeSpan} from "../buildCommon";
|
|
@@ -11,7 +10,7 @@ import * as html from "../buildHTML";
|
|
|
11
10
|
import * as mml from "../buildMathML";
|
|
12
11
|
|
|
13
12
|
import type {HtmlBuilderSupSub, MathMLBuilder} from "../defineFunction";
|
|
14
|
-
import type {ParseNode} from "../parseNode";
|
|
13
|
+
import type {AnyParseNode, ParseNode} from "../parseNode";
|
|
15
14
|
|
|
16
15
|
// NOTE: Unlike most `htmlBuilder`s, this one handles not only
|
|
17
16
|
// "operatorname", but also "supsub" since \operatorname* can
|
|
@@ -36,9 +35,8 @@ export const htmlBuilder: HtmlBuilderSupSub<"operatorname"> = (grp, options) =>
|
|
|
36
35
|
|
|
37
36
|
let base;
|
|
38
37
|
if (group.body.length > 0) {
|
|
39
|
-
const body = group.body.map(child => {
|
|
40
|
-
|
|
41
|
-
const childText = child.text;
|
|
38
|
+
const body = group.body.map((child): AnyParseNode => {
|
|
39
|
+
const childText = "text" in child ? child.text : undefined;
|
|
42
40
|
if (typeof childText === "string") {
|
|
43
41
|
return {
|
|
44
42
|
type: "textord",
|
|
@@ -79,7 +77,7 @@ export const htmlBuilder: HtmlBuilderSupSub<"operatorname"> = (grp, options) =>
|
|
|
79
77
|
|
|
80
78
|
const mathmlBuilder: MathMLBuilder<"operatorname"> = (group, options) => {
|
|
81
79
|
// The steps taken here are similar to the html version.
|
|
82
|
-
let expression = mml.buildExpression(
|
|
80
|
+
let expression: Array<MathNode | TextNode> = mml.buildExpression(
|
|
83
81
|
group.body, options.withFont("mathrm"));
|
|
84
82
|
|
|
85
83
|
// Is expression a string or has it something like a fraction?
|
|
@@ -92,7 +90,6 @@ const mathmlBuilder: MathMLBuilder<"operatorname"> = (group, options) => {
|
|
|
92
90
|
switch (node.type) {
|
|
93
91
|
case "mi":
|
|
94
92
|
case "mn":
|
|
95
|
-
case "ms":
|
|
96
93
|
case "mspace":
|
|
97
94
|
case "mtext":
|
|
98
95
|
break; // Do nothing yet.
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
// smash, with optional [tb], as in AMS
|
|
3
2
|
import defineFunction from "../defineFunction";
|
|
4
3
|
import {makeSpan, makeVList} from "../buildCommon";
|
|
5
4
|
import {MathNode} from "../mathMLTree";
|
|
6
|
-
import {assertNodeType} from "../parseNode";
|
|
5
|
+
import {assertNodeType, assertSymbolNodeType} from "../parseNode";
|
|
7
6
|
|
|
8
7
|
import * as html from "../buildHTML";
|
|
9
8
|
import * as mml from "../buildMathML";
|
|
@@ -27,8 +26,7 @@ defineFunction({
|
|
|
27
26
|
let letter = "";
|
|
28
27
|
for (let i = 0; i < tbArg.body.length; ++i) {
|
|
29
28
|
const node = tbArg.body[i];
|
|
30
|
-
|
|
31
|
-
letter = node.text;
|
|
29
|
+
letter = assertSymbolNodeType(node).text;
|
|
32
30
|
if (letter === "t") {
|
|
33
31
|
smashHeight = true;
|
|
34
32
|
} else if (letter === "b") {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import defineFunction from "../defineFunction";
|
|
3
2
|
import {MathNode} from "../mathMLTree";
|
|
4
3
|
import Style from "../Style";
|
|
5
4
|
import {sizingGroup} from "./sizing";
|
|
6
5
|
|
|
7
6
|
import * as mml from "../buildMathML";
|
|
7
|
+
import type {StyleStr} from "../types";
|
|
8
8
|
|
|
9
9
|
const styleMap = {
|
|
10
10
|
"display": Style.DISPLAY,
|
|
@@ -30,8 +30,8 @@ defineFunction({
|
|
|
30
30
|
|
|
31
31
|
// TODO: Refactor to avoid duplicating styleMap in multiple places (e.g.
|
|
32
32
|
// here and in buildHTML and de-dupe the enumeration of all the styles).
|
|
33
|
-
//
|
|
34
|
-
const style
|
|
33
|
+
// TODO(ts): The names above exactly match the styles.
|
|
34
|
+
const style = funcName.slice(1, funcName.length - 5) as StyleStr;
|
|
35
35
|
return {
|
|
36
36
|
type: "styling",
|
|
37
37
|
mode: parser.mode,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import {defineFunctionBuilders} from "../defineFunction";
|
|
3
2
|
import {makeSpan, makeVList} from "../buildCommon";
|
|
4
3
|
import {SymbolNode} from "../domTree";
|
|
@@ -29,7 +28,7 @@ import type {MathNodeType} from "../mathMLTree";
|
|
|
29
28
|
const htmlBuilderDelegate = function(
|
|
30
29
|
group: ParseNode<"supsub">,
|
|
31
30
|
options: Options,
|
|
32
|
-
):
|
|
31
|
+
): HtmlBuilder<any> | null | undefined {
|
|
33
32
|
const base = group.base;
|
|
34
33
|
if (!base) {
|
|
35
34
|
return null;
|
|
@@ -123,7 +122,7 @@ defineFunctionBuilders({
|
|
|
123
122
|
group.base && group.base.type === "op" && group.base.name &&
|
|
124
123
|
(group.base.name === "\\oiint" || group.base.name === "\\oiiint");
|
|
125
124
|
if (base instanceof SymbolNode || isOiint) {
|
|
126
|
-
//
|
|
125
|
+
// @ts-ignore
|
|
127
126
|
marginLeft = makeEm(-base.italic);
|
|
128
127
|
}
|
|
129
128
|
}
|
|
@@ -148,9 +147,9 @@ defineFunctionBuilders({
|
|
|
148
147
|
}
|
|
149
148
|
|
|
150
149
|
const vlistElem = [
|
|
151
|
-
{type: "elem", elem: subm, shift: subShift, marginRight,
|
|
150
|
+
{type: "elem" as const, elem: subm, shift: subShift, marginRight,
|
|
152
151
|
marginLeft},
|
|
153
|
-
{type: "elem", elem: supm, shift: -supShift, marginRight},
|
|
152
|
+
{type: "elem" as const, elem: supm, shift: -supShift, marginRight},
|
|
154
153
|
];
|
|
155
154
|
|
|
156
155
|
supsub = makeVList({
|
|
@@ -164,7 +163,7 @@ defineFunctionBuilders({
|
|
|
164
163
|
subm.height - 0.8 * metrics.xHeight);
|
|
165
164
|
|
|
166
165
|
const vlistElem =
|
|
167
|
-
[{type: "elem", elem: subm, marginLeft, marginRight}];
|
|
166
|
+
[{type: "elem" as const, elem: subm, marginLeft, marginRight}];
|
|
168
167
|
|
|
169
168
|
supsub = makeVList({
|
|
170
169
|
positionType: "shift",
|
|
@@ -179,7 +178,7 @@ defineFunctionBuilders({
|
|
|
179
178
|
supsub = makeVList({
|
|
180
179
|
positionType: "shift",
|
|
181
180
|
positionData: -supShift,
|
|
182
|
-
children: [{type: "elem", elem: supm, marginRight}],
|
|
181
|
+
children: [{type: "elem" as const, elem: supm, marginRight}],
|
|
183
182
|
}, options);
|
|
184
183
|
} else {
|
|
185
184
|
throw new Error("supsub must have either sup or sub.");
|
|
@@ -264,4 +263,3 @@ defineFunctionBuilders({
|
|
|
264
263
|
return new MathNode(nodeType, children);
|
|
265
264
|
},
|
|
266
265
|
});
|
|
267
|
-
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import {defineFunctionBuilders} from "../defineFunction";
|
|
3
2
|
import {makeOrd} from "../buildCommon";
|
|
4
3
|
import {MathNode} from "../mathMLTree";
|
|
@@ -10,7 +9,7 @@ import type {ParseNode} from "../parseNode";
|
|
|
10
9
|
// "mathord" and "textord" ParseNodes created in Parser.js from symbol Groups in
|
|
11
10
|
// src/symbols.js.
|
|
12
11
|
|
|
13
|
-
const defaultVariant:
|
|
12
|
+
const defaultVariant: Record<string, string> = {
|
|
14
13
|
"mi": "italic",
|
|
15
14
|
"mn": "normal",
|
|
16
15
|
"mtext": "normal",
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import {defineFunctionBuilders} from "../defineFunction";
|
|
3
2
|
import {mathsym, makeOrd, makeSpan} from "../buildCommon";
|
|
4
3
|
import {MathNode, TextNode} from "../mathMLTree";
|
|
5
4
|
import ParseError from "../ParseError";
|
|
6
5
|
|
|
7
6
|
// A map of CSS-based spacing functions to their CSS class.
|
|
8
|
-
const cssSpace:
|
|
7
|
+
const cssSpace: Record<string, string> = {
|
|
9
8
|
"\\nobreak": "nobreak",
|
|
10
9
|
"\\allowbreak": "allowbreak",
|
|
11
10
|
};
|
|
@@ -15,7 +14,7 @@ const cssSpace: {[string]: string} = {
|
|
|
15
14
|
// in this table, then it should be a regular space character. Furthermore,
|
|
16
15
|
// the associated value may have a `className` specifying an extra CSS class
|
|
17
16
|
// to add to the created `span`.
|
|
18
|
-
const regularSpace:
|
|
17
|
+
const regularSpace: Record<string, {className?: string}> = {
|
|
19
18
|
" ": {},
|
|
20
19
|
"\\ ": {},
|
|
21
20
|
"~": {
|
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import defineFunction, {ordargument} from "../defineFunction";
|
|
3
2
|
import {makeSpan} from "../buildCommon";
|
|
4
3
|
|
|
5
4
|
import * as html from "../buildHTML";
|
|
6
5
|
import * as mml from "../buildMathML";
|
|
6
|
+
import type Options from "../Options";
|
|
7
|
+
import type {ParseNode} from "../parseNode";
|
|
7
8
|
|
|
8
9
|
// Non-mathy text, possibly in a font
|
|
9
|
-
const textFontFamilies = {
|
|
10
|
+
const textFontFamilies: Record<string, string | undefined> = {
|
|
10
11
|
"\\text": undefined, "\\textrm": "textrm", "\\textsf": "textsf",
|
|
11
12
|
"\\texttt": "texttt", "\\textnormal": "textrm",
|
|
12
13
|
};
|
|
13
14
|
|
|
14
|
-
const textFontWeights = {
|
|
15
|
+
const textFontWeights: Record<string, "textbf" | "textmd"> = {
|
|
15
16
|
"\\textbf": "textbf",
|
|
16
17
|
"\\textmd": "textmd",
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
const textFontShapes = {
|
|
20
|
+
const textFontShapes: Record<string, "textit" | "textup"> = {
|
|
20
21
|
"\\textit": "textit",
|
|
21
22
|
"\\textup": "textup",
|
|
22
23
|
};
|
|
23
24
|
|
|
24
|
-
const optionsWithFont = (group
|
|
25
|
+
const optionsWithFont = (group: ParseNode<"text">, options: Options): Options => {
|
|
25
26
|
const font = group.font;
|
|
26
27
|
// Checks if the argument is a font family or a font style.
|
|
27
28
|
if (!font) {
|
|
@@ -36,7 +37,7 @@ const optionsWithFont = (group, options) => {
|
|
|
36
37
|
options.withTextFontShape("textit");
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
return options.withTextFontShape(textFontShapes[font]);
|
|
40
|
+
return options.withTextFontShape(textFontShapes[font] as "textit" | "textup");
|
|
40
41
|
};
|
|
41
42
|
|
|
42
43
|
defineFunction({
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import {makeSpan, makeVList} from "../../buildCommon";
|
|
3
2
|
import * as html from "../../buildHTML";
|
|
4
3
|
import {isCharacterBox} from "../../utils";
|
|
@@ -12,8 +11,8 @@ import {makeEm} from "../../units";
|
|
|
12
11
|
|
|
13
12
|
export const assembleSupSub = (
|
|
14
13
|
base: DomSpan | SymbolNode,
|
|
15
|
-
supGroup:
|
|
16
|
-
subGroup:
|
|
14
|
+
supGroup: AnyParseNode | null | undefined,
|
|
15
|
+
subGroup: AnyParseNode | null | undefined,
|
|
17
16
|
options: Options,
|
|
18
17
|
style: StyleInterface,
|
|
19
18
|
slant: number,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
/**
|
|
3
2
|
* Predefined macros for KaTeX.
|
|
4
3
|
* This can be used to define some commands in terms of others.
|
|
@@ -15,6 +14,7 @@ import symbols from "./symbols";
|
|
|
15
14
|
import {makeEm} from "./units";
|
|
16
15
|
import ParseError from "./ParseError";
|
|
17
16
|
|
|
17
|
+
import type {MacroContextInterface} from "./defineMacro";
|
|
18
18
|
|
|
19
19
|
//////////////////////////////////////////////////////////////////////
|
|
20
20
|
// macro tools
|
|
@@ -88,7 +88,7 @@ defineMacro("\\TextOrMath", function(context) {
|
|
|
88
88
|
});
|
|
89
89
|
|
|
90
90
|
// Lookup table for parsing numbers in base 8 through 16
|
|
91
|
-
const digitToNumber = {
|
|
91
|
+
const digitToNumber: Record<string, number> = {
|
|
92
92
|
"0": 0, "1": 1, "2": 2, "3": 3, "4": 4, "5": 5, "6": 6, "7": 7, "8": 8,
|
|
93
93
|
"9": 9, "a": 10, "A": 10, "b": 11, "B": 11, "c": 12, "C": 12,
|
|
94
94
|
"d": 13, "D": 13, "e": 14, "E": 14, "f": 15, "F": 15,
|
|
@@ -106,7 +106,7 @@ const digitToNumber = {
|
|
|
106
106
|
defineMacro("\\char", function(context) {
|
|
107
107
|
let token = context.popToken();
|
|
108
108
|
let base;
|
|
109
|
-
let number =
|
|
109
|
+
let number = 0;
|
|
110
110
|
if (token.text === "'") {
|
|
111
111
|
base = 8;
|
|
112
112
|
token = context.popToken();
|
|
@@ -146,7 +146,10 @@ defineMacro("\\char", function(context) {
|
|
|
146
146
|
// \renewcommand{\macro}[args]{definition}
|
|
147
147
|
// TODO: Optional arguments: \newcommand{\macro}[args][default]{definition}
|
|
148
148
|
const newcommand = (
|
|
149
|
-
context
|
|
149
|
+
context: MacroContextInterface,
|
|
150
|
+
existsOK: boolean,
|
|
151
|
+
nonexistsOK: boolean,
|
|
152
|
+
skipIfExists: boolean,
|
|
150
153
|
) => {
|
|
151
154
|
let arg = context.consumeArg().tokens;
|
|
152
155
|
if (arg.length !== 1) {
|
|
@@ -332,7 +335,6 @@ defineMacro("\u231E", "\\llcorner");
|
|
|
332
335
|
defineMacro("\u231F", "\\lrcorner");
|
|
333
336
|
defineMacro("\u00A9", "\\copyright");
|
|
334
337
|
defineMacro("\u00AE", "\\textregistered");
|
|
335
|
-
defineMacro("\uFE0F", "\\textregistered");
|
|
336
338
|
|
|
337
339
|
// The KaTeX fonts have corners at codepoints that don't match Unicode.
|
|
338
340
|
// For MathML purposes, use the Unicode code point.
|
|
@@ -394,7 +396,7 @@ defineMacro("\\dddot", "{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}");
|
|
|
394
396
|
defineMacro("\\ddddot", "{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}");
|
|
395
397
|
|
|
396
398
|
// AMSMath's automatic \dots, based on \mdots@@ macro.
|
|
397
|
-
const dotsByToken = {
|
|
399
|
+
const dotsByToken: Record<string, string> = {
|
|
398
400
|
',': '\\dotsc',
|
|
399
401
|
'\\not': '\\dotsb',
|
|
400
402
|
// \keybin@ checks for the following:
|
|
@@ -919,7 +921,7 @@ defineMacro("\\ket", "\\mathinner{|{#1}\\rangle}");
|
|
|
919
921
|
defineMacro("\\braket", "\\mathinner{\\langle{#1}\\rangle}");
|
|
920
922
|
defineMacro("\\Bra", "\\left\\langle#1\\right|");
|
|
921
923
|
defineMacro("\\Ket", "\\left|#1\\right\\rangle");
|
|
922
|
-
const braketHelper = (one) => (context) => {
|
|
924
|
+
const braketHelper = (one: boolean) => (context: MacroContextInterface) => {
|
|
923
925
|
const left = context.consumeArg().tokens;
|
|
924
926
|
const middle = context.consumeArg().tokens;
|
|
925
927
|
const middleDouble = context.consumeArg().tokens;
|
|
@@ -927,7 +929,7 @@ const braketHelper = (one) => (context) => {
|
|
|
927
929
|
const oldMiddle = context.macros.get("|");
|
|
928
930
|
const oldMiddleDouble = context.macros.get("\\|");
|
|
929
931
|
context.macros.beginGroup();
|
|
930
|
-
const midMacro = (double) => (context) => {
|
|
932
|
+
const midMacro = (double: boolean) => (context: MacroContextInterface) => {
|
|
931
933
|
if (one) {
|
|
932
934
|
// Only modify the first instance of | or \|
|
|
933
935
|
context.macros.set("|", oldMiddle);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
/**
|
|
3
2
|
* These objects store data about MathML nodes. This is the MathML equivalent
|
|
4
3
|
* of the types in domTree.js. Since MathML handles its own rendering, and
|
|
@@ -35,7 +34,7 @@ export interface MathDomNode extends VirtualNode {
|
|
|
35
34
|
|
|
36
35
|
export type documentFragment = DocumentFragment<MathDomNode>;
|
|
37
36
|
export function newDocumentFragment(
|
|
38
|
-
children:
|
|
37
|
+
children: ReadonlyArray<MathDomNode>
|
|
39
38
|
): documentFragment {
|
|
40
39
|
return new DocumentFragment(children);
|
|
41
40
|
}
|
|
@@ -47,13 +46,13 @@ export function newDocumentFragment(
|
|
|
47
46
|
*/
|
|
48
47
|
export class MathNode implements MathDomNode {
|
|
49
48
|
type: MathNodeType;
|
|
50
|
-
attributes:
|
|
51
|
-
children:
|
|
49
|
+
attributes: Record<string, string>;
|
|
50
|
+
children: MathDomNode[];
|
|
52
51
|
classes: string[];
|
|
53
52
|
|
|
54
53
|
constructor(
|
|
55
54
|
type: MathNodeType,
|
|
56
|
-
children?:
|
|
55
|
+
children?: MathDomNode[],
|
|
57
56
|
classes?: string[]
|
|
58
57
|
) {
|
|
59
58
|
this.type = type;
|
|
@@ -190,7 +189,7 @@ export class TextNode implements MathDomNode {
|
|
|
190
189
|
*/
|
|
191
190
|
export class SpaceNode implements MathDomNode {
|
|
192
191
|
width: number;
|
|
193
|
-
character:
|
|
192
|
+
character: string | null | undefined;
|
|
194
193
|
|
|
195
194
|
/**
|
|
196
195
|
* Create a Space node with width given in CSS ems.
|