@texuli/deck 0.0.0-stage → 0.5.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/LICENSE +21 -0
- package/README.md +183 -2
- package/dist/authoring/builder.d.ts +351 -0
- package/dist/authoring/builder.js +64 -0
- package/dist/authoring/index.d.ts +6 -0
- package/dist/authoring/index.js +6 -0
- package/dist/authoring/lint.d.ts +36 -0
- package/dist/authoring/lint.js +325 -0
- package/dist/authoring/outlines.d.ts +34 -0
- package/dist/authoring/outlines.js +255 -0
- package/dist/authoring/patch.d.ts +23 -0
- package/dist/authoring/patch.js +166 -0
- package/dist/authoring/select-layouts.d.ts +19 -0
- package/dist/authoring/select-layouts.js +90 -0
- package/dist/engine/auto-slide.d.ts +32 -0
- package/dist/engine/auto-slide.js +67 -0
- package/dist/engine/canvas.d.ts +56 -0
- package/dist/engine/canvas.js +48 -0
- package/dist/engine/controller.d.ts +126 -0
- package/dist/engine/controller.js +248 -0
- package/dist/engine/controls.d.ts +128 -0
- package/dist/engine/controls.js +460 -0
- package/dist/engine/hash.d.ts +42 -0
- package/dist/engine/hash.js +86 -0
- package/dist/engine/index.d.ts +88 -0
- package/dist/engine/index.js +88 -0
- package/dist/engine/messages.d.ts +138 -0
- package/dist/engine/messages.js +140 -0
- package/dist/engine/motion.d.ts +64 -0
- package/dist/engine/motion.js +112 -0
- package/dist/engine/navigation.d.ts +87 -0
- package/dist/engine/navigation.js +156 -0
- package/dist/engine/presenter.d.ts +58 -0
- package/dist/engine/presenter.js +157 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -0
- package/dist/markdown/attributes.d.ts +24 -0
- package/dist/markdown/attributes.js +94 -0
- package/dist/markdown/attrs-closed.d.ts +52 -0
- package/dist/markdown/attrs-closed.js +520 -0
- package/dist/markdown/blocks.d.ts +112 -0
- package/dist/markdown/blocks.js +766 -0
- package/dist/markdown/frontmatter.d.ts +30 -0
- package/dist/markdown/frontmatter.js +165 -0
- package/dist/markdown/index.d.ts +29 -0
- package/dist/markdown/index.js +29 -0
- package/dist/markdown/issues.d.ts +68 -0
- package/dist/markdown/issues.js +83 -0
- package/dist/markdown/json.d.ts +21 -0
- package/dist/markdown/json.js +236 -0
- package/dist/markdown/limits.d.ts +32 -0
- package/dist/markdown/limits.js +32 -0
- package/dist/markdown/parse.d.ts +31 -0
- package/dist/markdown/parse.js +283 -0
- package/dist/markdown/scan.d.ts +26 -0
- package/dist/markdown/scan.js +138 -0
- package/dist/markdown/slides.d.ts +32 -0
- package/dist/markdown/slides.js +854 -0
- package/dist/markdown/text.d.ts +76 -0
- package/dist/markdown/text.js +447 -0
- package/dist/markdown/twin.d.ts +41 -0
- package/dist/markdown/twin.js +374 -0
- package/dist/markdown/write.d.ts +17 -0
- package/dist/markdown/write.js +688 -0
- package/dist/math/index.d.ts +14 -0
- package/dist/math/index.js +14 -0
- package/dist/math/parse.d.ts +9 -0
- package/dist/math/parse.js +648 -0
- package/dist/math/symbols.d.ts +44 -0
- package/dist/math/symbols.js +333 -0
- package/dist/math/types.d.ts +59 -0
- package/dist/math/types.js +69 -0
- package/dist/model/backgrounds/contrast.d.ts +77 -0
- package/dist/model/backgrounds/contrast.js +186 -0
- package/dist/model/backgrounds/index.d.ts +7 -0
- package/dist/model/backgrounds/index.js +7 -0
- package/dist/model/backgrounds/resolve.d.ts +86 -0
- package/dist/model/backgrounds/resolve.js +215 -0
- package/dist/model/backgrounds/schema.d.ts +178 -0
- package/dist/model/backgrounds/schema.js +203 -0
- package/dist/model/codes.d.ts +73 -0
- package/dist/model/codes.js +67 -0
- package/dist/model/deck.d.ts +392 -0
- package/dist/model/deck.js +338 -0
- package/dist/model/index.d.ts +19 -0
- package/dist/model/index.js +19 -0
- package/dist/model/layouts/catalog.d.ts +433 -0
- package/dist/model/layouts/catalog.js +495 -0
- package/dist/model/layouts/index.d.ts +5 -0
- package/dist/model/layouts/index.js +5 -0
- package/dist/model/layouts/props.d.ts +302 -0
- package/dist/model/layouts/props.js +272 -0
- package/dist/model/loader.d.ts +37 -0
- package/dist/model/loader.js +317 -0
- package/dist/model/migrate.d.ts +34 -0
- package/dist/model/migrate.js +453 -0
- package/dist/model/motion/index.d.ts +6 -0
- package/dist/model/motion/index.js +6 -0
- package/dist/model/motion/transition.d.ts +96 -0
- package/dist/model/motion/transition.js +127 -0
- package/dist/model/parse.d.ts +57 -0
- package/dist/model/parse.js +307 -0
- package/dist/model/plain.d.ts +40 -0
- package/dist/model/plain.js +275 -0
- package/dist/model/shared.d.ts +63 -0
- package/dist/model/shared.js +86 -0
- package/dist/model/steps/index.d.ts +7 -0
- package/dist/model/steps/index.js +7 -0
- package/dist/model/steps/phase.d.ts +34 -0
- package/dist/model/steps/phase.js +50 -0
- package/dist/model/steps/slide-steps.d.ts +129 -0
- package/dist/model/steps/slide-steps.js +256 -0
- package/dist/model/style/index.d.ts +8 -0
- package/dist/model/style/index.js +8 -0
- package/dist/model/style/resolve.d.ts +87 -0
- package/dist/model/style/resolve.js +174 -0
- package/dist/model/style/schema.d.ts +85 -0
- package/dist/model/style/schema.js +53 -0
- package/dist/model/style/theme.d.ts +69 -0
- package/dist/model/style/theme.js +84 -0
- package/dist/schema/builders.d.ts +146 -0
- package/dist/schema/builders.js +285 -0
- package/dist/schema/diagnostics.d.ts +78 -0
- package/dist/schema/diagnostics.js +81 -0
- package/dist/schema/index.d.ts +15 -0
- package/dist/schema/index.js +14 -0
- package/dist/schema/internal.d.ts +40 -0
- package/dist/schema/internal.js +209 -0
- package/dist/schema/json-schema.d.ts +12 -0
- package/dist/schema/json-schema.js +213 -0
- package/dist/schema/types.d.ts +166 -0
- package/dist/schema/types.js +1 -0
- package/dist/schema/validate.d.ts +51 -0
- package/dist/schema/validate.js +765 -0
- package/dist/templates/index.d.ts +2 -0
- package/dist/templates/index.js +2 -0
- package/dist/templates/templates.d.ts +11 -0
- package/dist/templates/templates.js +47 -0
- package/package.json +60 -4
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The command tables of the owned TeX subset. Every output character comes
|
|
3
|
+
* from these tables or from the author's own letters, digits and operators.
|
|
4
|
+
*/
|
|
5
|
+
/** Greek letters → identifiers (uppercase ones are upright, as in TeX). */
|
|
6
|
+
export declare const GREEK: Readonly<Record<string, string>>;
|
|
7
|
+
/** Other identifiers. */
|
|
8
|
+
export declare const IDENTIFIERS: Readonly<Record<string, string>>;
|
|
9
|
+
/** Operators, relations and arrows. */
|
|
10
|
+
export declare const OPERATORS: Readonly<Record<string, string>>;
|
|
11
|
+
/** Big operators: limits go under and over in display math (integrals keep scripts). */
|
|
12
|
+
export declare const BIG_OPERATORS: Readonly<Record<string, {
|
|
13
|
+
text: string;
|
|
14
|
+
integral: boolean;
|
|
15
|
+
}>>;
|
|
16
|
+
/** Named functions, written upright; the `limits` ones take limits under them in display. */
|
|
17
|
+
export declare const FUNCTIONS: Readonly<Record<string, {
|
|
18
|
+
limits: boolean;
|
|
19
|
+
}>>;
|
|
20
|
+
/** Accents over a base (`\hat{x}`). */
|
|
21
|
+
export declare const ACCENTS: Readonly<Record<string, string>>;
|
|
22
|
+
/** Accents under a base. */
|
|
23
|
+
export declare const UNDER_ACCENTS: Readonly<Record<string, string>>;
|
|
24
|
+
/** Spacing commands → `mspace` widths. */
|
|
25
|
+
export declare const SPACES: Readonly<Record<string, string>>;
|
|
26
|
+
/** `\mathbb{R}` and friends → MathML `mathvariant`. */
|
|
27
|
+
export declare const FONTS: Readonly<Record<string, string>>;
|
|
28
|
+
/** Characters a backslash makes literal (`\{`, `\%`). */
|
|
29
|
+
export declare const ESCAPED: Readonly<Record<string, string>>;
|
|
30
|
+
/** Delimiters after `\left`, `\right` and the `\big` family. */
|
|
31
|
+
export declare const DELIMITERS: Readonly<Record<string, string>>;
|
|
32
|
+
/** Sizing commands that only change a delimiter's size (read as the plain delimiter). */
|
|
33
|
+
export declare const SIZING: Set<string>;
|
|
34
|
+
/** Matrix-like environments: the fences around them and the column alignment. */
|
|
35
|
+
export declare const ENVIRONMENTS: Readonly<Record<string, {
|
|
36
|
+
open: string;
|
|
37
|
+
close: string;
|
|
38
|
+
align?: string;
|
|
39
|
+
}>>;
|
|
40
|
+
/**
|
|
41
|
+
* Commands refused by policy: they would fetch, link, color, inject markup or
|
|
42
|
+
* define macros. Named so the diagnostic can say why.
|
|
43
|
+
*/
|
|
44
|
+
export declare const REFUSED: Set<string>;
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The command tables of the owned TeX subset. Every output character comes
|
|
3
|
+
* from these tables or from the author's own letters, digits and operators.
|
|
4
|
+
*/
|
|
5
|
+
/** Greek letters → identifiers (uppercase ones are upright, as in TeX). */
|
|
6
|
+
export const GREEK = Object.freeze({
|
|
7
|
+
alpha: 'α',
|
|
8
|
+
beta: 'β',
|
|
9
|
+
gamma: 'γ',
|
|
10
|
+
delta: 'δ',
|
|
11
|
+
epsilon: 'ϵ',
|
|
12
|
+
varepsilon: 'ε',
|
|
13
|
+
zeta: 'ζ',
|
|
14
|
+
eta: 'η',
|
|
15
|
+
theta: 'θ',
|
|
16
|
+
vartheta: 'ϑ',
|
|
17
|
+
iota: 'ι',
|
|
18
|
+
kappa: 'κ',
|
|
19
|
+
lambda: 'λ',
|
|
20
|
+
mu: 'μ',
|
|
21
|
+
nu: 'ν',
|
|
22
|
+
xi: 'ξ',
|
|
23
|
+
pi: 'π',
|
|
24
|
+
varpi: 'ϖ',
|
|
25
|
+
rho: 'ρ',
|
|
26
|
+
varrho: 'ϱ',
|
|
27
|
+
sigma: 'σ',
|
|
28
|
+
varsigma: 'ς',
|
|
29
|
+
tau: 'τ',
|
|
30
|
+
upsilon: 'υ',
|
|
31
|
+
phi: 'ϕ',
|
|
32
|
+
varphi: 'φ',
|
|
33
|
+
chi: 'χ',
|
|
34
|
+
psi: 'ψ',
|
|
35
|
+
omega: 'ω',
|
|
36
|
+
Gamma: 'Γ',
|
|
37
|
+
Delta: 'Δ',
|
|
38
|
+
Theta: 'Θ',
|
|
39
|
+
Lambda: 'Λ',
|
|
40
|
+
Xi: 'Ξ',
|
|
41
|
+
Pi: 'Π',
|
|
42
|
+
Sigma: 'Σ',
|
|
43
|
+
Upsilon: 'Υ',
|
|
44
|
+
Phi: 'Φ',
|
|
45
|
+
Psi: 'Ψ',
|
|
46
|
+
Omega: 'Ω',
|
|
47
|
+
});
|
|
48
|
+
/** Other identifiers. */
|
|
49
|
+
export const IDENTIFIERS = Object.freeze({
|
|
50
|
+
infty: '∞',
|
|
51
|
+
partial: '∂',
|
|
52
|
+
nabla: '∇',
|
|
53
|
+
ell: 'ℓ',
|
|
54
|
+
hbar: 'ℏ',
|
|
55
|
+
emptyset: '∅',
|
|
56
|
+
varnothing: '∅',
|
|
57
|
+
aleph: 'ℵ',
|
|
58
|
+
Re: 'ℜ',
|
|
59
|
+
Im: 'ℑ',
|
|
60
|
+
degree: '°',
|
|
61
|
+
});
|
|
62
|
+
/** Operators, relations and arrows. */
|
|
63
|
+
export const OPERATORS = Object.freeze({
|
|
64
|
+
le: '≤',
|
|
65
|
+
leq: '≤',
|
|
66
|
+
ge: '≥',
|
|
67
|
+
geq: '≥',
|
|
68
|
+
ne: '≠',
|
|
69
|
+
neq: '≠',
|
|
70
|
+
approx: '≈',
|
|
71
|
+
equiv: '≡',
|
|
72
|
+
sim: '∼',
|
|
73
|
+
simeq: '≃',
|
|
74
|
+
cong: '≅',
|
|
75
|
+
propto: '∝',
|
|
76
|
+
in: '∈',
|
|
77
|
+
notin: '∉',
|
|
78
|
+
ni: '∋',
|
|
79
|
+
subset: '⊂',
|
|
80
|
+
subseteq: '⊆',
|
|
81
|
+
supset: '⊃',
|
|
82
|
+
supseteq: '⊇',
|
|
83
|
+
cup: '∪',
|
|
84
|
+
cap: '∩',
|
|
85
|
+
setminus: '∖',
|
|
86
|
+
times: '×',
|
|
87
|
+
cdot: '⋅',
|
|
88
|
+
div: '÷',
|
|
89
|
+
pm: '±',
|
|
90
|
+
mp: '∓',
|
|
91
|
+
ast: '∗',
|
|
92
|
+
star: '⋆',
|
|
93
|
+
circ: '∘',
|
|
94
|
+
bullet: '∙',
|
|
95
|
+
oplus: '⊕',
|
|
96
|
+
otimes: '⊗',
|
|
97
|
+
to: '→',
|
|
98
|
+
rightarrow: '→',
|
|
99
|
+
leftarrow: '←',
|
|
100
|
+
leftrightarrow: '↔',
|
|
101
|
+
Rightarrow: '⇒',
|
|
102
|
+
Leftarrow: '⇐',
|
|
103
|
+
Leftrightarrow: '⇔',
|
|
104
|
+
implies: '⟹',
|
|
105
|
+
iff: '⟺',
|
|
106
|
+
mapsto: '↦',
|
|
107
|
+
uparrow: '↑',
|
|
108
|
+
downarrow: '↓',
|
|
109
|
+
forall: '∀',
|
|
110
|
+
exists: '∃',
|
|
111
|
+
nexists: '∄',
|
|
112
|
+
neg: '¬',
|
|
113
|
+
lnot: '¬',
|
|
114
|
+
land: '∧',
|
|
115
|
+
wedge: '∧',
|
|
116
|
+
lor: '∨',
|
|
117
|
+
vee: '∨',
|
|
118
|
+
ldots: '…',
|
|
119
|
+
cdots: '⋯',
|
|
120
|
+
vdots: '⋮',
|
|
121
|
+
ddots: '⋱',
|
|
122
|
+
dots: '…',
|
|
123
|
+
mid: '∣',
|
|
124
|
+
parallel: '∥',
|
|
125
|
+
perp: '⊥',
|
|
126
|
+
angle: '∠',
|
|
127
|
+
prime: '′',
|
|
128
|
+
langle: '⟨',
|
|
129
|
+
rangle: '⟩',
|
|
130
|
+
lfloor: '⌊',
|
|
131
|
+
rfloor: '⌋',
|
|
132
|
+
lceil: '⌈',
|
|
133
|
+
rceil: '⌉',
|
|
134
|
+
vert: '|',
|
|
135
|
+
Vert: '‖',
|
|
136
|
+
});
|
|
137
|
+
/** Big operators: limits go under and over in display math (integrals keep scripts). */
|
|
138
|
+
export const BIG_OPERATORS = Object.freeze({
|
|
139
|
+
sum: { text: '∑', integral: false },
|
|
140
|
+
prod: { text: '∏', integral: false },
|
|
141
|
+
coprod: { text: '∐', integral: false },
|
|
142
|
+
bigcup: { text: '⋃', integral: false },
|
|
143
|
+
bigcap: { text: '⋂', integral: false },
|
|
144
|
+
bigoplus: { text: '⨁', integral: false },
|
|
145
|
+
bigotimes: { text: '⨂', integral: false },
|
|
146
|
+
int: { text: '∫', integral: true },
|
|
147
|
+
iint: { text: '∬', integral: true },
|
|
148
|
+
iiint: { text: '∭', integral: true },
|
|
149
|
+
oint: { text: '∮', integral: true },
|
|
150
|
+
});
|
|
151
|
+
/** Named functions, written upright; the `limits` ones take limits under them in display. */
|
|
152
|
+
export const FUNCTIONS = Object.freeze({
|
|
153
|
+
sin: { limits: false },
|
|
154
|
+
cos: { limits: false },
|
|
155
|
+
tan: { limits: false },
|
|
156
|
+
cot: { limits: false },
|
|
157
|
+
sec: { limits: false },
|
|
158
|
+
csc: { limits: false },
|
|
159
|
+
arcsin: { limits: false },
|
|
160
|
+
arccos: { limits: false },
|
|
161
|
+
arctan: { limits: false },
|
|
162
|
+
sinh: { limits: false },
|
|
163
|
+
cosh: { limits: false },
|
|
164
|
+
tanh: { limits: false },
|
|
165
|
+
log: { limits: false },
|
|
166
|
+
ln: { limits: false },
|
|
167
|
+
lg: { limits: false },
|
|
168
|
+
exp: { limits: false },
|
|
169
|
+
deg: { limits: false },
|
|
170
|
+
arg: { limits: false },
|
|
171
|
+
dim: { limits: false },
|
|
172
|
+
ker: { limits: false },
|
|
173
|
+
det: { limits: true },
|
|
174
|
+
gcd: { limits: true },
|
|
175
|
+
lim: { limits: true },
|
|
176
|
+
max: { limits: true },
|
|
177
|
+
min: { limits: true },
|
|
178
|
+
sup: { limits: true },
|
|
179
|
+
inf: { limits: true },
|
|
180
|
+
Pr: { limits: true },
|
|
181
|
+
});
|
|
182
|
+
/** Accents over a base (`\hat{x}`). */
|
|
183
|
+
export const ACCENTS = Object.freeze({
|
|
184
|
+
hat: '^',
|
|
185
|
+
widehat: '^',
|
|
186
|
+
bar: '¯',
|
|
187
|
+
vec: '→',
|
|
188
|
+
dot: '˙',
|
|
189
|
+
ddot: '¨',
|
|
190
|
+
tilde: '~',
|
|
191
|
+
widetilde: '~',
|
|
192
|
+
acute: '´',
|
|
193
|
+
grave: '`',
|
|
194
|
+
check: 'ˇ',
|
|
195
|
+
breve: '˘',
|
|
196
|
+
overline: '‾',
|
|
197
|
+
overrightarrow: '→',
|
|
198
|
+
overleftarrow: '←',
|
|
199
|
+
overbrace: '⏞',
|
|
200
|
+
});
|
|
201
|
+
/** Accents under a base. */
|
|
202
|
+
export const UNDER_ACCENTS = Object.freeze({
|
|
203
|
+
underline: '_',
|
|
204
|
+
underbrace: '⏟',
|
|
205
|
+
});
|
|
206
|
+
/** Spacing commands → `mspace` widths. */
|
|
207
|
+
export const SPACES = Object.freeze({
|
|
208
|
+
',': '0.1667em',
|
|
209
|
+
':': '0.2222em',
|
|
210
|
+
'>': '0.2222em',
|
|
211
|
+
';': '0.2778em',
|
|
212
|
+
' ': '0.3333em',
|
|
213
|
+
'!': '-0.1667em',
|
|
214
|
+
quad: '1em',
|
|
215
|
+
qquad: '2em',
|
|
216
|
+
thinspace: '0.1667em',
|
|
217
|
+
medspace: '0.2222em',
|
|
218
|
+
thickspace: '0.2778em',
|
|
219
|
+
enspace: '0.5em',
|
|
220
|
+
});
|
|
221
|
+
/** `\mathbb{R}` and friends → MathML `mathvariant`. */
|
|
222
|
+
export const FONTS = Object.freeze({
|
|
223
|
+
mathrm: 'normal',
|
|
224
|
+
mathup: 'normal',
|
|
225
|
+
mathbf: 'bold',
|
|
226
|
+
mathit: 'italic',
|
|
227
|
+
mathbb: 'double-struck',
|
|
228
|
+
mathcal: 'script',
|
|
229
|
+
mathscr: 'script',
|
|
230
|
+
mathfrak: 'fraktur',
|
|
231
|
+
mathsf: 'sans-serif',
|
|
232
|
+
mathtt: 'monospace',
|
|
233
|
+
boldsymbol: 'bold-italic',
|
|
234
|
+
});
|
|
235
|
+
/** Characters a backslash makes literal (`\{`, `\%`). */
|
|
236
|
+
export const ESCAPED = Object.freeze({
|
|
237
|
+
'{': '{',
|
|
238
|
+
'}': '}',
|
|
239
|
+
'%': '%',
|
|
240
|
+
$: '$',
|
|
241
|
+
'&': '&',
|
|
242
|
+
'#': '#',
|
|
243
|
+
_: '_',
|
|
244
|
+
'|': '‖',
|
|
245
|
+
});
|
|
246
|
+
/** Delimiters after `\left`, `\right` and the `\big` family. */
|
|
247
|
+
export const DELIMITERS = Object.freeze({
|
|
248
|
+
'(': '(',
|
|
249
|
+
')': ')',
|
|
250
|
+
'[': '[',
|
|
251
|
+
']': ']',
|
|
252
|
+
'|': '|',
|
|
253
|
+
'/': '/',
|
|
254
|
+
'.': '',
|
|
255
|
+
'\\{': '{',
|
|
256
|
+
'\\}': '}',
|
|
257
|
+
'\\|': '‖',
|
|
258
|
+
'\\langle': '⟨',
|
|
259
|
+
'\\rangle': '⟩',
|
|
260
|
+
'\\lfloor': '⌊',
|
|
261
|
+
'\\rfloor': '⌋',
|
|
262
|
+
'\\lceil': '⌈',
|
|
263
|
+
'\\rceil': '⌉',
|
|
264
|
+
'\\vert': '|',
|
|
265
|
+
'\\Vert': '‖',
|
|
266
|
+
});
|
|
267
|
+
/** Sizing commands that only change a delimiter's size (read as the plain delimiter). */
|
|
268
|
+
export const SIZING = new Set([
|
|
269
|
+
'big',
|
|
270
|
+
'Big',
|
|
271
|
+
'bigg',
|
|
272
|
+
'Bigg',
|
|
273
|
+
'bigl',
|
|
274
|
+
'bigr',
|
|
275
|
+
'Bigl',
|
|
276
|
+
'Bigr',
|
|
277
|
+
'biggl',
|
|
278
|
+
'biggr',
|
|
279
|
+
'Biggl',
|
|
280
|
+
'Biggr',
|
|
281
|
+
]);
|
|
282
|
+
/** Matrix-like environments: the fences around them and the column alignment. */
|
|
283
|
+
export const ENVIRONMENTS = Object.freeze({
|
|
284
|
+
matrix: { open: '', close: '' },
|
|
285
|
+
smallmatrix: { open: '', close: '' },
|
|
286
|
+
pmatrix: { open: '(', close: ')' },
|
|
287
|
+
bmatrix: { open: '[', close: ']' },
|
|
288
|
+
Bmatrix: { open: '{', close: '}' },
|
|
289
|
+
vmatrix: { open: '|', close: '|' },
|
|
290
|
+
Vmatrix: { open: '‖', close: '‖' },
|
|
291
|
+
cases: { open: '{', close: '', align: 'left' },
|
|
292
|
+
aligned: { open: '', close: '', align: 'right left' },
|
|
293
|
+
align: { open: '', close: '', align: 'right left' },
|
|
294
|
+
gathered: { open: '', close: '' },
|
|
295
|
+
array: { open: '', close: '' },
|
|
296
|
+
});
|
|
297
|
+
/**
|
|
298
|
+
* Commands refused by policy: they would fetch, link, color, inject markup or
|
|
299
|
+
* define macros. Named so the diagnostic can say why.
|
|
300
|
+
*/
|
|
301
|
+
export const REFUSED = new Set([
|
|
302
|
+
'href',
|
|
303
|
+
'url',
|
|
304
|
+
'includegraphics',
|
|
305
|
+
'color',
|
|
306
|
+
'textcolor',
|
|
307
|
+
'colorbox',
|
|
308
|
+
'fcolorbox',
|
|
309
|
+
'htmlClass',
|
|
310
|
+
'htmlId',
|
|
311
|
+
'htmlStyle',
|
|
312
|
+
'htmlData',
|
|
313
|
+
'html',
|
|
314
|
+
'def',
|
|
315
|
+
'gdef',
|
|
316
|
+
'edef',
|
|
317
|
+
'xdef',
|
|
318
|
+
'let',
|
|
319
|
+
'newcommand',
|
|
320
|
+
'renewcommand',
|
|
321
|
+
'providecommand',
|
|
322
|
+
'DeclareMathOperator',
|
|
323
|
+
'input',
|
|
324
|
+
'include',
|
|
325
|
+
'verb',
|
|
326
|
+
'tag',
|
|
327
|
+
'label',
|
|
328
|
+
'ref',
|
|
329
|
+
'eqref',
|
|
330
|
+
'style',
|
|
331
|
+
'class',
|
|
332
|
+
'cssId',
|
|
333
|
+
]);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MathML node tree the owned TeX subset produces (ADR-009, math policy).
|
|
3
|
+
* A renderer walks it with a closed tag and attribute allowlist; no string of
|
|
4
|
+
* markup is ever produced, so nothing here reaches an HTML sink.
|
|
5
|
+
*/
|
|
6
|
+
/** The MathML Core elements the converter emits. */
|
|
7
|
+
export declare const MATH_TAGS: readonly ["math", "mrow", "mi", "mn", "mo", "mtext", "mspace", "msup", "msub", "msubsup", "mfrac", "msqrt", "mroot", "mover", "munder", "munderover", "mtable", "mtr", "mtd", "mstyle"];
|
|
8
|
+
export type MathTag = (typeof MATH_TAGS)[number];
|
|
9
|
+
/** The attributes the converter may set (values are always from its own tables). */
|
|
10
|
+
export declare const MATH_ATTRIBUTES: readonly ["display", "alttext", "mathvariant", "stretchy", "fence", "separator", "largeop", "movablelimits", "accent", "accentunder", "linethickness", "width", "columnalign", "displaystyle", "scriptlevel", "form", "lspace", "rspace"];
|
|
11
|
+
export type MathAttribute = (typeof MATH_ATTRIBUTES)[number];
|
|
12
|
+
export interface MathNode {
|
|
13
|
+
tag: MathTag;
|
|
14
|
+
attrs?: Partial<Record<MathAttribute, string>>;
|
|
15
|
+
/** Token elements (`mi`, `mn`, `mo`, `mtext`) carry text; the others carry children. */
|
|
16
|
+
text?: string;
|
|
17
|
+
children?: MathNode[];
|
|
18
|
+
}
|
|
19
|
+
export declare const MATH_CODES: Readonly<{
|
|
20
|
+
/** A command or environment outside the subset (`\href`, `\color`, macros…). */
|
|
21
|
+
readonly unsupported: "tex-unsupported";
|
|
22
|
+
/** Unbalanced braces, a missing argument, a double script… */
|
|
23
|
+
readonly syntax: "tex-syntax";
|
|
24
|
+
/** Over a size, nesting or node bound. */
|
|
25
|
+
readonly limit: "tex-limit";
|
|
26
|
+
}>;
|
|
27
|
+
export type MathCode = (typeof MATH_CODES)[keyof typeof MATH_CODES];
|
|
28
|
+
export interface MathIssue {
|
|
29
|
+
code: MathCode;
|
|
30
|
+
message: string;
|
|
31
|
+
/** UTF-16 offset in the TeX source. */
|
|
32
|
+
offset: number;
|
|
33
|
+
}
|
|
34
|
+
export interface MathResult {
|
|
35
|
+
/** True when the whole source converted. */
|
|
36
|
+
ok: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The `math` root. When `ok` is false it holds the TeX source as `mtext`,
|
|
39
|
+
* so a failed formula still shows what the author wrote.
|
|
40
|
+
*/
|
|
41
|
+
node: MathNode;
|
|
42
|
+
issues: MathIssue[];
|
|
43
|
+
}
|
|
44
|
+
export interface TexToMathOptions {
|
|
45
|
+
/** Block (`$$`) math; default false (inline). */
|
|
46
|
+
display?: boolean;
|
|
47
|
+
}
|
|
48
|
+
/** Bounds per formula (hostile input stays cheap). */
|
|
49
|
+
export declare const MATH_LIMITS: Readonly<{
|
|
50
|
+
/** TeX source length in UTF-16 units. */
|
|
51
|
+
source: 2000;
|
|
52
|
+
/** Nested groups, environments and fractions. */
|
|
53
|
+
depth: 16;
|
|
54
|
+
/** Output nodes. */
|
|
55
|
+
nodes: 2000;
|
|
56
|
+
/** Rows and cells of one environment. */
|
|
57
|
+
rows: 50;
|
|
58
|
+
cells: 400;
|
|
59
|
+
}>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MathML node tree the owned TeX subset produces (ADR-009, math policy).
|
|
3
|
+
* A renderer walks it with a closed tag and attribute allowlist; no string of
|
|
4
|
+
* markup is ever produced, so nothing here reaches an HTML sink.
|
|
5
|
+
*/
|
|
6
|
+
/** The MathML Core elements the converter emits. */
|
|
7
|
+
export const MATH_TAGS = [
|
|
8
|
+
'math',
|
|
9
|
+
'mrow',
|
|
10
|
+
'mi',
|
|
11
|
+
'mn',
|
|
12
|
+
'mo',
|
|
13
|
+
'mtext',
|
|
14
|
+
'mspace',
|
|
15
|
+
'msup',
|
|
16
|
+
'msub',
|
|
17
|
+
'msubsup',
|
|
18
|
+
'mfrac',
|
|
19
|
+
'msqrt',
|
|
20
|
+
'mroot',
|
|
21
|
+
'mover',
|
|
22
|
+
'munder',
|
|
23
|
+
'munderover',
|
|
24
|
+
'mtable',
|
|
25
|
+
'mtr',
|
|
26
|
+
'mtd',
|
|
27
|
+
'mstyle',
|
|
28
|
+
];
|
|
29
|
+
/** The attributes the converter may set (values are always from its own tables). */
|
|
30
|
+
export const MATH_ATTRIBUTES = [
|
|
31
|
+
'display',
|
|
32
|
+
'alttext',
|
|
33
|
+
'mathvariant',
|
|
34
|
+
'stretchy',
|
|
35
|
+
'fence',
|
|
36
|
+
'separator',
|
|
37
|
+
'largeop',
|
|
38
|
+
'movablelimits',
|
|
39
|
+
'accent',
|
|
40
|
+
'accentunder',
|
|
41
|
+
'linethickness',
|
|
42
|
+
'width',
|
|
43
|
+
'columnalign',
|
|
44
|
+
'displaystyle',
|
|
45
|
+
'scriptlevel',
|
|
46
|
+
'form',
|
|
47
|
+
'lspace',
|
|
48
|
+
'rspace',
|
|
49
|
+
];
|
|
50
|
+
export const MATH_CODES = Object.freeze({
|
|
51
|
+
/** A command or environment outside the subset (`\href`, `\color`, macros…). */
|
|
52
|
+
unsupported: 'tex-unsupported',
|
|
53
|
+
/** Unbalanced braces, a missing argument, a double script… */
|
|
54
|
+
syntax: 'tex-syntax',
|
|
55
|
+
/** Over a size, nesting or node bound. */
|
|
56
|
+
limit: 'tex-limit',
|
|
57
|
+
});
|
|
58
|
+
/** Bounds per formula (hostile input stays cheap). */
|
|
59
|
+
export const MATH_LIMITS = Object.freeze({
|
|
60
|
+
/** TeX source length in UTF-16 units. */
|
|
61
|
+
source: 2_000,
|
|
62
|
+
/** Nested groups, environments and fractions. */
|
|
63
|
+
depth: 16,
|
|
64
|
+
/** Output nodes. */
|
|
65
|
+
nodes: 2_000,
|
|
66
|
+
/** Rows and cells of one environment. */
|
|
67
|
+
rows: 50,
|
|
68
|
+
cells: 400,
|
|
69
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WCAG 2.x contrast math for deck backgrounds, on sRGB hex colors only.
|
|
3
|
+
*
|
|
4
|
+
* Every function here is pure and framework-free. Inputs are `#rgb` or
|
|
5
|
+
* `#rrggbb` (and, through `opaqueColor`, `rgb()`/`rgba()` composited over a
|
|
6
|
+
* base); `oklch()` and other color spaces are converted by the caller (the
|
|
7
|
+
* stage reads them from `@texuli/tokens`). Outputs are always lowercase
|
|
8
|
+
* `#rrggbb`, so a computed color can go into CSS without escaping.
|
|
9
|
+
*/
|
|
10
|
+
/** WCAG AA for normal-size body text: the floor every background guarantees. */
|
|
11
|
+
export declare const DECK_TEXT_CONTRAST_MIN = 4.5;
|
|
12
|
+
/** Scrim alphas move in steps of 0.05 … */
|
|
13
|
+
export declare const DECK_SCRIM_STEP = 0.05;
|
|
14
|
+
/** … up to 0.9 (an image or video always stays faintly visible). */
|
|
15
|
+
export declare const DECK_SCRIM_MAX = 0.9;
|
|
16
|
+
/** Light ink and the scrim under it; dark ink and the scrim under it. */
|
|
17
|
+
export declare const PURE_LIGHT = "#ffffff";
|
|
18
|
+
export declare const PURE_DARK = "#000000";
|
|
19
|
+
export type TextTone = 'light' | 'dark';
|
|
20
|
+
export type Rgb = readonly [number, number, number];
|
|
21
|
+
/** `#rgb` or `#rrggbb` (any case, surrounding spaces ignored) as 0–255 channels; anything else is `null`. */
|
|
22
|
+
export declare function parseHexColor(color: unknown): Rgb | null;
|
|
23
|
+
/** Channels → lowercase `#rrggbb` (channels are clamped and rounded). */
|
|
24
|
+
export declare function toHex(rgb: Rgb): string;
|
|
25
|
+
/** A hex color in its canonical form (`#rrggbb`, lowercase), or `null`. */
|
|
26
|
+
export declare function normalizeHex(color: unknown): string | null;
|
|
27
|
+
/** WCAG relative luminance (0 for black, 1 for white). Throws `TypeError` on a non-hex color. */
|
|
28
|
+
export declare function relativeLuminance(color: string): number;
|
|
29
|
+
/** WCAG contrast ratio, 1 to 21, order independent. Throws `TypeError` on a non-hex color. */
|
|
30
|
+
export declare function contrastRatio(a: string, b: string): number;
|
|
31
|
+
/** `top` over `base` at `alpha` (0–1), composited in sRGB as browsers paint it. */
|
|
32
|
+
export declare function compositeOver(base: string, top: string, alpha: number): string;
|
|
33
|
+
/**
|
|
34
|
+
* A palette color as an opaque hex: hex passes through (canonicalized),
|
|
35
|
+
* `rgb()`/`rgba()` is composited over `base` (dark-mode borders carry alpha).
|
|
36
|
+
* Anything else is `null`, so the contrast math never guesses at a color.
|
|
37
|
+
*/
|
|
38
|
+
export declare function opaqueColor(color: unknown, base: string): string | null;
|
|
39
|
+
/** Points along a linear sRGB gradient: every stop and `perSegment - 1` points between each pair. */
|
|
40
|
+
export declare function sampleGradient(stops: readonly string[], perSegment?: number): string[];
|
|
41
|
+
/** The lowest contrast of `ink` over any of `backgrounds` (21 for an empty list). */
|
|
42
|
+
export declare function worstContrast(ink: string, backgrounds: readonly string[]): number;
|
|
43
|
+
/** The first scrim step at or above `alpha` (an author overlay is never weakened). */
|
|
44
|
+
export declare function scrimStepFor(alpha: number): number;
|
|
45
|
+
export interface InkChoice {
|
|
46
|
+
tone: TextTone;
|
|
47
|
+
ink: string;
|
|
48
|
+
/** Black under light ink, white under dark ink. */
|
|
49
|
+
scrimColor: string;
|
|
50
|
+
/** 0 to 0.9 in 0.05 steps; 0 means no scrim is painted. */
|
|
51
|
+
scrim: number;
|
|
52
|
+
/** Worst-case contrast of `ink` over every background with the scrim, ≥ `minimum`. */
|
|
53
|
+
contrast: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The lowest scrim (in 0.05 steps, from `minimumScrim` up to 0.9) under which
|
|
57
|
+
* `ink` reaches `minimum` over every background, or `null` when none does.
|
|
58
|
+
*/
|
|
59
|
+
export declare function inkWithScrim(tone: TextTone, ink: string, backgrounds: readonly string[], minimumScrim?: number, minimum?: number): InkChoice | null;
|
|
60
|
+
export interface ChooseInkOptions {
|
|
61
|
+
/** Only this tone (an image declared dark or light). */
|
|
62
|
+
forced?: TextTone;
|
|
63
|
+
/** The author's overlay: the scrim never goes below it. */
|
|
64
|
+
minimumScrim?: number;
|
|
65
|
+
/** The contrast floor; values below 4.5 are raised to 4.5. */
|
|
66
|
+
minimum?: number;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The ink for a set of backgrounds. Each tone tries the theme ink first and
|
|
70
|
+
* pure white or black second; the choice needs the lightest scrim, then
|
|
71
|
+
* prefers the theme ink, then the higher contrast. Pure ink over a 0.9 scrim
|
|
72
|
+
* always clears AA (about 15:1 against any pixel), so a result always exists.
|
|
73
|
+
*/
|
|
74
|
+
export declare function chooseInk(backgrounds: readonly string[], inks: {
|
|
75
|
+
light: string;
|
|
76
|
+
dark: string;
|
|
77
|
+
}, options?: ChooseInkOptions): InkChoice;
|