@mdit/plugin-mathjax-slim 0.24.1 → 0.25.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/lib/sync.d.ts CHANGED
@@ -1,296 +1,432 @@
1
- import { LiteElement } from '@mathjax/src/js/adaptors/lite/Element.js';
2
- import { LiteAdaptor } from '@mathjax/src/js/adaptors/liteAdaptor.js';
3
- import { TeX } from '@mathjax/src/js/input/tex.js';
4
- import { CHTML } from '@mathjax/src/js/output/chtml.js';
5
- import { SVG } from '@mathjax/src/js/output/svg.js';
6
- import MarkdownIt from 'markdown-it';
7
- import { MarkdownItTexOptions } from '@mdit/plugin-tex';
8
- import { MmlNode } from '@mathjax/src/js/core/MmlTree/MmlNode.js';
9
- import TexError from '@mathjax/src/js/input/tex/TexError.js';
1
+ import { MarkdownItTexOptions } from "@mdit/plugin-tex";
2
+ import { LiteAdaptor } from "@mathjax/src/cjs/adaptors/liteAdaptor.js";
3
+ import { TeX } from "@mathjax/src/cjs/input/tex.js";
4
+ import { CHTML } from "@mathjax/src/cjs/output/chtml.js";
5
+ import { SVG } from "@mathjax/src/cjs/output/svg.js";
6
+ import { LiteElement } from "@mathjax/src/cjs/adaptors/lite/Element.js";
7
+ import MarkdownIt from "markdown-it";
8
+ import { MmlNode } from "@mathjax/src/js/core/MmlTree/MmlNode.js";
9
+ import TexError from "@mathjax/src/js/input/tex/TexError.js";
10
+ import { TeX as TeX$1 } from "@mathjax/src/js/input/tex.js";
11
+ import { ChtmlFontData } from "@mathjax/src/js/output/chtml/FontData.js";
12
+ import { SvgFontData } from "@mathjax/src/js/output/svg/FontData.js";
13
+ import { MathItem } from "@mathjax/src/js/core/MathItem.js";
14
+ import { LiteElement as LiteElement$1 } from "@mathjax/src/js/adaptors/lite/Element.js";
15
+ import { MathDocument } from "@mathjax/src/js/core/MathDocument.js";
16
+ import { CssStyles } from "@mathjax/src/js/ui/menu/mj-context-menu.js";
17
+ import { LinebreakVisitor } from "@mathjax/src/js/output/common/LinebreakVisitor.js";
18
+ import { SvgWrapperFactory } from "@mathjax/src/js/output/svg/WrapperFactory.js";
19
+ import { ChtmlWrapperFactory } from "@mathjax/src/js/output/chtml/WrapperFactory.js";
10
20
 
21
+ //#region src/mathjax.d.ts
11
22
  type TexPackage = "action" | "ams" | "amscd" | "bbm" | "bboldx" | "bbox" | "begingroup" | "boldsymbol" | "braket" | "bussproofs" | "cancel" | "cases" | "centernot" | "color" | "colortbl" | "colorv2" | "configmacros" | "dsfont" | "empheq" | "enclose" | "extpfeil" | "gensymb" | "html" | "mathtools" | "mhchem" | "newcommand" | "noerrors" | "noundefined" | "physics" | "setoptions" | "tagformat" | "texhtml" | "textcomp" | "textmacros" | "unicode" | "units" | "upgreek" | "verb";
