katex 0.16.45 → 0.16.47
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/copy-tex/README.md +2 -2
- package/contrib/mathtex-script-type/README.md +5 -5
- package/contrib/mathtex-script-type/mathtex-script-type.js +2 -1
- package/contrib/mhchem/README.md +1 -1
- package/contrib/render-a11y-string/render-a11y-string.ts +7 -5
- package/contrib/render-a11y-string/test/render-a11y-string-spec.ts +0 -1
- package/dist/README.md +3 -3
- package/dist/contrib/mathtex-script-type.js +2 -1
- package/dist/contrib/mathtex-script-type.min.js +1 -1
- package/dist/contrib/mathtex-script-type.mjs +2 -1
- package/dist/contrib/render-a11y-string.js +47 -8
- package/dist/contrib/render-a11y-string.min.js +1 -1
- package/dist/contrib/render-a11y-string.mjs +27 -2
- package/dist/katex-swap.css +5 -2
- package/dist/katex-swap.min.css +1 -1
- package/dist/katex.css +5 -2
- package/dist/katex.js +520 -316
- package/dist/katex.min.css +1 -1
- package/dist/katex.min.js +1 -1
- package/dist/katex.mjs +492 -321
- package/package.json +15 -16
- package/src/Options.ts +29 -28
- package/src/Parser.ts +12 -15
- package/src/Settings.ts +177 -60
- package/src/atoms.ts +33 -0
- package/src/buildCommon.ts +54 -46
- package/src/buildHTML.ts +4 -3
- package/src/buildMathML.ts +54 -47
- package/src/defineEnvironment.ts +1 -1
- package/src/defineFunction.ts +10 -3
- package/src/delimiter.ts +17 -13
- package/src/domTree.ts +28 -23
- package/src/environments/array.ts +12 -6
- package/src/environments/cd.ts +9 -2
- package/src/fontMetrics.ts +10 -23
- package/src/fontMetricsData.d.ts +6 -1
- package/src/functions/arrow.ts +4 -5
- package/src/functions/delimsizing.ts +22 -16
- package/src/functions/enclose.ts +6 -6
- package/src/functions/environment.ts +7 -2
- package/src/functions/font.ts +13 -8
- package/src/functions/hbox.ts +2 -2
- package/src/functions/horizBrace.ts +4 -6
- package/src/functions/math.ts +1 -0
- package/src/functions/op.ts +10 -5
- package/src/functions/smash.ts +1 -1
- package/src/functions/styling.ts +17 -5
- package/src/functions/supsub.ts +6 -3
- package/src/functions/text.ts +7 -3
- package/src/parseNode.ts +7 -5
- package/src/stretchy.ts +14 -14
- package/src/styles/katex.scss +3 -1
- package/src/svgGeometry.ts +2 -2
- package/src/symbols.ts +11 -26
- package/src/tree.ts +11 -5
- package/src/types/fonts.ts +73 -0
- package/src/{types.ts → types/index.ts} +4 -10
- package/src/utils.ts +0 -1
- package/src/wide-character.ts +101 -55
package/src/styles/katex.scss
CHANGED
|
@@ -49,7 +49,7 @@ $display-margin: 1em 0 !default;
|
|
|
49
49
|
/* Accessibility hack to only show to screen readers
|
|
50
50
|
Found at: http://a11yproject.com/posts/how-to-hide-content/ */
|
|
51
51
|
position: absolute;
|
|
52
|
-
clip:
|
|
52
|
+
clip-path: inset(50%);
|
|
53
53
|
padding: 0;
|
|
54
54
|
border: 0;
|
|
55
55
|
height: 1px;
|
|
@@ -349,7 +349,9 @@ $display-margin: 1em 0 !default;
|
|
|
349
349
|
> .root {
|
|
350
350
|
/* These values are taken from the definition of `\r@@t`,
|
|
351
351
|
`\mkern 5mu` and `\mkern -10mu`. */
|
|
352
|
+
/* stylelint-disable-next-line declaration-property-value-no-unknown */
|
|
352
353
|
margin-left: calc(5*$mu);
|
|
354
|
+
/* stylelint-disable-next-line declaration-property-value-no-unknown */
|
|
353
355
|
margin-right: calc(-10*$mu);
|
|
354
356
|
}
|
|
355
357
|
}
|
package/src/svgGeometry.ts
CHANGED
|
@@ -507,8 +507,8 @@ M500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z`,
|
|
|
507
507
|
export const tallDelim = function(label: string, midHeight: number): string {
|
|
508
508
|
switch (label) {
|
|
509
509
|
case "lbrack":
|
|
510
|
-
return `M403 1759 V84 H666 V0 H319 V1759 v${midHeight} v1759 h347 v-84
|
|
511
|
-
H403z M403 1759 V0 H319 V1759 v${midHeight} v1759 h84z`;
|
|
510
|
+
return `M403 1759 V84 H666 V0 H319 V1759 v${midHeight} v1759 v84 h347 v-84
|
|
511
|
+
H403z M403 1759 V0 H319 V1759 v${midHeight} v1759 v84 h84z`;
|
|
512
512
|
case "rbrack":
|
|
513
513
|
return `M347 1759 V0 H0 V84 H263 V1759 v${midHeight} v1759 H0 v84 H347z
|
|
514
514
|
M347 1759 V0 H263 V1759 v${midHeight} v1759 h84z`;
|
package/src/symbols.ts
CHANGED
|
@@ -16,34 +16,19 @@
|
|
|
16
16
|
* accepted in (e.g. "math" or "text").
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
+
import type {Group} from "./atoms";
|
|
19
20
|
import type {Mode} from "./types";
|
|
21
|
+
import type {SymbolFont} from "./types/fonts";
|
|
20
22
|
|
|
21
|
-
type Font = "main" | "ams";
|
|
22
23
|
// Some of these have a "-token" suffix since these are also used as `ParseNode`
|
|
23
24
|
// types for raw text tokens, and we want to avoid conflicts with higher-level
|
|
24
25
|
// `ParseNode` types. These `ParseNode`s are constructed within `Parser` by
|
|
25
26
|
// looking up the `symbols` map.
|
|
26
|
-
export const ATOMS = {
|
|
27
|
-
"bin": 1,
|
|
28
|
-
"close": 1,
|
|
29
|
-
"inner": 1,
|
|
30
|
-
"open": 1,
|
|
31
|
-
"punct": 1,
|
|
32
|
-
"rel": 1,
|
|
33
|
-
};
|
|
34
|
-
export const NON_ATOMS = {
|
|
35
|
-
"accent-token": 1,
|
|
36
|
-
"mathord": 1,
|
|
37
|
-
"op-token": 1,
|
|
38
|
-
"spacing": 1,
|
|
39
|
-
"textord": 1,
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export type Atom = keyof typeof ATOMS;
|
|
43
|
-
export type NonAtom = keyof typeof NON_ATOMS;
|
|
44
|
-
export type Group = Atom | NonAtom;
|
|
45
27
|
|
|
46
|
-
type CharInfoMap = Record<
|
|
28
|
+
type CharInfoMap = Record<
|
|
29
|
+
string,
|
|
30
|
+
{font: SymbolFont; group: Group; replace: string | null | undefined}
|
|
31
|
+
>;
|
|
47
32
|
|
|
48
33
|
const symbols: Record<Mode, CharInfoMap> = {
|
|
49
34
|
"math": {},
|
|
@@ -54,9 +39,9 @@ export default symbols;
|
|
|
54
39
|
/** `acceptUnicodeChar = true` is only applicable if `replace` is set. */
|
|
55
40
|
export function defineSymbol(
|
|
56
41
|
mode: Mode,
|
|
57
|
-
font:
|
|
42
|
+
font: SymbolFont,
|
|
58
43
|
group: Group,
|
|
59
|
-
replace: string
|
|
44
|
+
replace: string,
|
|
60
45
|
name: string,
|
|
61
46
|
acceptUnicodeChar?: boolean,
|
|
62
47
|
) {
|
|
@@ -595,8 +580,8 @@ defineSymbol(text, main, spacing, "\u00a0", "\\ ");
|
|
|
595
580
|
defineSymbol(text, main, spacing, "\u00a0", " ");
|
|
596
581
|
defineSymbol(text, main, spacing, "\u00a0", "\\space");
|
|
597
582
|
defineSymbol(text, main, spacing, "\u00a0", "\\nobreakspace");
|
|
598
|
-
defineSymbol(math, main, spacing,
|
|
599
|
-
defineSymbol(math, main, spacing,
|
|
583
|
+
defineSymbol(math, main, spacing, "", "\\nobreak");
|
|
584
|
+
defineSymbol(math, main, spacing, "", "\\allowbreak");
|
|
600
585
|
defineSymbol(math, main, punct, ",", ",");
|
|
601
586
|
defineSymbol(math, main, punct, ";", ";");
|
|
602
587
|
defineSymbol(math, ams, bin, "\u22bc", "\\barwedge", true);
|
|
@@ -799,7 +784,7 @@ defineSymbol(text, main, mathord, "h", "\u210E");
|
|
|
799
784
|
// Mathematical Alphanumeric Symbols.
|
|
800
785
|
// Some editors do not deal well with wide characters. So don't write the
|
|
801
786
|
// string into this file. Instead, create the string from the surrogate pair.
|
|
802
|
-
let wideChar
|
|
787
|
+
let wideChar;
|
|
803
788
|
for (let i = 0; i < letters.length; i++) {
|
|
804
789
|
const ch = letters.charAt(i);
|
|
805
790
|
|
package/src/tree.ts
CHANGED
|
@@ -8,6 +8,10 @@ export interface VirtualNode {
|
|
|
8
8
|
toMarkup(): string;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
function isMathDomNode(node: VirtualNode): node is MathDomNode {
|
|
12
|
+
return 'toText' in node;
|
|
13
|
+
}
|
|
14
|
+
|
|
11
15
|
|
|
12
16
|
/**
|
|
13
17
|
* This node represents a document fragment, which contains elements, but when
|
|
@@ -64,10 +68,12 @@ export class DocumentFragment<ChildType extends VirtualNode>
|
|
|
64
68
|
* MathDomNode's only.
|
|
65
69
|
*/
|
|
66
70
|
toText(): string {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
return this.children.map((child: ChildType): string => {
|
|
72
|
+
if (isMathDomNode(child)) {
|
|
73
|
+
return child.toText();
|
|
74
|
+
}
|
|
75
|
+
throw new Error(
|
|
76
|
+
`Expected MathDomNode with toText, got ${child.constructor.name}`);
|
|
77
|
+
}).join("");
|
|
72
78
|
}
|
|
73
79
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Math font variants.
|
|
2
|
+
export type FontVariant =
|
|
3
|
+
| "bold"
|
|
4
|
+
| "bold-italic"
|
|
5
|
+
| "bold-sans-serif"
|
|
6
|
+
| "double-struck"
|
|
7
|
+
| "fraktur"
|
|
8
|
+
| "italic"
|
|
9
|
+
| "monospace"
|
|
10
|
+
| "normal"
|
|
11
|
+
| "sans-serif"
|
|
12
|
+
| "sans-serif-bold-italic"
|
|
13
|
+
| "sans-serif-italic"
|
|
14
|
+
| "script";
|
|
15
|
+
|
|
16
|
+
export type FontName =
|
|
17
|
+
| "AMS-Regular"
|
|
18
|
+
| "Caligraphic-Regular"
|
|
19
|
+
| "Fraktur-Regular"
|
|
20
|
+
| "Main-Bold"
|
|
21
|
+
| "Main-BoldItalic"
|
|
22
|
+
| "Main-Italic"
|
|
23
|
+
| "Main-Regular"
|
|
24
|
+
| "Math-BoldItalic"
|
|
25
|
+
| "Math-Italic"
|
|
26
|
+
| "SansSerif-Regular"
|
|
27
|
+
| "SansSerif-Bold"
|
|
28
|
+
| "SansSerif-Italic"
|
|
29
|
+
| "Script-Regular"
|
|
30
|
+
| "Size1-Regular"
|
|
31
|
+
| "Size2-Regular"
|
|
32
|
+
| "Size3-Regular"
|
|
33
|
+
| "Size4-Regular"
|
|
34
|
+
| "Typewriter-Regular";
|
|
35
|
+
|
|
36
|
+
//[depth, height, italic, skew, width]
|
|
37
|
+
export type CharacterMetricsTuple = [depth: number, height: number, italic: number, skew: number, width: number];
|
|
38
|
+
|
|
39
|
+
export type CharacterMetrics = {
|
|
40
|
+
depth: number;
|
|
41
|
+
height: number;
|
|
42
|
+
italic: number;
|
|
43
|
+
skew: number;
|
|
44
|
+
width: number;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type FontMetrics = {
|
|
48
|
+
cssEmPerMu: number;
|
|
49
|
+
[key: string]: number;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type SymbolFont = "main" | "ams";
|
|
53
|
+
|
|
54
|
+
export type MathFont =
|
|
55
|
+
| ""
|
|
56
|
+
| "mathrm"
|
|
57
|
+
| "mathit"
|
|
58
|
+
| "mathbf"
|
|
59
|
+
| "mathnormal"
|
|
60
|
+
| "mathsfit"
|
|
61
|
+
| "mathbb"
|
|
62
|
+
| "mathcal"
|
|
63
|
+
| "mathfrak"
|
|
64
|
+
| "mathscr"
|
|
65
|
+
| "mathsf"
|
|
66
|
+
| "mathtt"
|
|
67
|
+
| "boldsymbol";
|
|
68
|
+
|
|
69
|
+
export type TextFont = "textrm" | "textsf" | "texttt" | "amsrm" | "";
|
|
70
|
+
|
|
71
|
+
// In these types, "" (empty string) means "no change".
|
|
72
|
+
export type FontWeight = "textbf" | "textmd" | "";
|
|
73
|
+
export type FontShape = "textit" | "textup" | "";
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* This file consists only of basic types used in multiple places.
|
|
4
|
-
* For types with javascript, create separate files by themselves.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
1
|
export type Mode = "math" | "text";
|
|
8
2
|
|
|
9
3
|
// LaTeX argument type.
|
|
@@ -29,7 +23,7 @@ export type StyleStr = "text" | "display" | "script" | "scriptscript";
|
|
|
29
23
|
export type BreakToken = "]" | "}" | "\\endgroup" | "$" | "\\)" | "\\\\" | "\\end" |
|
|
30
24
|
"EOF";
|
|
31
25
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
export type DelimiterSize = 1 | 2 | 3 | 4;
|
|
27
|
+
|
|
28
|
+
export type Slice1<S extends string> =
|
|
29
|
+
S extends `${string}${infer Rest}` ? Rest : "";
|
package/src/utils.ts
CHANGED
|
@@ -70,7 +70,6 @@ export const protocolFromUrl = (url: string): string | null => {
|
|
|
70
70
|
// Check for possible leading protocol.
|
|
71
71
|
// https://url.spec.whatwg.org/#url-parsing strips leading whitespace
|
|
72
72
|
// (U+20) or C0 control (U+00-U+1F) characters.
|
|
73
|
-
// eslint-disable-next-line no-control-regex
|
|
74
73
|
const protocol = /^[\x00-\x20]*([^\\/#?]*?)(:|�*58|�*3a|&colon)/i
|
|
75
74
|
.exec(url);
|
|
76
75
|
if (!protocol) {
|
package/src/wide-character.ts
CHANGED
|
@@ -6,101 +6,147 @@
|
|
|
6
6
|
* the font information necessary to render it properly.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type {Mode} from "./types";
|
|
10
9
|
import ParseError from "./ParseError";
|
|
10
|
+
import type {FontName} from "./types/fonts";
|
|
11
|
+
|
|
12
|
+
type WideChar = {
|
|
13
|
+
readonly mathClass: string;
|
|
14
|
+
readonly textClass: string;
|
|
15
|
+
readonly font: Extract<FontName,
|
|
16
|
+
| "Main-Bold"
|
|
17
|
+
| "Math-Italic"
|
|
18
|
+
| "Main-BoldItalic"
|
|
19
|
+
| "Script-Regular"
|
|
20
|
+
| "Fraktur-Regular"
|
|
21
|
+
| "AMS-Regular"
|
|
22
|
+
| "SansSerif-Regular"
|
|
23
|
+
| "SansSerif-Bold"
|
|
24
|
+
| "SansSerif-Italic"
|
|
25
|
+
| "Typewriter-Regular"
|
|
26
|
+
> | "";
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const boldUpright: WideChar = {
|
|
30
|
+
mathClass: "mathbf",
|
|
31
|
+
textClass: "textbf",
|
|
32
|
+
font: "Main-Bold",
|
|
33
|
+
};
|
|
34
|
+
const italic: WideChar = {
|
|
35
|
+
mathClass: "mathnormal",
|
|
36
|
+
textClass: "textit",
|
|
37
|
+
font: "Math-Italic",
|
|
38
|
+
};
|
|
39
|
+
const boldItalic: WideChar = {
|
|
40
|
+
mathClass: "boldsymbol",
|
|
41
|
+
textClass: "boldsymbol",
|
|
42
|
+
font: "Main-BoldItalic",
|
|
43
|
+
};
|
|
44
|
+
const script: WideChar = {
|
|
45
|
+
mathClass: "mathscr",
|
|
46
|
+
textClass: "textscr",
|
|
47
|
+
font: "Script-Regular",
|
|
48
|
+
};
|
|
49
|
+
const noFont: WideChar = {mathClass: "", textClass: "", font: ""};
|
|
50
|
+
const fraktur: WideChar = {
|
|
51
|
+
mathClass: "mathfrak",
|
|
52
|
+
textClass: "textfrak",
|
|
53
|
+
font: "Fraktur-Regular",
|
|
54
|
+
};
|
|
55
|
+
const doubleStruck: WideChar = {
|
|
56
|
+
mathClass: "mathbb",
|
|
57
|
+
textClass: "textbb",
|
|
58
|
+
font: "AMS-Regular",
|
|
59
|
+
};
|
|
60
|
+
const boldFraktur: WideChar = {
|
|
61
|
+
mathClass: "mathboldfrak",
|
|
62
|
+
textClass: "textboldfrak",
|
|
63
|
+
font: "Fraktur-Regular",
|
|
64
|
+
};
|
|
65
|
+
const sansSerif: WideChar = {
|
|
66
|
+
mathClass: "mathsf",
|
|
67
|
+
textClass: "textsf",
|
|
68
|
+
font: "SansSerif-Regular",
|
|
69
|
+
};
|
|
70
|
+
const boldSansSerif: WideChar = {
|
|
71
|
+
mathClass: "mathboldsf",
|
|
72
|
+
textClass: "textboldsf",
|
|
73
|
+
font: "SansSerif-Bold",
|
|
74
|
+
};
|
|
75
|
+
const italicSansSerif: WideChar = {
|
|
76
|
+
mathClass: "mathitsf",
|
|
77
|
+
textClass: "textitsf",
|
|
78
|
+
font: "SansSerif-Italic",
|
|
79
|
+
};
|
|
80
|
+
const monospace: WideChar = {
|
|
81
|
+
mathClass: "mathtt",
|
|
82
|
+
textClass: "texttt",
|
|
83
|
+
font: "Typewriter-Regular",
|
|
84
|
+
};
|
|
11
85
|
|
|
12
86
|
/**
|
|
13
87
|
* Data below is from https://www.unicode.org/charts/PDF/U1D400.pdf
|
|
14
88
|
* That document sorts characters into groups by font type, say bold or italic.
|
|
15
89
|
*
|
|
16
|
-
* In the arrays below, each
|
|
90
|
+
* In the arrays below, each object consists of three properties:
|
|
17
91
|
* * The CSS class of that group when in math mode.
|
|
18
92
|
* * The CSS class of that group when in text mode.
|
|
19
93
|
* * The font name, so that KaTeX can get font metrics.
|
|
20
94
|
*/
|
|
21
95
|
|
|
22
96
|
const wideLatinLetterData = [
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
["mathnormal", "textit", "Math-Italic"], // A-Z italic
|
|
27
|
-
["mathnormal", "textit", "Math-Italic"], // a-z italic
|
|
28
|
-
|
|
29
|
-
["boldsymbol", "boldsymbol", "Main-BoldItalic"], // A-Z bold italic
|
|
30
|
-
["boldsymbol", "boldsymbol", "Main-BoldItalic"], // a-z bold italic
|
|
31
|
-
|
|
97
|
+
boldUpright, boldUpright, // A-Z, a-z
|
|
98
|
+
italic, italic, // A-Z, a-z
|
|
99
|
+
boldItalic, boldItalic, // A-Z, a-z
|
|
32
100
|
// Map fancy A-Z letters to script, not calligraphic.
|
|
33
101
|
// This aligns with unicode-math and math fonts (except Cambria Math).
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
["", "", ""], // a-z bold script. No font
|
|
39
|
-
|
|
40
|
-
["mathfrak", "textfrak", "Fraktur-Regular"], // A-Z Fraktur
|
|
41
|
-
["mathfrak", "textfrak", "Fraktur-Regular"], // a-z Fraktur
|
|
42
|
-
|
|
43
|
-
["mathbb", "textbb", "AMS-Regular"], // A-Z double-struck
|
|
44
|
-
["mathbb", "textbb", "AMS-Regular"], // k double-struck
|
|
45
|
-
|
|
102
|
+
script, noFont, // A-Z script, a-z — no font
|
|
103
|
+
noFont, noFont, // A-Z bold script, a-z bold script — no font
|
|
104
|
+
fraktur, fraktur, // A-Z, a-z
|
|
105
|
+
doubleStruck, doubleStruck, // A-Z double-struck, k double-struck
|
|
46
106
|
// Note that we are using a bold font, but font metrics for regular Fraktur.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
["mathboldsf", "textboldsf", "SansSerif-Bold"], // a-z bold sans-serif
|
|
55
|
-
|
|
56
|
-
["mathitsf", "textitsf", "SansSerif-Italic"], // A-Z italic sans-serif
|
|
57
|
-
["mathitsf", "textitsf", "SansSerif-Italic"], // a-z italic sans-serif
|
|
58
|
-
|
|
59
|
-
["", "", ""], // A-Z bold italic sans. No font
|
|
60
|
-
["", "", ""], // a-z bold italic sans. No font
|
|
61
|
-
|
|
62
|
-
["mathtt", "texttt", "Typewriter-Regular"], // A-Z monospace
|
|
63
|
-
["mathtt", "texttt", "Typewriter-Regular"], // a-z monospace
|
|
64
|
-
] as const satisfies readonly (readonly [string, string, string])[];
|
|
107
|
+
boldFraktur, boldFraktur, // A-Z, a-z
|
|
108
|
+
sansSerif, sansSerif, // A-Z, a-z
|
|
109
|
+
boldSansSerif, boldSansSerif, // A-Z, a-z
|
|
110
|
+
italicSansSerif, italicSansSerif, // A-Z, a-z
|
|
111
|
+
noFont, noFont, // A-Z bold italic sans, a-z bold italic sans - no font
|
|
112
|
+
monospace, monospace, // A-Z, a-z
|
|
113
|
+
] as const;
|
|
65
114
|
|
|
66
115
|
const wideNumeralData = [
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
] as const
|
|
116
|
+
boldUpright, // 0-9
|
|
117
|
+
noFont, // 0-9 double-struck. No KaTeX font.
|
|
118
|
+
sansSerif, // 0-9
|
|
119
|
+
boldSansSerif, // 0-9
|
|
120
|
+
monospace, // 0-9
|
|
121
|
+
] as const;
|
|
73
122
|
|
|
74
123
|
export const wideCharacterFont = (
|
|
75
124
|
wideChar: string,
|
|
76
|
-
|
|
77
|
-
): [string, string] => {
|
|
125
|
+
): WideChar => {
|
|
78
126
|
|
|
79
127
|
// IE doesn't support codePointAt(). So work with the surrogate pair.
|
|
80
128
|
const H = wideChar.charCodeAt(0); // high surrogate
|
|
81
129
|
const L = wideChar.charCodeAt(1); // low surrogate
|
|
82
130
|
const codePoint = ((H - 0xD800) * 0x400) + (L - 0xDC00) + 0x10000;
|
|
83
131
|
|
|
84
|
-
const j = mode === "math" ? 0 : 1; // column index for CSS class.
|
|
85
|
-
|
|
86
132
|
if (0x1D400 <= codePoint && codePoint < 0x1D6A4) {
|
|
87
133
|
// wideLatinLetterData contains exactly 26 chars on each row.
|
|
88
134
|
// So we can calculate the relevant row. No traverse necessary.
|
|
89
135
|
const i = Math.floor((codePoint - 0x1D400) / 26);
|
|
90
|
-
return
|
|
136
|
+
return wideLatinLetterData[i];
|
|
91
137
|
|
|
92
138
|
} else if (0x1D7CE <= codePoint && codePoint <= 0x1D7FF) {
|
|
93
139
|
// Numerals, ten per row.
|
|
94
140
|
const i = Math.floor((codePoint - 0x1D7CE) / 10);
|
|
95
|
-
return
|
|
141
|
+
return wideNumeralData[i];
|
|
96
142
|
|
|
97
143
|
} else if (codePoint === 0x1D6A5 || codePoint === 0x1D6A6) {
|
|
98
144
|
// dotless i or j
|
|
99
|
-
return
|
|
145
|
+
return wideLatinLetterData[0];
|
|
100
146
|
|
|
101
147
|
} else if (0x1D6A6 < codePoint && codePoint < 0x1D7CE) {
|
|
102
148
|
// Greek letters. Not supported, yet.
|
|
103
|
-
return
|
|
149
|
+
return noFont;
|
|
104
150
|
|
|
105
151
|
} else {
|
|
106
152
|
// We don't support any wide characters outside 1D400–1D7FF.
|