12
23
  interface MathJaxTexInputOptions {
13
- /**
14
- * extensions to use
15
- *
16
- * @default [
17
- * 'base',
18
- * 'action',
19
- * 'ams',
20
- * 'amscd',
21
- * 'bbm',
22
- * 'bboldx',
23
- * 'bbox',
24
- * 'begingroup',
25
- * 'boldsymbol',
26
- * 'braket',
27
- * 'bussproofs',
28
- * 'cancel',
29
- * 'cases',
30
- * 'centernot',
31
- * 'color',
32
- * 'colortbl',
33
- * 'colorv2',
34
- * 'configmacros',
35
- * 'dsfont',
36
- * 'empheq',
37
- * 'enclose',
38
- * 'extpfeil',
39
- * 'gensymb',
40
- * 'html',
41
- * 'mathtools',
42
- * 'mhchem',
43
- * 'newcommand',
44
- * 'noerrors',
45
- * 'noundefined',
46
- * 'physics',
47
- * 'require',
48
- * 'setoptions',
49
- * 'tagformat',
50
- * 'texhtml',
51
- * 'textcomp',
52
- * 'textmacros',
53
- * 'unicode',
54
- * 'units',
55
- * 'upgreek',
56
- * 'verb',
57
- * ]
58
- */
59
- packages?: TexPackage[];
60
- /**
61
- * pattern for recognizing numbers
62
- *
63
- * @default /^(?:[0-9]+(?:\{,\}[0-9]{3})*(?:\.[0-9]*)?|\.[0-9]+)/
64
- */
65
- digits?: RegExp;
66
- tags?: "ams" | "all" | "none";
67
- /**
68
- * side for `\tag` macros
69
- */
70
- tagSide?: "left" | "right";
71
- /**
72
- * amount to indent tags
73
- *
74
- * @default "0.8em"
75
- */
76
- tagIndent?: "0.8em";
77
- /**
78
- * use label name rather than tag for ids
79
- *
80
- * @default true;
81
- */
82
- useLabelIds?: boolean;
83
- /**
84
- * maximum number of macro substitutions per expression
85
- *
86
- * @default 1000
87
- */
88
- maxMacros?: number;
89
- /**
90
- * maximum size for the internal TeX string (in bytes)
91
- *
92
- * @default 5120
93
- */
94
- maxBuffer?: number;
95
- formatError?: (jax: TeX<unknown, unknown, unknown>, error: typeof TexError) => MmlNode;
24
+ /**
25
+ * extensions to use
26
+ *
27
+ * @default [
28
+ * 'action',
29
+ * 'ams',
30
+ * 'amscd',
31
+ * 'bbm',
32
+ * 'bboldx',
33
+ * 'bbox',
34
+ * 'begingroup',
35
+ * 'boldsymbol',
36
+ * 'braket',
37
+ * 'bussproofs',
38
+ * 'cancel',
39
+ * 'cases',
40
+ * 'centernot',
41
+ * 'color',
42
+ * 'colortbl',
43
+ * 'colorv2',
44
+ * 'configmacros',
45
+ * 'dsfont',
46
+ * 'empheq',
47
+ * 'enclose',
48
+ * 'extpfeil',
49
+ * 'gensymb',
50
+ * 'html',
51
+ * 'mathtools',
52
+ * 'mhchem',
53
+ * 'newcommand',
54
+ * 'noerrors',
55
+ * 'noundefined',
56
+ * 'physics',
57
+ * 'require',
58
+ * 'setoptions',
59
+ * 'tagformat',
60
+ * 'texhtml',
61
+ * 'textcomp',
62
+ * 'textmacros',
63
+ * 'unicode',
64
+ * 'units',
65
+ * 'upgreek',
66
+ * 'verb',
67
+ * ]
68
+ */
69
+ packages?: TexPackage[];
70
+ /**
71
+ * pattern for recognizing numbers
72
+ *
73
+ * @default /^(?:[0-9]+(?:\{,\}[0-9]{3})*(?:\.[0-9]*)?|\.[0-9]+)/
74
+ */
75
+ digits?: RegExp;
76
+ tags?: "ams" | "all" | "none";
77
+ /**
78
+ * side for `\tag` macros
79
+ */
80
+ tagSide?: "left" | "right";
81
+ /**
82
+ * amount to indent tags
83
+ *
84
+ * @default "0.8em"
85
+ */
86
+ tagIndent?: "0.8em";
87
+ /**
88
+ * use label name rather than tag for ids
89
+ *
90
+ * @default true;
91
+ */
92
+ useLabelIds?: boolean;
93
+ /**
94
+ * maximum number of macro substitutions per expression
95
+ *
96
+ * @default 1000
97
+ */
98
+ maxMacros?: number;
99
+ /**
100
+ * maximum size for the internal TeX string (in bytes)
101
+ *
102
+ * @default 5120
103
+ */
104
+ maxBuffer?: number;
105
+ formatError?: (jax: TeX$1<unknown, unknown, unknown>, error: typeof TexError) => MmlNode;
106
+ }
107
+ /**
108
+ * Data passed to MathJax filters
109
+ */
110
+ interface MathjaxFilterData {
111
+ math: MathItem<LiteElement$1, string, HTMLElement>;
112
+ document: MathDocument<LiteElement$1, string, HTMLElement>;
113
+ data: any;
96
114
  }
115
+ /**
116
+ * MathJax filter function
117
+ */
118
+ type MathjaxFilter = (data: MathjaxFilterData) => void;
119
+ /**
120
+ * @see https://docs.mathjax.org/en/latest/options/output/index.html#option-descriptions
121
+ */
97
122
  interface MathjaxCommonOutputOptions {
98
- /**
99
- * Global scaling factor for all expressions
100
- *
101
- * @default 1
102
- */
103
- scale?: number;
104
- /**
105
- * smallest scaling factor to use
106
- *
107
- * @default 0.5
108
- */
109
- minScale?: number;
110
- /**
111
- * make mtext elements use surrounding font
112
- *
113
- * @default false
114
- */
115
- mtextInheritFont?: boolean;
116
- /**
117
- * make merror text use surrounding font
123
+ /**
124
+ * Global scaling factor for all expressions
125
+ *
126
+ * @default 1
127
+ */
128
+ scale?: number;
129
+ /**
130
+ * smallest scaling factor to use
131
+ *
132
+ * @default 0.5
133
+ */
134
+ minScale?: number;
135
+ /**
136
+ * make mtext elements use surrounding font
137
+ *
138
+ * @default false
139
+ */
140
+ mtextInheritFont?: boolean;
141
+ /**
142
+ * make merror text use surrounding font
143
+ *
144
+ * @default true
145
+ */
146
+ merrorInheritFont?: boolean;
147
+ /**
148
+ * font to use for mtext, if not inheriting (empty means use MathJax fonts)
149
+ *
150
+ * @default ""
151
+ */
152
+ mtextFont?: string;
153
+ /**
154
+ * font to use for merror, if not inheriting (empty means use MathJax fonts)
155
+ *
156
+ * @default "serif"
157
+ */
158
+ merrorFont?: string;
159
+ /**
160
+ * font to use for character that aren’t in MathJax's fonts
161
+ *
162
+ * @default "serif"
163
+ */
164
+ unknownFamily?: string;
165
+ /**
166
+ * - `true` for MathML spacing rules
167
+ * - `false` for TeX rules
168
+ *
169
+ * @default false
170
+ */
171
+ mathmlSpacing?: boolean;
172
+ /**
173
+ * RFDa and other attributes NOT to copy to the output
174
+ */
175
+ skipAttributes?: Record<string, boolean>;
176
+ /**
177
+ * default size of ex in em units
178
+ *
179
+ * @default 0.5
180
+ */
181
+ exFactor?: number;
182
+ /**
183
+ * default for indentalign when set to 'auto'
184
+ *
185
+ * @default "center"
186
+ */
187
+ displayAlign?: "left" | "center" | "right";
188
+ /**
189
+ * default for indentshift when set to 'auto'
190
+ *
191
+ * @default 0
192
+ */
193
+ displayIndent?: string;
194
+ /**
195
+ * default for overflow
196
+ *
197
+ * @default "overflow"
198
+ */
199
+ displayOverflow?: "scroll" | "scale" | "truncate" | "elide" | "linebreak" | "overflow";
200
+ /**
201
+ * options for when overflow is linebreak
202
+ */
203
+ linebreaks?: {
204
+ /**
205
+ * true for browser-based breaking of inline equations
118
206
  *
119
207
  * @default true
120
208
  */
121
- merrorInheritFont?: boolean;
122
- /**
123
- * font to use for mtext, if not inheriting (empty means use MathJax fonts)
124
- *
125
- * @default ""
126
- */
127
- mtextFont?: string;
128
- /**
129
- * font to use for merror, if not inheriting (empty means use MathJax fonts)
130
- *
131
- * @default "serif"
132
- */
133
- merrorFont?: string;
209
+ inline?: boolean;
134
210
  /**
135
- * font to use for character that aren’t in MathJax's fonts
211
+ * a fixed size or a percentage of the container width
136
212
  *
137
- * @default "serif"
213
+ * @default "100%"
138
214
  */
139
- unknownFamily?: string;
215
+ width?: string;
140
216
  /**
141
- * @default "center"
142
- */
143
- displayAlign?: "left" | "center" | "right";
144
- /**
145
- * @default 0
146
- */
147
- displayIndent?: string;
148
- /**
149
- * - `true` for MathML spacing rules
150
- * - `false` for TeX rules
151
- *
152
- * @default false
153
- */
154
- mathmlSpacing?: boolean;
155
- /**
156
- * RFDa and other attributes NOT to copy to the output
157
- */
158
- skipAttributes?: Record<string, boolean>;
159
- /**
160
- * default size of ex in em units
217
+ * the default lineleading in em units
161
218
  *
162
- * @default 0.5
163
- */
164
- exFactor?: number;
219
+ * @default 0.2
220
+ */
221
+ lineleading?: number;
222
+ /**
223
+ * for developers only
224
+ */
225
+ LinebreakVisitor?: typeof LinebreakVisitor;
226
+ };
227
+ /**
228
+ * the font component to load
229
+ *
230
+ * @default ""
231
+ */
232
+ font?: string;
233
+ /**
234
+ * The path to the font definitions
235
+ *
236
+ * @default "https://cdn.jsdelivr.net/npm/@mathjax/mathjax-newcm-font/"
237
+ */
238
+ fontPath?: string;
239
+ /**
240
+ * The font extensions to load
241
+ *
242
+ * @default []
243
+ */
244
+ fontExtensions?: string[];
245
+ /**
246
+ * 'use', 'force', or 'ignore' data-mjx-hdw attributes
247
+ *
248
+ * @default "auto"
249
+ */
250
+ htmlHDW?: "use" | "force" | "ignore";
251
+ /**
252
+ * A list of pre-filters to add to the output jax
253
+ *
254
+ * @default []
255
+ */
256
+ preFilters?: MathjaxFilter[];
257
+ /**
258
+ * A list of post-filters to add to the output jax
259
+ *
260
+ * @default []
261
+ */
262
+ postFilters?: MathjaxFilter[];
263
+ /**
264
+ * for developers only
265
+ */
266
+ cssStyles?: typeof CssStyles;
165
267
  }
166
268
  interface MathjaxCommonHTMLOutputOptions extends MathjaxCommonOutputOptions {
167
- /**
168
- * Whether match ex-height of surrounding font
169
- *
170
- * @default true
171
- */
172
- matchFontHeight?: boolean;
173
- /**
174
- * The URL where the fonts are found
175
- *
176
- * @default local form @mathjax/src
177
- */
178
- fontURL?: string;
179
- /**
180
- * Whether only produce CSS that is used in the processed equations
181
- *
182
- * @default true
183
- */
184
- adaptiveCSS?: boolean;
269
+ /**
270
+ * Whether match ex-height of surrounding font
271
+ *
272
+ * @default true
273
+ */
274
+ matchFontHeight?: boolean;
275
+ /**
276
+ * Font data to use
277
+ *
278
+ * @default font data from `@mathjax/mathjax-newcm-font`
279
+ */
280
+ fontData?: typeof ChtmlFontData;
281
+ /**
282
+ * The URL where the fonts are found
283
+ *
284
+ * @default jsdelivr CDN links for `@mathjax/mathjax-newcm-font`
285
+ */
286
+ fontURL?: string;
287
+ /**
288
+ * location where MathJax should look for font data that has to be loaded dynamically.
289
+ *
290
+ * @default jsdelivr CDN links for `@mathjax/mathjax-newcm-font`
291
+ */
292
+ dynamicPrefix?: string;
293
+ /**
294
+ * Whether only produce CSS that is used in the processed equations
295
+ *
296
+ * @default true
297
+ */
298
+ adaptiveCSS?: boolean;
299
+ /**
300
+ * for developers only
301
+ */
302
+ wrapperFactory?: typeof ChtmlWrapperFactory;
185
303
  }
186
304
  interface MathjaxSVGOutputOptions extends MathjaxCommonOutputOptions {
187
- /**
188
- * @default "none"
189
- */
190
- fontCache?: "local" | "global" | "none";
191
- /**
192
- * ID to use for local font cache (for single equation processing)
193
- */
194
- localID?: string | null;
195
- /**
196
- * insert <title> tags with speech content
197
- *
198
- * @default true
199
- */
200
- internalSpeechTitles?: boolean;
201
- /**
202
- * initial id number to use for aria-labeledby titles
203
- */
204
- titleID?: number;
305
+ /**
306
+ * stroke-width to use for SVG character paths in units that are 1/1000 of an em
307
+ *
308
+ * @default 3
309
+ */
310
+ blacker?: number;
311
+ /**
312
+ * @see https://docs.mathjax.org/en/latest/options/output/svg.html#option-descriptions
313
+ * @default "local"
314
+ */
315
+ fontCache?: "local" | "global" | "none";
316
+ /**
317
+ * Font data to use
318
+ *
319
+ * @default font data from `@mathjax/mathjax-newcm-font`
320
+ */
321
+ fontData?: typeof SvgFontData;
322
+ /**
323
+ * Whether the xlink namespace should be included in the href attributes or not
324
+ *
325
+ * @default true
326
+ */
327
+ useXlink?: boolean;
328
+ /**
329
+ * ID to use for local font cache (for single equation processing)
330
+ */
331
+ localID?: string | null;
332
+ /**
333
+ * for developers only
334
+ */
335
+ wrapperFactory?: typeof SvgWrapperFactory;
205
336
  }
206
-
337
+ //#endregion
338
+ //#region src/options.d.ts
207
339
  type TeXTransformer = (content: string, displayMode: boolean) => string;
208
340
  interface MarkdownItMathjaxOptions extends Pick<MarkdownItTexOptions, "allowInlineWithSpace" | "delimiters" | "mathFence"> {
209
- /**
210
- * Output syntax
211
- *
212
- * 输出格式
213
- *
214
- * @default 'svg'
215
- */
216
- output?: "chtml" | "svg";
217
- /**
218
- * Enable A11y
219
- *
220
- * 是否启用无障碍
221
- *
222
- * @default true
223
- */
224
- a11y?: boolean;
225
- /**
226
- * TeX input options
227
- *
228
- * TeX 输入选项
229
- */
230
- tex?: MathJaxTexInputOptions;
231
- /**
232
- * Common HTML output options
233
- *
234
- * 通用 HTML 输出选项
235
- */
236
- chtml?: MathjaxCommonHTMLOutputOptions;
237
- /**
238
- * SVG output options
239
- *
240
- * SVG 输出选项
241
- */
242
- svg?: MathjaxSVGOutputOptions;
243
- /**
244
- * transformer on output content
245
- *
246
- * 输出内容的转换器
247
- */
248
- transformer?: TeXTransformer;
341
+ /**
342
+ * Output syntax
343
+ *
344
+ * 输出格式
345
+ *
346
+ * @default 'svg'
347
+ */
348
+ output?: "chtml" | "svg";
349
+ /**
350
+ * Enable A11y
351
+ *
352
+ * 是否启用无障碍
353
+ *
354
+ * @default true
355
+ */
356
+ a11y?: boolean;
357
+ /**
358
+ * TeX input options
359
+ *
360
+ * TeX 输入选项
361
+ */
362
+ tex?: MathJaxTexInputOptions;
363
+ /**
364
+ * Common HTML output options
365
+ *
366
+ * 通用 HTML 输出选项
367
+ */
368
+ chtml?: MathjaxCommonHTMLOutputOptions;
369
+ /**
370
+ * SVG output options
371
+ *
372
+ * SVG 输出选项
373
+ */
374
+ svg?: MathjaxSVGOutputOptions;
375
+ /**
376
+ * transformer on output content
377
+ *
378
+ * 输出内容的转换器
379
+ */
380
+ transformer?: TeXTransformer;
249
381
  }
250
-
251
- /**
252
- * Forked from https://github.com/tani/markdown-it-mathjax3/blob/master/index.ts
253
- */
254
-
382
+ //#endregion
383
+ //#region src/sync.d.ts
255
384
  interface DocumentOptions {
256
- InputJax: TeX<LiteElement, string, HTMLElement>;
257
- OutputJax: CHTML<LiteElement, string, HTMLElement> | SVG<LiteElement, string, HTMLElement>;
258
- enableAssistiveMml: boolean;
385
+ InputJax: TeX<LiteElement, string, HTMLElement>;
386
+ OutputJax: CHTML<LiteElement, string, HTMLElement> | SVG<LiteElement, string, HTMLElement>;
387
+ enableAssistiveMml: boolean;
259
388
  }
260
389
  declare const getDocumentOptions: (options: MarkdownItMathjaxOptions) => DocumentOptions;
261
390
  /**
262
391
  * Mathjax instance
263
392
  */
264
393
  interface MathjaxInstance extends Required<Pick<MarkdownItMathjaxOptions, "allowInlineWithSpace" | "delimiters" | "mathFence">> {
265
- /**
266
- * Mathjax adaptor
267
- */
268
- adaptor: LiteAdaptor;
269
- /**
270
- * Mathjax document options
271
- */
272
- documentOptions: DocumentOptions;
273
- /**
274
- * Clear style cache
275
- */
276
- clearStyle: () => void;
277
- /**
278
- * Output style for rendered content and clears it
279
- *
280
- * @returns style
281
- */
282
- outputStyle: () => string;
283
- /**
284
- * Reset tex (including labels)
285
- */
286
- reset: () => void;
287
- /**
288
- * Output content transformer
289
- */
290
- transformer: TeXTransformer | null;
394
+ /**
395
+ * Mathjax adaptor
396
+ */
397
+ adaptor: LiteAdaptor;
398
+ /**
399
+ * Mathjax document options
400
+ */
401
+ documentOptions: DocumentOptions;
402
+ /**
403
+ * Clear style cache
404
+ */
405
+ clearStyle: () => void;
406
+ /**
407
+ * Output style for rendered content and clears it
408
+ *
409
+ * @returns style
410
+ */
411
+ outputStyle: () => string;
412
+ /**
413
+ * Reset tex (including labels)
414
+ */
415
+ reset: () => void;
416
+ /**
417
+ * Output content transformer
418
+ */
419
+ transformer: TeXTransformer | null;
291
420
  }
292
421
  declare const createMathjaxInstance: (options?: MarkdownItMathjaxOptions) => MathjaxInstance | null;
293
- declare const mathjax: (md: MarkdownIt, { allowInlineWithSpace, adaptor, delimiters, documentOptions, mathFence, transformer, }: MathjaxInstance) => void;
294
-
295
- export { createMathjaxInstance, getDocumentOptions, mathjax };
296
- export type { DocumentOptions, MathjaxInstance };
422
+ declare const mathjax: (md: MarkdownIt, {
423
+ allowInlineWithSpace,
424
+ adaptor,
425
+ delimiters,
426
+ documentOptions,
427
+ mathFence,
428
+ transformer
429
+ }: MathjaxInstance) => void;
430
+ //#endregion
431
+ export { DocumentOptions, MathjaxInstance, createMathjaxInstance, getDocumentOptions, mathjax };
432
+ //# sourceMappingURL=sync.d.ts.map