@mdit/plugin-mathjax-slim 0.26.2 → 1.0.1
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/dist/index.d.ts +56 -83
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{sync.d.ts → sync-node.d.ts} +56 -83
- package/dist/sync-node.js +2 -0
- package/dist/sync-node.js.map +1 -0
- package/package.json +15 -14
- package/dist/importer-jSCcpwWF.js +0 -1
- package/dist/sync.js +0 -2
- package/dist/sync.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ import MarkdownIt from "markdown-it";
|
|
|
20
20
|
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";
|
|
21
21
|
interface MathJaxTexInputOptions {
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* Extensions to use
|
|
24
24
|
*
|
|
25
25
|
* @default [
|
|
26
26
|
* 'action',
|
|
@@ -66,57 +66,49 @@ interface MathJaxTexInputOptions {
|
|
|
66
66
|
*/
|
|
67
67
|
packages?: TexPackage[];
|
|
68
68
|
/**
|
|
69
|
-
*
|
|
69
|
+
* Pattern for recognizing numbers
|
|
70
70
|
*
|
|
71
|
-
* @default /^(?:[0-9]+(?:\{,\}[0-9]{3})
|
|
71
|
+
* @default /^(?:[0-9]+(?:\{,\}[0-9]{3})_(?:\.[0-9]_)?|\.[0-9]+)/
|
|
72
72
|
*/
|
|
73
73
|
digits?: RegExp;
|
|
74
74
|
tags?: "ams" | "all" | "none";
|
|
75
|
-
/**
|
|
76
|
-
* side for `\tag` macros
|
|
77
|
-
*/
|
|
75
|
+
/** Side for `\tag` macros */
|
|
78
76
|
tagSide?: "left" | "right";
|
|
79
77
|
/**
|
|
80
|
-
*
|
|
78
|
+
* Amount to indent tags
|
|
81
79
|
*
|
|
82
80
|
* @default "0.8em"
|
|
83
81
|
*/
|
|
84
82
|
tagIndent?: "0.8em";
|
|
85
83
|
/**
|
|
86
|
-
*
|
|
84
|
+
* Use label name rather than tag for ids
|
|
87
85
|
*
|
|
88
86
|
* @default true;
|
|
89
87
|
*/
|
|
90
88
|
useLabelIds?: boolean;
|
|
91
89
|
/**
|
|
92
|
-
*
|
|
90
|
+
* Maximum number of macro substitutions per expression
|
|
93
91
|
*
|
|
94
92
|
* @default 1000
|
|
95
93
|
*/
|
|
96
94
|
maxMacros?: number;
|
|
97
95
|
/**
|
|
98
|
-
*
|
|
96
|
+
* Maximum size for the internal TeX string (in bytes)
|
|
99
97
|
*
|
|
100
98
|
* @default 5120
|
|
101
99
|
*/
|
|
102
100
|
maxBuffer?: number;
|
|
103
101
|
formatError?: (jax: TeX<unknown, unknown, unknown>, error: typeof TexError) => MmlNode;
|
|
104
102
|
}
|
|
105
|
-
/**
|
|
106
|
-
* Data passed to MathJax filters
|
|
107
|
-
*/
|
|
103
|
+
/** Data passed to MathJax filters */
|
|
108
104
|
interface MathjaxFilterData {
|
|
109
105
|
math: MathItem<LiteElement, string, HTMLElement>;
|
|
110
106
|
document: MathDocument<LiteElement, string, HTMLElement>;
|
|
111
107
|
data: any;
|
|
112
108
|
}
|
|
113
|
-
/**
|
|
114
|
-
* MathJax filter function
|
|
115
|
-
*/
|
|
109
|
+
/** MathJax filter function */
|
|
116
110
|
type MathjaxFilter = (data: MathjaxFilterData) => void;
|
|
117
|
-
/**
|
|
118
|
-
* @see https://docs.mathjax.org/en/latest/options/output/index.html#option-descriptions
|
|
119
|
-
*/
|
|
111
|
+
/** @see https://docs.mathjax.org/en/latest/options/output/index.html#option-descriptions */
|
|
120
112
|
interface MathjaxCommonOutputOptions {
|
|
121
113
|
/**
|
|
122
114
|
* Global scaling factor for all expressions
|
|
@@ -125,37 +117,37 @@ interface MathjaxCommonOutputOptions {
|
|
|
125
117
|
*/
|
|
126
118
|
scale?: number;
|
|
127
119
|
/**
|
|
128
|
-
*
|
|
120
|
+
* Smallest scaling factor to use
|
|
129
121
|
*
|
|
130
122
|
* @default 0.5
|
|
131
123
|
*/
|
|
132
124
|
minScale?: number;
|
|
133
125
|
/**
|
|
134
|
-
*
|
|
126
|
+
* Make mtext elements use surrounding font
|
|
135
127
|
*
|
|
136
128
|
* @default false
|
|
137
129
|
*/
|
|
138
130
|
mtextInheritFont?: boolean;
|
|
139
131
|
/**
|
|
140
|
-
*
|
|
132
|
+
* Make merror text use surrounding font
|
|
141
133
|
*
|
|
142
134
|
* @default true
|
|
143
135
|
*/
|
|
144
136
|
merrorInheritFont?: boolean;
|
|
145
137
|
/**
|
|
146
|
-
*
|
|
138
|
+
* Font to use for mtext, if not inheriting (empty means use MathJax fonts)
|
|
147
139
|
*
|
|
148
140
|
* @default ""
|
|
149
141
|
*/
|
|
150
142
|
mtextFont?: string;
|
|
151
143
|
/**
|
|
152
|
-
*
|
|
144
|
+
* Font to use for merror, if not inheriting (empty means use MathJax fonts)
|
|
153
145
|
*
|
|
154
146
|
* @default "serif"
|
|
155
147
|
*/
|
|
156
148
|
merrorFont?: string;
|
|
157
149
|
/**
|
|
158
|
-
*
|
|
150
|
+
* Font to use for character that aren’t in MathJax's fonts
|
|
159
151
|
*
|
|
160
152
|
* @default "serif"
|
|
161
153
|
*/
|
|
@@ -167,63 +159,56 @@ interface MathjaxCommonOutputOptions {
|
|
|
167
159
|
* @default false
|
|
168
160
|
*/
|
|
169
161
|
mathmlSpacing?: boolean;
|
|
170
|
-
/**
|
|
171
|
-
* RFDa and other attributes NOT to copy to the output
|
|
172
|
-
*/
|
|
162
|
+
/** RFDa and other attributes NOT to copy to the output */
|
|
173
163
|
skipAttributes?: Record<string, boolean>;
|
|
174
164
|
/**
|
|
175
|
-
*
|
|
165
|
+
* Default size of ex in em units
|
|
176
166
|
*
|
|
177
167
|
* @default 0.5
|
|
178
168
|
*/
|
|
179
169
|
exFactor?: number;
|
|
180
170
|
/**
|
|
181
|
-
*
|
|
171
|
+
* Default for indentalign when set to 'auto'
|
|
182
172
|
*
|
|
183
173
|
* @default "center"
|
|
184
174
|
*/
|
|
185
175
|
displayAlign?: "left" | "center" | "right";
|
|
186
176
|
/**
|
|
187
|
-
*
|
|
177
|
+
* Default for indentshift when set to 'auto'
|
|
188
178
|
*
|
|
189
179
|
* @default 0
|
|
190
180
|
*/
|
|
191
181
|
displayIndent?: string;
|
|
192
182
|
/**
|
|
193
|
-
*
|
|
183
|
+
* Default for overflow
|
|
194
184
|
*
|
|
195
185
|
* @default "overflow"
|
|
196
186
|
*/
|
|
197
187
|
displayOverflow?: "scroll" | "scale" | "truncate" | "elide" | "linebreak" | "overflow";
|
|
198
|
-
/**
|
|
199
|
-
* options for when overflow is linebreak
|
|
200
|
-
*/
|
|
188
|
+
/** Options for when overflow is linebreak */
|
|
201
189
|
linebreaks?: {
|
|
202
190
|
/**
|
|
203
|
-
*
|
|
191
|
+
* True for browser-based breaking of inline equations
|
|
204
192
|
*
|
|
205
193
|
* @default true
|
|
206
194
|
*/
|
|
207
195
|
inline?: boolean;
|
|
208
196
|
/**
|
|
209
|
-
*
|
|
197
|
+
* A fixed size or a percentage of the container width
|
|
210
198
|
*
|
|
211
199
|
* @default "100%"
|
|
212
200
|
*/
|
|
213
201
|
width?: string;
|
|
214
202
|
/**
|
|
215
|
-
*
|
|
203
|
+
* The default lineleading in em units
|
|
216
204
|
*
|
|
217
205
|
* @default 0.2
|
|
218
206
|
*/
|
|
219
|
-
lineleading?: number;
|
|
220
|
-
/**
|
|
221
|
-
* for developers only
|
|
222
|
-
*/
|
|
207
|
+
lineleading?: number; /** For developers only */
|
|
223
208
|
LinebreakVisitor?: typeof LinebreakVisitor;
|
|
224
209
|
};
|
|
225
210
|
/**
|
|
226
|
-
*
|
|
211
|
+
* The font component to load
|
|
227
212
|
*
|
|
228
213
|
* @default ""
|
|
229
214
|
*/
|
|
@@ -237,7 +222,7 @@ interface MathjaxCommonOutputOptions {
|
|
|
237
222
|
/**
|
|
238
223
|
* The font extensions to load
|
|
239
224
|
*
|
|
240
|
-
* @default []
|
|
225
|
+
* @default [ ]
|
|
241
226
|
*/
|
|
242
227
|
fontExtensions?: string[];
|
|
243
228
|
/**
|
|
@@ -249,18 +234,16 @@ interface MathjaxCommonOutputOptions {
|
|
|
249
234
|
/**
|
|
250
235
|
* A list of pre-filters to add to the output jax
|
|
251
236
|
*
|
|
252
|
-
* @default []
|
|
237
|
+
* @default [ ]
|
|
253
238
|
*/
|
|
254
239
|
preFilters?: MathjaxFilter[];
|
|
255
240
|
/**
|
|
256
241
|
* A list of post-filters to add to the output jax
|
|
257
242
|
*
|
|
258
|
-
* @default []
|
|
243
|
+
* @default [ ]
|
|
259
244
|
*/
|
|
260
245
|
postFilters?: MathjaxFilter[];
|
|
261
|
-
/**
|
|
262
|
-
* for developers only
|
|
263
|
-
*/
|
|
246
|
+
/** For developers only */
|
|
264
247
|
cssStyles?: typeof CssStyles;
|
|
265
248
|
}
|
|
266
249
|
interface MathjaxCommonHTMLOutputOptions extends MathjaxCommonOutputOptions {
|
|
@@ -283,7 +266,7 @@ interface MathjaxCommonHTMLOutputOptions extends MathjaxCommonOutputOptions {
|
|
|
283
266
|
*/
|
|
284
267
|
fontURL?: string;
|
|
285
268
|
/**
|
|
286
|
-
*
|
|
269
|
+
* Location where MathJax should look for font data that has to be loaded dynamically.
|
|
287
270
|
*
|
|
288
271
|
* @default jsdelivr CDN links for `@mathjax/mathjax-newcm-font`
|
|
289
272
|
*/
|
|
@@ -294,21 +277,19 @@ interface MathjaxCommonHTMLOutputOptions extends MathjaxCommonOutputOptions {
|
|
|
294
277
|
* @default true
|
|
295
278
|
*/
|
|
296
279
|
adaptiveCSS?: boolean;
|
|
297
|
-
/**
|
|
298
|
-
* for developers only
|
|
299
|
-
*/
|
|
280
|
+
/** For developers only */
|
|
300
281
|
wrapperFactory?: typeof ChtmlWrapperFactory;
|
|
301
282
|
}
|
|
302
283
|
interface MathjaxSVGOutputOptions extends MathjaxCommonOutputOptions {
|
|
303
284
|
/**
|
|
304
|
-
*
|
|
285
|
+
* Stroke-width to use for SVG character paths in units that are 1/1000 of an em
|
|
305
286
|
*
|
|
306
287
|
* @default 3
|
|
307
288
|
*/
|
|
308
289
|
blacker?: number;
|
|
309
290
|
/**
|
|
310
|
-
* @see https://docs.mathjax.org/en/latest/options/output/svg.html#option-descriptions
|
|
311
291
|
* @default "local"
|
|
292
|
+
* @see https://docs.mathjax.org/en/latest/options/output/svg.html#option-descriptions
|
|
312
293
|
*/
|
|
313
294
|
fontCache?: "local" | "global" | "none";
|
|
314
295
|
/**
|
|
@@ -323,13 +304,9 @@ interface MathjaxSVGOutputOptions extends MathjaxCommonOutputOptions {
|
|
|
323
304
|
* @default true
|
|
324
305
|
*/
|
|
325
306
|
useXlink?: boolean;
|
|
326
|
-
/**
|
|
327
|
-
* ID to use for local font cache (for single equation processing)
|
|
328
|
-
*/
|
|
307
|
+
/** ID to use for local font cache (for single equation processing) */
|
|
329
308
|
localID?: string | null;
|
|
330
|
-
/**
|
|
331
|
-
* for developers only
|
|
332
|
-
*/
|
|
309
|
+
/** For developers only */
|
|
333
310
|
wrapperFactory?: typeof SvgWrapperFactory;
|
|
334
311
|
}
|
|
335
312
|
//#endregion
|
|
@@ -341,7 +318,7 @@ interface MarkdownItMathjaxOptions extends Pick<MarkdownItTexOptions, "allowInli
|
|
|
341
318
|
*
|
|
342
319
|
* 输出格式
|
|
343
320
|
*
|
|
344
|
-
* @default
|
|
321
|
+
* @default "svg"
|
|
345
322
|
*/
|
|
346
323
|
output?: "chtml" | "svg";
|
|
347
324
|
/**
|
|
@@ -371,46 +348,42 @@ interface MarkdownItMathjaxOptions extends Pick<MarkdownItTexOptions, "allowInli
|
|
|
371
348
|
*/
|
|
372
349
|
svg?: MathjaxSVGOutputOptions;
|
|
373
350
|
/**
|
|
374
|
-
*
|
|
351
|
+
* Transformer on output content
|
|
375
352
|
*
|
|
376
353
|
* 输出内容的转换器
|
|
377
354
|
*/
|
|
378
355
|
transformer?: TeXTransformer;
|
|
356
|
+
/**
|
|
357
|
+
* Enable debug mode
|
|
358
|
+
*
|
|
359
|
+
* 启用调试模式
|
|
360
|
+
*
|
|
361
|
+
* @default false
|
|
362
|
+
*/
|
|
363
|
+
debug?: boolean;
|
|
379
364
|
}
|
|
380
365
|
interface DocumentOptions {
|
|
381
366
|
InputJax: TeX<LiteElement, string, HTMLElement>;
|
|
382
367
|
OutputJax: CHTML<LiteElement, string, HTMLElement> | SVG<LiteElement, string, HTMLElement>;
|
|
383
368
|
enableAssistiveMml: boolean;
|
|
384
369
|
}
|
|
385
|
-
/**
|
|
386
|
-
* Mathjax instance common options
|
|
387
|
-
*/
|
|
370
|
+
/** Mathjax instance common options */
|
|
388
371
|
interface MathjaxInstance<Sync extends boolean = false> extends Required<Pick<MarkdownItMathjaxOptions, "allowInlineWithSpace" | "delimiters" | "mathFence">> {
|
|
389
|
-
/**
|
|
390
|
-
* Mathjax adaptor
|
|
391
|
-
*/
|
|
372
|
+
/** Mathjax adaptor */
|
|
392
373
|
adaptor: LiteAdaptor;
|
|
393
|
-
/**
|
|
394
|
-
* Mathjax document options
|
|
395
|
-
*/
|
|
374
|
+
/** Mathjax document options */
|
|
396
375
|
documentOptions: DocumentOptions;
|
|
397
376
|
/**
|
|
398
377
|
* Output style for rendered content and clears it
|
|
399
378
|
*
|
|
400
|
-
* @returns
|
|
379
|
+
* @returns Style
|
|
401
380
|
*/
|
|
402
381
|
outputStyle: () => Sync extends true ? string : Promise<string>;
|
|
403
|
-
/**
|
|
404
|
-
* Reset tex (including labels)
|
|
405
|
-
*/
|
|
382
|
+
/** Reset tex (including labels) */
|
|
406
383
|
reset: () => void;
|
|
407
|
-
/**
|
|
408
|
-
* Clear style cache
|
|
409
|
-
*/
|
|
384
|
+
/** Clear style cache */
|
|
410
385
|
clearStyle: () => void;
|
|
411
|
-
/**
|
|
412
|
-
* Output content transformer
|
|
413
|
-
*/
|
|
386
|
+
/** Output content transformer */
|
|
414
387
|
transformer: TeXTransformer | null;
|
|
415
388
|
}
|
|
416
389
|
//#endregion
|
|
@@ -426,5 +399,5 @@ declare const mathjax: (md: MarkdownIt, {
|
|
|
426
399
|
transformer
|
|
427
400
|
}: MathjaxInstance) => void;
|
|
428
401
|
//#endregion
|
|
429
|
-
export { DocumentOptions, MarkdownItMathjaxOptions, MathJaxTexInputOptions, MathjaxCommonHTMLOutputOptions, MathjaxCommonOutputOptions, MathjaxFilter, MathjaxFilterData, MathjaxInstance, MathjaxSVGOutputOptions, TeXTransformer, TexPackage, createMathjaxInstance, getDocumentOptions, mathjax };
|
|
402
|
+
export { type DocumentOptions, type MarkdownItMathjaxOptions, type MathJaxTexInputOptions, type MathjaxCommonHTMLOutputOptions, type MathjaxCommonOutputOptions, type MathjaxFilter, type MathjaxFilterData, type MathjaxInstance, type MathjaxSVGOutputOptions, type TeXTransformer, type TexPackage, createMathjaxInstance, getDocumentOptions, mathjax };
|
|
430
403
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{tex as e}from"@mdit/plugin-tex";const t=`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`.split(`.`),n={action:()=>import(`@mathjax/src/js/input/tex/action/ActionConfiguration.js`),ams:()=>import(`@mathjax/src/js/input/tex/ams/AmsConfiguration.js`),amscd:()=>import(`@mathjax/src/js/input/tex/amscd/AmsCdConfiguration.js`),bbm:()=>import(`@mathjax/src/js/input/tex/bbm/BbmConfiguration.js`),bboldx:()=>import(`@mathjax/src/js/input/tex/bboldx/BboldxConfiguration.js`),bbox:()=>import(`@mathjax/src/js/input/tex/bbox/BboxConfiguration.js`),begingroup:()=>import(`@mathjax/src/js/input/tex/begingroup/BegingroupConfiguration.js`),boldsymbol:()=>import(`@mathjax/src/js/input/tex/boldsymbol/BoldsymbolConfiguration.js`),braket:()=>import(`@mathjax/src/js/input/tex/braket/BraketConfiguration.js`),bussproofs:()=>import(`@mathjax/src/js/input/tex/bussproofs/BussproofsConfiguration.js`),cancel:()=>import(`@mathjax/src/js/input/tex/cancel/CancelConfiguration.js`),cases:()=>import(`@mathjax/src/js/input/tex/cases/CasesConfiguration.js`),centernot:()=>import(`@mathjax/src/js/input/tex/centernot/CenternotConfiguration.js`),color:()=>import(`@mathjax/src/js/input/tex/color/ColorConfiguration.js`),colortbl:()=>import(`@mathjax/src/js/input/tex/colortbl/ColortblConfiguration.js`),colorv2:()=>import(`@mathjax/src/js/input/tex/colorv2/ColorV2Configuration.js`),configmacros:()=>import(`@mathjax/src/js/input/tex/configmacros/ConfigMacrosConfiguration.js`),dsfont:()=>import(`@mathjax/src/js/input/tex/dsfont/DsfontConfiguration.js`),empheq:()=>import(`@mathjax/src/js/input/tex/empheq/EmpheqConfiguration.js`),enclose:()=>import(`@mathjax/src/js/input/tex/enclose/EncloseConfiguration.js`),extpfeil:()=>import(`@mathjax/src/js/input/tex/extpfeil/ExtpfeilConfiguration.js`),gensymb:()=>import(`@mathjax/src/js/input/tex/gensymb/GensymbConfiguration.js`),html:()=>import(`@mathjax/src/js/input/tex/html/HtmlConfiguration.js`),mathtools:()=>import(`@mathjax/src/js/input/tex/mathtools/MathtoolsConfiguration.js`),mhchem:()=>import(`@mathjax/src/js/input/tex/mhchem/MhchemConfiguration.js`),newcommand:()=>import(`@mathjax/src/js/input/tex/newcommand/NewcommandConfiguration.js`),noerrors:()=>import(`@mathjax/src/js/input/tex/noerrors/NoErrorsConfiguration.js`),noundefined:()=>import(`@mathjax/src/js/input/tex/noundefined/NoUndefinedConfiguration.js`),physics:()=>import(`@mathjax/src/js/input/tex/physics/PhysicsConfiguration.js`),setoptions:()=>import(`@mathjax/src/js/input/tex/setoptions/SetOptionsConfiguration.js`),tagformat:()=>import(`@mathjax/src/js/input/tex/tagformat/TagFormatConfiguration.js`),texhtml:()=>import(`@mathjax/src/js/input/tex/texhtml/TexHtmlConfiguration.js`),textcomp:()=>import(`@mathjax/src/js/input/tex/textcomp/TextcompConfiguration.js`),textmacros:()=>import(`@mathjax/src/js/input/tex/textmacros/TextMacrosConfiguration.js`),unicode:()=>import(`@mathjax/src/js/input/tex/unicode/UnicodeConfiguration.js`),units:()=>import(`@mathjax/src/js/input/tex/units/UnitsConfiguration.js`),upgreek:()=>import(`@mathjax/src/js/input/tex/upgreek/UpgreekConfiguration.js`),verb:()=>import(`@mathjax/src/js/input/tex/verb/VerbConfiguration.js`)},r=async(e=t)=>{await import(`@mathjax/src/js/input/tex/base/BaseConfiguration.js`),await Promise.all(e.filter(e=>t.includes(e)).map(e=>n[e]()))};let i=!0,a,o,s,c,l,u,d,f=!0,p,m;try{({mathjax:a}=await import(`@mathjax/src/js/mathjax.js`)),{TeX:o}=await import(`@mathjax/src/js/input/tex.js`),{CHTML:s}=await import(`@mathjax/src/js/output/chtml.js`),{SVG:c}=await import(`@mathjax/src/js/output/svg.js`),{liteAdaptor:l}=await import(`@mathjax/src/js/adaptors/liteAdaptor.js`),{RegisterHTMLHandler:u}=await import(`@mathjax/src/js/handlers/html.js`),{AssistiveMmlHandler:d}=await import(`@mathjax/src/js/a11y/assistive-mml.js`)
|
|
1
|
+
import{tex as e}from"@mdit/plugin-tex";const t=`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`.split(`.`),n={action:()=>import(`@mathjax/src/js/input/tex/action/ActionConfiguration.js`),ams:()=>import(`@mathjax/src/js/input/tex/ams/AmsConfiguration.js`),amscd:()=>import(`@mathjax/src/js/input/tex/amscd/AmsCdConfiguration.js`),bbm:()=>import(`@mathjax/src/js/input/tex/bbm/BbmConfiguration.js`),bboldx:()=>import(`@mathjax/src/js/input/tex/bboldx/BboldxConfiguration.js`),bbox:()=>import(`@mathjax/src/js/input/tex/bbox/BboxConfiguration.js`),begingroup:()=>import(`@mathjax/src/js/input/tex/begingroup/BegingroupConfiguration.js`),boldsymbol:()=>import(`@mathjax/src/js/input/tex/boldsymbol/BoldsymbolConfiguration.js`),braket:()=>import(`@mathjax/src/js/input/tex/braket/BraketConfiguration.js`),bussproofs:()=>import(`@mathjax/src/js/input/tex/bussproofs/BussproofsConfiguration.js`),cancel:()=>import(`@mathjax/src/js/input/tex/cancel/CancelConfiguration.js`),cases:()=>import(`@mathjax/src/js/input/tex/cases/CasesConfiguration.js`),centernot:()=>import(`@mathjax/src/js/input/tex/centernot/CenternotConfiguration.js`),color:()=>import(`@mathjax/src/js/input/tex/color/ColorConfiguration.js`),colortbl:()=>import(`@mathjax/src/js/input/tex/colortbl/ColortblConfiguration.js`),colorv2:()=>import(`@mathjax/src/js/input/tex/colorv2/ColorV2Configuration.js`),configmacros:()=>import(`@mathjax/src/js/input/tex/configmacros/ConfigMacrosConfiguration.js`),dsfont:()=>import(`@mathjax/src/js/input/tex/dsfont/DsfontConfiguration.js`),empheq:()=>import(`@mathjax/src/js/input/tex/empheq/EmpheqConfiguration.js`),enclose:()=>import(`@mathjax/src/js/input/tex/enclose/EncloseConfiguration.js`),extpfeil:()=>import(`@mathjax/src/js/input/tex/extpfeil/ExtpfeilConfiguration.js`),gensymb:()=>import(`@mathjax/src/js/input/tex/gensymb/GensymbConfiguration.js`),html:()=>import(`@mathjax/src/js/input/tex/html/HtmlConfiguration.js`),mathtools:()=>import(`@mathjax/src/js/input/tex/mathtools/MathtoolsConfiguration.js`),mhchem:()=>import(`@mathjax/src/js/input/tex/mhchem/MhchemConfiguration.js`),newcommand:()=>import(`@mathjax/src/js/input/tex/newcommand/NewcommandConfiguration.js`),noerrors:()=>import(`@mathjax/src/js/input/tex/noerrors/NoErrorsConfiguration.js`),noundefined:()=>import(`@mathjax/src/js/input/tex/noundefined/NoUndefinedConfiguration.js`),physics:()=>import(`@mathjax/src/js/input/tex/physics/PhysicsConfiguration.js`),setoptions:()=>import(`@mathjax/src/js/input/tex/setoptions/SetOptionsConfiguration.js`),tagformat:()=>import(`@mathjax/src/js/input/tex/tagformat/TagFormatConfiguration.js`),texhtml:()=>import(`@mathjax/src/js/input/tex/texhtml/TexHtmlConfiguration.js`),textcomp:()=>import(`@mathjax/src/js/input/tex/textcomp/TextcompConfiguration.js`),textmacros:()=>import(`@mathjax/src/js/input/tex/textmacros/TextMacrosConfiguration.js`),unicode:()=>import(`@mathjax/src/js/input/tex/unicode/UnicodeConfiguration.js`),units:()=>import(`@mathjax/src/js/input/tex/units/UnitsConfiguration.js`),upgreek:()=>import(`@mathjax/src/js/input/tex/upgreek/UpgreekConfiguration.js`),verb:()=>import(`@mathjax/src/js/input/tex/verb/VerbConfiguration.js`)},r=async(e=t)=>{await import(`@mathjax/src/js/input/tex/base/BaseConfiguration.js`),await Promise.all(e.filter(e=>t.includes(e)).map(e=>n[e]()))};let i=!0,a,o,s,c,l,u,d,f=!0,p,m;try{({mathjax:a}=await import(`@mathjax/src/js/mathjax.js`)),{TeX:o}=await import(`@mathjax/src/js/input/tex.js`),{CHTML:s}=await import(`@mathjax/src/js/output/chtml.js`),{SVG:c}=await import(`@mathjax/src/js/output/svg.js`),{liteAdaptor:l}=await import(`@mathjax/src/js/adaptors/liteAdaptor.js`),{RegisterHTMLHandler:u}=await import(`@mathjax/src/js/handlers/html.js`),{AssistiveMmlHandler:d}=await import(`@mathjax/src/js/a11y/assistive-mml.js`)}catch{i=!1}try{p=(await import(`@mathjax/mathjax-newcm-font/js/chtml.js`)).MathJaxNewcmFont,m=(await import(`@mathjax/mathjax-newcm-font/js/svg.js`)).MathJaxNewcmFont}catch{f=!1}const h=async e=>{if(!i)throw Error(`[@mdit/plugin-mathjax-slim] "@mathjax/src" is not installed!`);let n=e.output===`chtml`,l=(n?e.chtml:e.svg)??{};if(!l.fontData&&!f)throw Error(`[@mdit/plugin-mathjax-slim] "@mathjax/mathjax-newcm-font" is not installed!`);let u=Object.assign({fontData:n?p:m},l?.fontData?{}:{dynamicPrefix:`@mathjax/mathjax-newcm-font/js/${n?`chtml`:`svg`}/dynamic`},n&&!l.fontData?{fontURL:`https://cdn.jsdelivr.net/npm/@mathjax/mathjax-newcm-font/chtml/woff2`}:{},l);return a.asyncLoad=t=>(e.debug&&console.debug(`[MathJax]: loading ${t}...`),import(t)),await r(e.tex?.packages),{InputJax:new o({packages:[`base`,...t],...e.tex}),OutputJax:new(n?s:c)(u),enableAssistiveMml:e.a11y!==!1}},g=async(e={})=>{let t=await h(e),{OutputJax:n,InputJax:r}=t,i=l(),o=u(i);e.a11y!==!1&&d(o);let s=()=>{n.adaptor!=null&&(r.reset(),n.reset())};return{adaptor:i,documentOptions:t,allowInlineWithSpace:e.allowInlineWithSpace??!1,delimiters:e.delimiters??`dollars`,mathFence:e.mathFence??!1,clearStyle:s,reset:()=>{r.reset()},outputStyle:async()=>{await n.font.loadDynamicFiles();let e=i.cssText(n.styleSheet(a.document(``,t)));return s(),e},transformer:e.transformer??null}},_=(t,{allowInlineWithSpace:n,adaptor:r,delimiters:i,documentOptions:o,mathFence:s,transformer:c})=>{t.use(e,{allowInlineWithSpace:n,delimiters:i,mathFence:s,render:(e,t)=>{let n=a.document(e,o).convert(e,{display:t}),i=r.outerHTML(n);return c?.(i,t)??i}})};export{g as createMathjaxInstance,h as getDocumentOptions,_ as mathjax};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/tex/packages.ts","../src/tex/loader.ts","../src/tex/utils.ts","../src/plugin.ts"],"sourcesContent":["import type { TexPackage } from \"../mathjax.js\";\n\nexport const texPackages: TexPackage[] = [\n \"action\",\n \"ams\",\n \"amscd\",\n \"bbm\",\n \"bboldx\",\n \"bbox\",\n \"begingroup\",\n \"boldsymbol\",\n \"braket\",\n \"bussproofs\",\n \"cancel\",\n \"cases\",\n \"centernot\",\n \"color\",\n \"colortbl\",\n \"colorv2\",\n \"configmacros\",\n \"dsfont\",\n \"empheq\",\n \"enclose\",\n \"extpfeil\",\n \"gensymb\",\n \"html\",\n \"mathtools\",\n \"mhchem\",\n \"newcommand\",\n \"noerrors\",\n \"noundefined\",\n \"physics\",\n \"setoptions\",\n \"tagformat\",\n \"texhtml\",\n \"textcomp\",\n \"textmacros\",\n \"unicode\",\n \"units\",\n \"upgreek\",\n \"verb\",\n];\n","import type { TexPackage } from \"../mathjax.js\";\n\nexport const texLoaders: Record<TexPackage, () => Promise<unknown>> = {\n action: () => import(\"@mathjax/src/js/input/tex/action/ActionConfiguration.js\"),\n ams: () => import(\"@mathjax/src/js/input/tex/ams/AmsConfiguration.js\"),\n amscd: () => import(\"@mathjax/src/js/input/tex/amscd/AmsCdConfiguration.js\"),\n bbm: () => import(\"@mathjax/src/js/input/tex/bbm/BbmConfiguration.js\"),\n bboldx: () => import(\"@mathjax/src/js/input/tex/bboldx/BboldxConfiguration.js\"),\n bbox: () => import(\"@mathjax/src/js/input/tex/bbox/BboxConfiguration.js\"),\n begingroup: () => import(\"@mathjax/src/js/input/tex/begingroup/BegingroupConfiguration.js\"),\n boldsymbol: () => import(\"@mathjax/src/js/input/tex/boldsymbol/BoldsymbolConfiguration.js\"),\n braket: () => import(\"@mathjax/src/js/input/tex/braket/BraketConfiguration.js\"),\n bussproofs: () => import(\"@mathjax/src/js/input/tex/bussproofs/BussproofsConfiguration.js\"),\n cancel: () => import(\"@mathjax/src/js/input/tex/cancel/CancelConfiguration.js\"),\n cases: () => import(\"@mathjax/src/js/input/tex/cases/CasesConfiguration.js\"),\n centernot: () => import(\"@mathjax/src/js/input/tex/centernot/CenternotConfiguration.js\"),\n color: () => import(\"@mathjax/src/js/input/tex/color/ColorConfiguration.js\"),\n colortbl: () => import(\"@mathjax/src/js/input/tex/colortbl/ColortblConfiguration.js\"),\n colorv2: () => import(\"@mathjax/src/js/input/tex/colorv2/ColorV2Configuration.js\"),\n configmacros: () => import(\"@mathjax/src/js/input/tex/configmacros/ConfigMacrosConfiguration.js\"),\n dsfont: () => import(\"@mathjax/src/js/input/tex/dsfont/DsfontConfiguration.js\"),\n empheq: () => import(\"@mathjax/src/js/input/tex/empheq/EmpheqConfiguration.js\"),\n enclose: () => import(\"@mathjax/src/js/input/tex/enclose/EncloseConfiguration.js\"),\n extpfeil: () => import(\"@mathjax/src/js/input/tex/extpfeil/ExtpfeilConfiguration.js\"),\n gensymb: () => import(\"@mathjax/src/js/input/tex/gensymb/GensymbConfiguration.js\"),\n html: () => import(\"@mathjax/src/js/input/tex/html/HtmlConfiguration.js\"),\n mathtools: () => import(\"@mathjax/src/js/input/tex/mathtools/MathtoolsConfiguration.js\"),\n mhchem: () => import(\"@mathjax/src/js/input/tex/mhchem/MhchemConfiguration.js\"),\n newcommand: () => import(\"@mathjax/src/js/input/tex/newcommand/NewcommandConfiguration.js\"),\n noerrors: () => import(\"@mathjax/src/js/input/tex/noerrors/NoErrorsConfiguration.js\"),\n noundefined: () => import(\"@mathjax/src/js/input/tex/noundefined/NoUndefinedConfiguration.js\"),\n physics: () => import(\"@mathjax/src/js/input/tex/physics/PhysicsConfiguration.js\"),\n setoptions: () => import(\"@mathjax/src/js/input/tex/setoptions/SetOptionsConfiguration.js\"),\n tagformat: () => import(\"@mathjax/src/js/input/tex/tagformat/TagFormatConfiguration.js\"),\n texhtml: () => import(\"@mathjax/src/js/input/tex/texhtml/TexHtmlConfiguration.js\"),\n textcomp: () => import(\"@mathjax/src/js/input/tex/textcomp/TextcompConfiguration.js\"),\n textmacros: () => import(\"@mathjax/src/js/input/tex/textmacros/TextMacrosConfiguration.js\"),\n unicode: () => import(\"@mathjax/src/js/input/tex/unicode/UnicodeConfiguration.js\"),\n units: () => import(\"@mathjax/src/js/input/tex/units/UnitsConfiguration.js\"),\n upgreek: () => import(\"@mathjax/src/js/input/tex/upgreek/UpgreekConfiguration.js\"),\n verb: () => import(\"@mathjax/src/js/input/tex/verb/VerbConfiguration.js\"),\n};\n","import type { TexPackage } from \"../mathjax.js\";\nimport { texLoaders } from \"./loader.js\";\nimport { texPackages } from \"./packages.js\";\n\nexport const loadTexPackages = async (packages: TexPackage[] = texPackages): Promise<void> => {\n await import(\"@mathjax/src/js/input/tex/base/BaseConfiguration.js\");\n\n await Promise.all(\n packages.filter((pkg) => texPackages.includes(pkg)).map((pkg) => texLoaders[pkg]()),\n );\n};\n","/**\n * Forked from https://github.com/tani/markdown-it-mathjax3/blob/master/index.ts\n */\n\nimport type { MathJaxNewcmFont as chtmlFontType } from \"@mathjax/mathjax-newcm-font/js/chtml.js\";\nimport type { MathJaxNewcmFont as svgFontType } from \"@mathjax/mathjax-newcm-font/js/svg.js\";\nimport type { AssistiveMmlHandler as AssistiveMmlHandlerType } from \"@mathjax/src/js/a11y/assistive-mml.js\";\nimport type { LiteDocument } from \"@mathjax/src/js/adaptors/lite/Document.js\";\nimport type { LiteElement, LiteNode } from \"@mathjax/src/js/adaptors/lite/Element.js\";\nimport type { LiteText } from \"@mathjax/src/js/adaptors/lite/Text.js\";\nimport type { liteAdaptor as liteAdaptorType } from \"@mathjax/src/js/adaptors/liteAdaptor.js\";\nimport type { MathDocument } from \"@mathjax/src/js/core/MathDocument.js\";\nimport type { RegisterHTMLHandler as RegisterHTMLHandlerType } from \"@mathjax/src/js/handlers/html.js\";\nimport type { TeX as TeXType } from \"@mathjax/src/js/input/tex.js\";\nimport type { mathjax as mathjaxType } from \"@mathjax/src/js/mathjax.js\";\nimport type { CHTML as CHTMLType } from \"@mathjax/src/js/output/chtml.js\";\nimport type { SVG as SVGType } from \"@mathjax/src/js/output/svg.js\";\nimport { tex } from \"@mdit/plugin-tex\";\nimport type MarkdownIt from \"markdown-it\";\n\nimport type { MarkdownItMathjaxOptions, DocumentOptions, MathjaxInstance } from \"./options.js\";\nimport { loadTexPackages, texPackages } from \"./tex/index.js\";\n\nlet isMathJaxInstalled = true;\nlet mathjaxLib: typeof mathjaxType;\nlet TeX: typeof TeXType;\nlet CHTML: typeof CHTMLType;\nlet SVG: typeof SVGType;\nlet liteAdaptor: typeof liteAdaptorType;\n// move type import to front\nlet RegisterHTMLHandler: typeof RegisterHTMLHandlerType;\nlet AssistiveMmlHandler: typeof AssistiveMmlHandlerType;\nlet isMathJaxNewcmFontInstalled = true;\nlet chtmlFont: typeof chtmlFontType;\nlet svgFont: typeof svgFontType;\n\ntry {\n ({ mathjax: mathjaxLib } = await import(\"@mathjax/src/js/mathjax.js\"));\n ({ TeX } = await import(\"@mathjax/src/js/input/tex.js\"));\n ({ CHTML } = await import(\"@mathjax/src/js/output/chtml.js\"));\n ({ SVG } = await import(\"@mathjax/src/js/output/svg.js\"));\n ({ liteAdaptor } = await import(\"@mathjax/src/js/adaptors/liteAdaptor.js\"));\n ({ RegisterHTMLHandler } = await import(\"@mathjax/src/js/handlers/html.js\"));\n ({ AssistiveMmlHandler } = await import(\"@mathjax/src/js/a11y/assistive-mml.js\"));\n mathjaxLib.asyncLoad = (file): Promise<unknown> => import(file);\n} catch {\n /* istanbul ignore next -- @preserve */\n isMathJaxInstalled = false;\n}\n\ntry {\n chtmlFont = (await import(\"@mathjax/mathjax-newcm-font/js/chtml.js\")).MathJaxNewcmFont;\n svgFont = (await import(\"@mathjax/mathjax-newcm-font/js/svg.js\")).MathJaxNewcmFont;\n} catch {\n /* istanbul ignore next -- @preserve */\n isMathJaxNewcmFontInstalled = false;\n}\n\nexport const getDocumentOptions = async (\n options: MarkdownItMathjaxOptions,\n): Promise<DocumentOptions> => {\n /* istanbul ignore if -- @preserve */\n if (!isMathJaxInstalled)\n throw new Error('[@mdit/plugin-mathjax-slim] \"@mathjax/src\" is not installed!');\n\n const isCHTML = options.output === \"chtml\";\n const userOptions = (isCHTML ? options.chtml : options.svg) ?? {};\n\n /* istanbul ignore if -- @preserve */\n if (!userOptions.fontData && !isMathJaxNewcmFontInstalled)\n throw new Error('[@mdit/plugin-mathjax-slim] \"@mathjax/mathjax-newcm-font\" is not installed!');\n\n const outputOptions = Object.assign(\n {\n fontData: isCHTML ? chtmlFont : svgFont,\n },\n // fontURL can be set to undefined if you want to bundle the fonts yourself\n // both fontURL and dynamicPrefix shall be synced with fontData, so set it to undefined if fontData is customized\n userOptions?.fontData\n ? {}\n : { dynamicPrefix: `@mathjax/mathjax-newcm-font/js/${isCHTML ? \"chtml\" : \"svg\"}/dynamic` },\n isCHTML && !userOptions.fontData\n ? { fontURL: \"https://cdn.jsdelivr.net/npm/@mathjax/mathjax-newcm-font/chtml/woff2\" }\n : {},\n userOptions,\n );\n\n await loadTexPackages(options.tex?.packages);\n\n return {\n InputJax: new TeX<LiteElement, string, HTMLElement>({\n packages: [\"base\", ...texPackages],\n ...options.tex,\n }),\n OutputJax: new (isCHTML ? CHTML : SVG)<LiteElement, string, HTMLElement>(outputOptions),\n enableAssistiveMml: options.a11y !== false,\n };\n};\n\nexport const createMathjaxInstance = async (\n options: MarkdownItMathjaxOptions = {},\n): Promise<MathjaxInstance | null> => {\n const documentOptions = await getDocumentOptions(options);\n\n const { OutputJax, InputJax } = documentOptions;\n\n const adaptor = liteAdaptor();\n // oxlint-disable-next-line new-cap\n const handler = RegisterHTMLHandler(adaptor);\n\n // oxlint-disable-next-line new-cap\n if (options.a11y !== false) AssistiveMmlHandler<LiteNode, LiteText, LiteDocument>(handler);\n\n const clearStyle = (): void => {\n // if there is no adaptor, output jax is not initialized yet, so nothing to clear\n if (OutputJax.adaptor == null) return;\n\n InputJax.reset();\n OutputJax.reset();\n };\n\n const reset = (): void => {\n InputJax.reset();\n };\n\n const outputStyle = async (): Promise<string> => {\n await OutputJax.font.loadDynamicFiles();\n\n const style = adaptor.cssText(\n OutputJax.styleSheet(\n mathjaxLib.document(\"\", documentOptions) as MathDocument<LiteElement, string, HTMLElement>,\n ),\n );\n\n clearStyle();\n\n return style;\n };\n\n return {\n adaptor,\n documentOptions,\n allowInlineWithSpace: options.allowInlineWithSpace ?? false,\n delimiters: options.delimiters ?? \"dollars\",\n mathFence: options.mathFence ?? false,\n clearStyle,\n reset,\n outputStyle,\n transformer: options.transformer ?? null,\n };\n};\n\nexport const mathjax = (\n md: MarkdownIt,\n {\n allowInlineWithSpace,\n adaptor,\n delimiters,\n documentOptions,\n mathFence,\n transformer,\n }: MathjaxInstance,\n): void => {\n md.use(tex, {\n allowInlineWithSpace,\n delimiters,\n mathFence,\n render: (content, displayMode) => {\n const mathDocument = mathjaxLib.document(content, documentOptions).convert(content, {\n display: displayMode,\n }) as LiteElement;\n\n const result = adaptor.outerHTML(mathDocument);\n\n return transformer?.(result, displayMode) ?? result;\n },\n });\n};\n"],"mappings":"uCAEA,MAAa,EAA4B,iUAuCxC,CCvCY,EAAyD,CACpE,WAAc,OAAO,2DACrB,QAAW,OAAO,qDAClB,UAAa,OAAO,yDACpB,QAAW,OAAO,qDAClB,WAAc,OAAO,2DACrB,SAAY,OAAO,uDACnB,eAAkB,OAAO,mEACzB,eAAkB,OAAO,mEACzB,WAAc,OAAO,2DACrB,eAAkB,OAAO,mEACzB,WAAc,OAAO,2DACrB,UAAa,OAAO,yDACpB,cAAiB,OAAO,iEACxB,UAAa,OAAO,yDACpB,aAAgB,OAAO,+DACvB,YAAe,OAAO,6DACtB,iBAAoB,OAAO,uEAC3B,WAAc,OAAO,2DACrB,WAAc,OAAO,2DACrB,YAAe,OAAO,6DACtB,aAAgB,OAAO,+DACvB,YAAe,OAAO,6DACtB,SAAY,OAAO,uDACnB,cAAiB,OAAO,iEACxB,WAAc,OAAO,2DACrB,eAA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","../src/tex/loader.ts","../src/tex/utils.ts","../src/plugin.ts"],"sourcesContent":["import type { TexPackage } from \"../mathjax.js\";\n\nexport const texPackages: TexPackage[] = [\n \"action\",\n \"ams\",\n \"amscd\",\n \"bbm\",\n \"bboldx\",\n \"bbox\",\n \"begingroup\",\n \"boldsymbol\",\n \"braket\",\n \"bussproofs\",\n \"cancel\",\n \"cases\",\n \"centernot\",\n \"color\",\n \"colortbl\",\n \"colorv2\",\n \"configmacros\",\n \"dsfont\",\n \"empheq\",\n \"enclose\",\n \"extpfeil\",\n \"gensymb\",\n \"html\",\n \"mathtools\",\n \"mhchem\",\n \"newcommand\",\n \"noerrors\",\n \"noundefined\",\n \"physics\",\n \"setoptions\",\n \"tagformat\",\n \"texhtml\",\n \"textcomp\",\n \"textmacros\",\n \"unicode\",\n \"units\",\n \"upgreek\",\n \"verb\",\n];\n","import type { TexPackage } from \"../mathjax.js\";\n\nexport const texLoaders: Record<TexPackage, () => Promise<unknown>> = {\n action: () => import(\"@mathjax/src/js/input/tex/action/ActionConfiguration.js\"),\n ams: () => import(\"@mathjax/src/js/input/tex/ams/AmsConfiguration.js\"),\n amscd: () => import(\"@mathjax/src/js/input/tex/amscd/AmsCdConfiguration.js\"),\n bbm: () => import(\"@mathjax/src/js/input/tex/bbm/BbmConfiguration.js\"),\n bboldx: () => import(\"@mathjax/src/js/input/tex/bboldx/BboldxConfiguration.js\"),\n bbox: () => import(\"@mathjax/src/js/input/tex/bbox/BboxConfiguration.js\"),\n begingroup: () => import(\"@mathjax/src/js/input/tex/begingroup/BegingroupConfiguration.js\"),\n boldsymbol: () => import(\"@mathjax/src/js/input/tex/boldsymbol/BoldsymbolConfiguration.js\"),\n braket: () => import(\"@mathjax/src/js/input/tex/braket/BraketConfiguration.js\"),\n bussproofs: () => import(\"@mathjax/src/js/input/tex/bussproofs/BussproofsConfiguration.js\"),\n cancel: () => import(\"@mathjax/src/js/input/tex/cancel/CancelConfiguration.js\"),\n cases: () => import(\"@mathjax/src/js/input/tex/cases/CasesConfiguration.js\"),\n centernot: () => import(\"@mathjax/src/js/input/tex/centernot/CenternotConfiguration.js\"),\n color: () => import(\"@mathjax/src/js/input/tex/color/ColorConfiguration.js\"),\n colortbl: () => import(\"@mathjax/src/js/input/tex/colortbl/ColortblConfiguration.js\"),\n colorv2: () => import(\"@mathjax/src/js/input/tex/colorv2/ColorV2Configuration.js\"),\n configmacros: () => import(\"@mathjax/src/js/input/tex/configmacros/ConfigMacrosConfiguration.js\"),\n dsfont: () => import(\"@mathjax/src/js/input/tex/dsfont/DsfontConfiguration.js\"),\n empheq: () => import(\"@mathjax/src/js/input/tex/empheq/EmpheqConfiguration.js\"),\n enclose: () => import(\"@mathjax/src/js/input/tex/enclose/EncloseConfiguration.js\"),\n extpfeil: () => import(\"@mathjax/src/js/input/tex/extpfeil/ExtpfeilConfiguration.js\"),\n gensymb: () => import(\"@mathjax/src/js/input/tex/gensymb/GensymbConfiguration.js\"),\n html: () => import(\"@mathjax/src/js/input/tex/html/HtmlConfiguration.js\"),\n mathtools: () => import(\"@mathjax/src/js/input/tex/mathtools/MathtoolsConfiguration.js\"),\n mhchem: () => import(\"@mathjax/src/js/input/tex/mhchem/MhchemConfiguration.js\"),\n newcommand: () => import(\"@mathjax/src/js/input/tex/newcommand/NewcommandConfiguration.js\"),\n noerrors: () => import(\"@mathjax/src/js/input/tex/noerrors/NoErrorsConfiguration.js\"),\n noundefined: () => import(\"@mathjax/src/js/input/tex/noundefined/NoUndefinedConfiguration.js\"),\n physics: () => import(\"@mathjax/src/js/input/tex/physics/PhysicsConfiguration.js\"),\n setoptions: () => import(\"@mathjax/src/js/input/tex/setoptions/SetOptionsConfiguration.js\"),\n tagformat: () => import(\"@mathjax/src/js/input/tex/tagformat/TagFormatConfiguration.js\"),\n texhtml: () => import(\"@mathjax/src/js/input/tex/texhtml/TexHtmlConfiguration.js\"),\n textcomp: () => import(\"@mathjax/src/js/input/tex/textcomp/TextcompConfiguration.js\"),\n textmacros: () => import(\"@mathjax/src/js/input/tex/textmacros/TextMacrosConfiguration.js\"),\n unicode: () => import(\"@mathjax/src/js/input/tex/unicode/UnicodeConfiguration.js\"),\n units: () => import(\"@mathjax/src/js/input/tex/units/UnitsConfiguration.js\"),\n upgreek: () => import(\"@mathjax/src/js/input/tex/upgreek/UpgreekConfiguration.js\"),\n verb: () => import(\"@mathjax/src/js/input/tex/verb/VerbConfiguration.js\"),\n};\n","import type { TexPackage } from \"../mathjax.js\";\nimport { texLoaders } from \"./loader.js\";\nimport { texPackages } from \"./packages.js\";\n\nexport const loadTexPackages = async (packages: TexPackage[] = texPackages): Promise<void> => {\n await import(\"@mathjax/src/js/input/tex/base/BaseConfiguration.js\");\n\n await Promise.all(\n packages.filter((pkg) => texPackages.includes(pkg)).map((pkg) => texLoaders[pkg]()),\n );\n};\n","/** Forked from https://github.com/tani/markdown-it-mathjax3/blob/master/index.ts */\n\nimport type { MathJaxNewcmFont as chtmlFontType } from \"@mathjax/mathjax-newcm-font/js/chtml.js\";\nimport type { MathJaxNewcmFont as svgFontType } from \"@mathjax/mathjax-newcm-font/js/svg.js\";\nimport type { AssistiveMmlHandler as AssistiveMmlHandlerType } from \"@mathjax/src/js/a11y/assistive-mml.js\";\nimport type { LiteDocument } from \"@mathjax/src/js/adaptors/lite/Document.js\";\nimport type { LiteElement, LiteNode } from \"@mathjax/src/js/adaptors/lite/Element.js\";\nimport type { LiteText } from \"@mathjax/src/js/adaptors/lite/Text.js\";\nimport type { liteAdaptor as liteAdaptorType } from \"@mathjax/src/js/adaptors/liteAdaptor.js\";\nimport type { MathDocument } from \"@mathjax/src/js/core/MathDocument.js\";\nimport type { RegisterHTMLHandler as RegisterHTMLHandlerType } from \"@mathjax/src/js/handlers/html.js\";\nimport type { TeX as TeXType } from \"@mathjax/src/js/input/tex.js\";\nimport type { mathjax as mathjaxType } from \"@mathjax/src/js/mathjax.js\";\nimport type { CHTML as CHTMLType } from \"@mathjax/src/js/output/chtml.js\";\nimport type { SVG as SVGType } from \"@mathjax/src/js/output/svg.js\";\nimport { tex } from \"@mdit/plugin-tex\";\nimport type MarkdownIt from \"markdown-it\";\n\nimport type { MarkdownItMathjaxOptions, DocumentOptions, MathjaxInstance } from \"./options.js\";\nimport { loadTexPackages, texPackages } from \"./tex/index.js\";\n\nlet isMathJaxInstalled = true;\nlet mathjaxLib: typeof mathjaxType;\nlet TeX: typeof TeXType;\nlet CHTML: typeof CHTMLType;\nlet SVG: typeof SVGType;\nlet liteAdaptor: typeof liteAdaptorType;\n// move type import to front\nlet RegisterHTMLHandler: typeof RegisterHTMLHandlerType;\nlet AssistiveMmlHandler: typeof AssistiveMmlHandlerType;\nlet isMathJaxNewcmFontInstalled = true;\nlet chtmlFont: typeof chtmlFontType;\nlet svgFont: typeof svgFontType;\n\ntry {\n ({ mathjax: mathjaxLib } = await import(\"@mathjax/src/js/mathjax.js\"));\n ({ TeX } = await import(\"@mathjax/src/js/input/tex.js\"));\n ({ CHTML } = await import(\"@mathjax/src/js/output/chtml.js\"));\n ({ SVG } = await import(\"@mathjax/src/js/output/svg.js\"));\n ({ liteAdaptor } = await import(\"@mathjax/src/js/adaptors/liteAdaptor.js\"));\n ({ RegisterHTMLHandler } = await import(\"@mathjax/src/js/handlers/html.js\"));\n ({ AssistiveMmlHandler } = await import(\"@mathjax/src/js/a11y/assistive-mml.js\"));\n} catch {\n /* istanbul ignore next -- @preserve */\n isMathJaxInstalled = false;\n}\n\ntry {\n chtmlFont = (await import(\"@mathjax/mathjax-newcm-font/js/chtml.js\")).MathJaxNewcmFont;\n svgFont = (await import(\"@mathjax/mathjax-newcm-font/js/svg.js\")).MathJaxNewcmFont;\n} catch {\n /* istanbul ignore next -- @preserve */\n isMathJaxNewcmFontInstalled = false;\n}\n\nexport const getDocumentOptions = async (\n options: MarkdownItMathjaxOptions,\n): Promise<DocumentOptions> => {\n /* istanbul ignore if -- @preserve */\n if (!isMathJaxInstalled)\n throw new Error('[@mdit/plugin-mathjax-slim] \"@mathjax/src\" is not installed!');\n\n const isCHTML = options.output === \"chtml\";\n const userOptions = (isCHTML ? options.chtml : options.svg) ?? {};\n\n /* istanbul ignore if -- @preserve */\n if (!userOptions.fontData && !isMathJaxNewcmFontInstalled)\n throw new Error('[@mdit/plugin-mathjax-slim] \"@mathjax/mathjax-newcm-font\" is not installed!');\n\n const outputOptions = Object.assign(\n {\n fontData: isCHTML ? chtmlFont : svgFont,\n },\n // fontURL can be set to undefined if you want to bundle the fonts yourself\n // both fontURL and dynamicPrefix shall be synced with fontData, so set it to undefined if fontData is customized\n userOptions?.fontData\n ? {}\n : { dynamicPrefix: `@mathjax/mathjax-newcm-font/js/${isCHTML ? \"chtml\" : \"svg\"}/dynamic` },\n isCHTML && !userOptions.fontData\n ? { fontURL: \"https://cdn.jsdelivr.net/npm/@mathjax/mathjax-newcm-font/chtml/woff2\" }\n : {},\n userOptions,\n );\n\n mathjaxLib.asyncLoad = (file): Promise<unknown> => {\n if (options.debug)\n // oxlint-disable-next-line no-console\n console.debug(`[MathJax]: loading ${file}...`);\n\n return import(file);\n };\n\n await loadTexPackages(options.tex?.packages);\n\n return {\n InputJax: new TeX<LiteElement, string, HTMLElement>({\n packages: [\"base\", ...texPackages],\n ...options.tex,\n }),\n OutputJax: new (isCHTML ? CHTML : SVG)<LiteElement, string, HTMLElement>(outputOptions),\n enableAssistiveMml: options.a11y !== false,\n };\n};\n\nexport const createMathjaxInstance = async (\n options: MarkdownItMathjaxOptions = {},\n): Promise<MathjaxInstance | null> => {\n const documentOptions = await getDocumentOptions(options);\n\n const { OutputJax, InputJax } = documentOptions;\n\n const adaptor = liteAdaptor();\n // oxlint-disable-next-line new-cap\n const handler = RegisterHTMLHandler(adaptor);\n\n // oxlint-disable-next-line new-cap\n if (options.a11y !== false) AssistiveMmlHandler<LiteNode, LiteText, LiteDocument>(handler);\n\n const clearStyle = (): void => {\n // if there is no adaptor, output jax is not initialized yet, so nothing to clear\n if (OutputJax.adaptor == null) return;\n\n InputJax.reset();\n OutputJax.reset();\n };\n\n const reset = (): void => {\n InputJax.reset();\n };\n\n const outputStyle = async (): Promise<string> => {\n await OutputJax.font.loadDynamicFiles();\n\n const style = adaptor.cssText(\n OutputJax.styleSheet(\n mathjaxLib.document(\"\", documentOptions) as MathDocument<LiteElement, string, HTMLElement>,\n ),\n );\n\n clearStyle();\n\n return style;\n };\n\n return {\n adaptor,\n documentOptions,\n allowInlineWithSpace: options.allowInlineWithSpace ?? false,\n delimiters: options.delimiters ?? \"dollars\",\n mathFence: options.mathFence ?? false,\n clearStyle,\n reset,\n outputStyle,\n transformer: options.transformer ?? null,\n };\n};\n\nexport const mathjax = (\n md: MarkdownIt,\n {\n allowInlineWithSpace,\n adaptor,\n delimiters,\n documentOptions,\n mathFence,\n transformer,\n }: MathjaxInstance,\n): void => {\n md.use(tex, {\n allowInlineWithSpace,\n delimiters,\n mathFence,\n render: (content, displayMode) => {\n const mathDocument = mathjaxLib.document(content, documentOptions).convert(content, {\n display: displayMode,\n }) as LiteElement;\n\n const result = adaptor.outerHTML(mathDocument);\n\n return transformer?.(result, displayMode) ?? result;\n },\n });\n};\n"],"mappings":"uCAEA,MAAa,EAA4B,gUAuCzC,ECvCa,EAAyD,CACpE,WAAc,OAAO,2DACrB,QAAW,OAAO,qDAClB,UAAa,OAAO,yDACpB,QAAW,OAAO,qDAClB,WAAc,OAAO,2DACrB,SAAY,OAAO,uDACnB,eAAkB,OAAO,mEACzB,eAAkB,OAAO,mEACzB,WAAc,OAAO,2DACrB,eAAkB,OAAO,mEACzB,WAAc,OAAO,2DACrB,UAAa,OAAO,yDACpB,cAAiB,OAAO,iEACxB,UAAa,OAAO,yDACpB,aAAgB,OAAO,+DACvB,YAAe,OAAO,6DACtB,iBAAoB,OAAO,uEAC3B,WAAc,OAAO,2DACrB,WAAc,OAAO,2DACrB,YAAe,OAAO,6DACtB,aAAgB,OAAO,+DACvB,YAAe,OAAO,6DACtB,SAAY,OAAO,uDACnB,cAAiB,OAAO,iEACxB,WAAc,OAAO,2DACrB,e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S,EAAQ,UAAU,CAAY,EAE7C,OAAO,IAAc,EAAQ,CAAW,GAAK,CAC/C,CACF,CAAC,CACH"}
|
|
@@ -20,7 +20,7 @@ import { CssStyles } from "@mathjax/src/js/ui/menu/mj-context-menu.js";
|
|
|
20
20
|
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";
|
|
21
21
|
interface MathJaxTexInputOptions {
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* Extensions to use
|
|
24
24
|
*
|
|
25
25
|
* @default [
|
|
26
26
|
* 'action',
|
|
@@ -66,57 +66,49 @@ interface MathJaxTexInputOptions {
|
|
|
66
66
|
*/
|
|
67
67
|
packages?: TexPackage[];
|
|
68
68
|
/**
|
|
69
|
-
*
|
|
69
|
+
* Pattern for recognizing numbers
|
|
70
70
|
*
|
|
71
|
-
* @default /^(?:[0-9]+(?:\{,\}[0-9]{3})
|
|
71
|
+
* @default /^(?:[0-9]+(?:\{,\}[0-9]{3})_(?:\.[0-9]_)?|\.[0-9]+)/
|
|
72
72
|
*/
|
|
73
73
|
digits?: RegExp;
|
|
74
74
|
tags?: "ams" | "all" | "none";
|
|
75
|
-
/**
|
|
76
|
-
* side for `\tag` macros
|
|
77
|
-
*/
|
|
75
|
+
/** Side for `\tag` macros */
|
|
78
76
|
tagSide?: "left" | "right";
|
|
79
77
|
/**
|
|
80
|
-
*
|
|
78
|
+
* Amount to indent tags
|
|
81
79
|
*
|
|
82
80
|
* @default "0.8em"
|
|
83
81
|
*/
|
|
84
82
|
tagIndent?: "0.8em";
|
|
85
83
|
/**
|
|
86
|
-
*
|
|
84
|
+
* Use label name rather than tag for ids
|
|
87
85
|
*
|
|
88
86
|
* @default true;
|
|
89
87
|
*/
|
|
90
88
|
useLabelIds?: boolean;
|
|
91
89
|
/**
|
|
92
|
-
*
|
|
90
|
+
* Maximum number of macro substitutions per expression
|
|
93
91
|
*
|
|
94
92
|
* @default 1000
|
|
95
93
|
*/
|
|
96
94
|
maxMacros?: number;
|
|
97
95
|
/**
|
|
98
|
-
*
|
|
96
|
+
* Maximum size for the internal TeX string (in bytes)
|
|
99
97
|
*
|
|
100
98
|
* @default 5120
|
|
101
99
|
*/
|
|
102
100
|
maxBuffer?: number;
|
|
103
101
|
formatError?: (jax: TeX<unknown, unknown, unknown>, error: typeof TexError) => MmlNode;
|
|
104
102
|
}
|
|
105
|
-
/**
|
|
106
|
-
* Data passed to MathJax filters
|
|
107
|
-
*/
|
|
103
|
+
/** Data passed to MathJax filters */
|
|
108
104
|
interface MathjaxFilterData {
|
|
109
105
|
math: MathItem<LiteElement, string, HTMLElement>;
|
|
110
106
|
document: MathDocument<LiteElement, string, HTMLElement>;
|
|
111
107
|
data: any;
|
|
112
108
|
}
|
|
113
|
-
/**
|
|
114
|
-
* MathJax filter function
|
|
115
|
-
*/
|
|
109
|
+
/** MathJax filter function */
|
|
116
110
|
type MathjaxFilter = (data: MathjaxFilterData) => void;
|
|
117
|
-
/**
|
|
118
|
-
* @see https://docs.mathjax.org/en/latest/options/output/index.html#option-descriptions
|
|
119
|
-
*/
|
|
111
|
+
/** @see https://docs.mathjax.org/en/latest/options/output/index.html#option-descriptions */
|
|
120
112
|
interface MathjaxCommonOutputOptions {
|
|
121
113
|
/**
|
|
122
114
|
* Global scaling factor for all expressions
|
|
@@ -125,37 +117,37 @@ interface MathjaxCommonOutputOptions {
|
|
|
125
117
|
*/
|
|
126
118
|
scale?: number;
|
|
127
119
|
/**
|
|
128
|
-
*
|
|
120
|
+
* Smallest scaling factor to use
|
|
129
121
|
*
|
|
130
122
|
* @default 0.5
|
|
131
123
|
*/
|
|
132
124
|
minScale?: number;
|
|
133
125
|
/**
|
|
134
|
-
*
|
|
126
|
+
* Make mtext elements use surrounding font
|
|
135
127
|
*
|
|
136
128
|
* @default false
|
|
137
129
|
*/
|
|
138
130
|
mtextInheritFont?: boolean;
|
|
139
131
|
/**
|
|
140
|
-
*
|
|
132
|
+
* Make merror text use surrounding font
|
|
141
133
|
*
|
|
142
134
|
* @default true
|
|
143
135
|
*/
|
|
144
136
|
merrorInheritFont?: boolean;
|
|
145
137
|
/**
|
|
146
|
-
*
|
|
138
|
+
* Font to use for mtext, if not inheriting (empty means use MathJax fonts)
|
|
147
139
|
*
|
|
148
140
|
* @default ""
|
|
149
141
|
*/
|
|
150
142
|
mtextFont?: string;
|
|
151
143
|
/**
|
|
152
|
-
*
|
|
144
|
+
* Font to use for merror, if not inheriting (empty means use MathJax fonts)
|
|
153
145
|
*
|
|
154
146
|
* @default "serif"
|
|
155
147
|
*/
|
|
156
148
|
merrorFont?: string;
|
|
157
149
|
/**
|
|
158
|
-
*
|
|
150
|
+
* Font to use for character that aren’t in MathJax's fonts
|
|
159
151
|
*
|
|
160
152
|
* @default "serif"
|
|
161
153
|
*/
|
|
@@ -167,63 +159,56 @@ interface MathjaxCommonOutputOptions {
|
|
|
167
159
|
* @default false
|
|
168
160
|
*/
|
|
169
161
|
mathmlSpacing?: boolean;
|
|
170
|
-
/**
|
|
171
|
-
* RFDa and other attributes NOT to copy to the output
|
|
172
|
-
*/
|
|
162
|
+
/** RFDa and other attributes NOT to copy to the output */
|
|
173
163
|
skipAttributes?: Record<string, boolean>;
|
|
174
164
|
/**
|
|
175
|
-
*
|
|
165
|
+
* Default size of ex in em units
|
|
176
166
|
*
|
|
177
167
|
* @default 0.5
|
|
178
168
|
*/
|
|
179
169
|
exFactor?: number;
|
|
180
170
|
/**
|
|
181
|
-
*
|
|
171
|
+
* Default for indentalign when set to 'auto'
|
|
182
172
|
*
|
|
183
173
|
* @default "center"
|
|
184
174
|
*/
|
|
185
175
|
displayAlign?: "left" | "center" | "right";
|
|
186
176
|
/**
|
|
187
|
-
*
|
|
177
|
+
* Default for indentshift when set to 'auto'
|
|
188
178
|
*
|
|
189
179
|
* @default 0
|
|
190
180
|
*/
|
|
191
181
|
displayIndent?: string;
|
|
192
182
|
/**
|
|
193
|
-
*
|
|
183
|
+
* Default for overflow
|
|
194
184
|
*
|
|
195
185
|
* @default "overflow"
|
|
196
186
|
*/
|
|
197
187
|
displayOverflow?: "scroll" | "scale" | "truncate" | "elide" | "linebreak" | "overflow";
|
|
198
|
-
/**
|
|
199
|
-
* options for when overflow is linebreak
|
|
200
|
-
*/
|
|
188
|
+
/** Options for when overflow is linebreak */
|
|
201
189
|
linebreaks?: {
|
|
202
190
|
/**
|
|
203
|
-
*
|
|
191
|
+
* True for browser-based breaking of inline equations
|
|
204
192
|
*
|
|
205
193
|
* @default true
|
|
206
194
|
*/
|
|
207
195
|
inline?: boolean;
|
|
208
196
|
/**
|
|
209
|
-
*
|
|
197
|
+
* A fixed size or a percentage of the container width
|
|
210
198
|
*
|
|
211
199
|
* @default "100%"
|
|
212
200
|
*/
|
|
213
201
|
width?: string;
|
|
214
202
|
/**
|
|
215
|
-
*
|
|
203
|
+
* The default lineleading in em units
|
|
216
204
|
*
|
|
217
205
|
* @default 0.2
|
|
218
206
|
*/
|
|
219
|
-
lineleading?: number;
|
|
220
|
-
/**
|
|
221
|
-
* for developers only
|
|
222
|
-
*/
|
|
207
|
+
lineleading?: number; /** For developers only */
|
|
223
208
|
LinebreakVisitor?: typeof LinebreakVisitor;
|
|
224
209
|
};
|
|
225
210
|
/**
|
|
226
|
-
*
|
|
211
|
+
* The font component to load
|
|
227
212
|
*
|
|
228
213
|
* @default ""
|
|
229
214
|
*/
|
|
@@ -237,7 +222,7 @@ interface MathjaxCommonOutputOptions {
|
|
|
237
222
|
/**
|
|
238
223
|
* The font extensions to load
|
|
239
224
|
*
|
|
240
|
-
* @default []
|
|
225
|
+
* @default [ ]
|
|
241
226
|
*/
|
|
242
227
|
fontExtensions?: string[];
|
|
243
228
|
/**
|
|
@@ -249,18 +234,16 @@ interface MathjaxCommonOutputOptions {
|
|
|
249
234
|
/**
|
|
250
235
|
* A list of pre-filters to add to the output jax
|
|
251
236
|
*
|
|
252
|
-
* @default []
|
|
237
|
+
* @default [ ]
|
|
253
238
|
*/
|
|
254
239
|
preFilters?: MathjaxFilter[];
|
|
255
240
|
/**
|
|
256
241
|
* A list of post-filters to add to the output jax
|
|
257
242
|
*
|
|
258
|
-
* @default []
|
|
243
|
+
* @default [ ]
|
|
259
244
|
*/
|
|
260
245
|
postFilters?: MathjaxFilter[];
|
|
261
|
-
/**
|
|
262
|
-
* for developers only
|
|
263
|
-
*/
|
|
246
|
+
/** For developers only */
|
|
264
247
|
cssStyles?: typeof CssStyles;
|
|
265
248
|
}
|
|
266
249
|
interface MathjaxCommonHTMLOutputOptions extends MathjaxCommonOutputOptions {
|
|
@@ -283,7 +266,7 @@ interface MathjaxCommonHTMLOutputOptions extends MathjaxCommonOutputOptions {
|
|
|
283
266
|
*/
|
|
284
267
|
fontURL?: string;
|
|
285
268
|
/**
|
|
286
|
-
*
|
|
269
|
+
* Location where MathJax should look for font data that has to be loaded dynamically.
|
|
287
270
|
*
|
|
288
271
|
* @default jsdelivr CDN links for `@mathjax/mathjax-newcm-font`
|
|
289
272
|
*/
|
|
@@ -294,21 +277,19 @@ interface MathjaxCommonHTMLOutputOptions extends MathjaxCommonOutputOptions {
|
|
|
294
277
|
* @default true
|
|
295
278
|
*/
|
|
296
279
|
adaptiveCSS?: boolean;
|
|
297
|
-
/**
|
|
298
|
-
* for developers only
|
|
299
|
-
*/
|
|
280
|
+
/** For developers only */
|
|
300
281
|
wrapperFactory?: typeof ChtmlWrapperFactory;
|
|
301
282
|
}
|
|
302
283
|
interface MathjaxSVGOutputOptions extends MathjaxCommonOutputOptions {
|
|
303
284
|
/**
|
|
304
|
-
*
|
|
285
|
+
* Stroke-width to use for SVG character paths in units that are 1/1000 of an em
|
|
305
286
|
*
|
|
306
287
|
* @default 3
|
|
307
288
|
*/
|
|
308
289
|
blacker?: number;
|
|
309
290
|
/**
|
|
310
|
-
* @see https://docs.mathjax.org/en/latest/options/output/svg.html#option-descriptions
|
|
311
291
|
* @default "local"
|
|
292
|
+
* @see https://docs.mathjax.org/en/latest/options/output/svg.html#option-descriptions
|
|
312
293
|
*/
|
|
313
294
|
fontCache?: "local" | "global" | "none";
|
|
314
295
|
/**
|
|
@@ -323,13 +304,9 @@ interface MathjaxSVGOutputOptions extends MathjaxCommonOutputOptions {
|
|
|
323
304
|
* @default true
|
|
324
305
|
*/
|
|
325
306
|
useXlink?: boolean;
|
|
326
|
-
/**
|
|
327
|
-
* ID to use for local font cache (for single equation processing)
|
|
328
|
-
*/
|
|
307
|
+
/** ID to use for local font cache (for single equation processing) */
|
|
329
308
|
localID?: string | null;
|
|
330
|
-
/**
|
|
331
|
-
* for developers only
|
|
332
|
-
*/
|
|
309
|
+
/** For developers only */
|
|
333
310
|
wrapperFactory?: typeof SvgWrapperFactory;
|
|
334
311
|
}
|
|
335
312
|
//#endregion
|
|
@@ -341,7 +318,7 @@ interface MarkdownItMathjaxOptions extends Pick<MarkdownItTexOptions, "allowInli
|
|
|
341
318
|
*
|
|
342
319
|
* 输出格式
|
|
343
320
|
*
|
|
344
|
-
* @default
|
|
321
|
+
* @default "svg"
|
|
345
322
|
*/
|
|
346
323
|
output?: "chtml" | "svg";
|
|
347
324
|
/**
|
|
@@ -371,46 +348,42 @@ interface MarkdownItMathjaxOptions extends Pick<MarkdownItTexOptions, "allowInli
|
|
|
371
348
|
*/
|
|
372
349
|
svg?: MathjaxSVGOutputOptions;
|
|
373
350
|
/**
|
|
374
|
-
*
|
|
351
|
+
* Transformer on output content
|
|
375
352
|
*
|
|
376
353
|
* 输出内容的转换器
|
|
377
354
|
*/
|
|
378
355
|
transformer?: TeXTransformer;
|
|
356
|
+
/**
|
|
357
|
+
* Enable debug mode
|
|
358
|
+
*
|
|
359
|
+
* 启用调试模式
|
|
360
|
+
*
|
|
361
|
+
* @default false
|
|
362
|
+
*/
|
|
363
|
+
debug?: boolean;
|
|
379
364
|
}
|
|
380
365
|
interface DocumentOptions {
|
|
381
366
|
InputJax: TeX<LiteElement, string, HTMLElement>;
|
|
382
367
|
OutputJax: CHTML<LiteElement, string, HTMLElement> | SVG<LiteElement, string, HTMLElement>;
|
|
383
368
|
enableAssistiveMml: boolean;
|
|
384
369
|
}
|
|
385
|
-
/**
|
|
386
|
-
* Mathjax instance common options
|
|
387
|
-
*/
|
|
370
|
+
/** Mathjax instance common options */
|
|
388
371
|
interface MathjaxInstance<Sync extends boolean = false> extends Required<Pick<MarkdownItMathjaxOptions, "allowInlineWithSpace" | "delimiters" | "mathFence">> {
|
|
389
|
-
/**
|
|
390
|
-
* Mathjax adaptor
|
|
391
|
-
*/
|
|
372
|
+
/** Mathjax adaptor */
|
|
392
373
|
adaptor: LiteAdaptor;
|
|
393
|
-
/**
|
|
394
|
-
* Mathjax document options
|
|
395
|
-
*/
|
|
374
|
+
/** Mathjax document options */
|
|
396
375
|
documentOptions: DocumentOptions;
|
|
397
376
|
/**
|
|
398
377
|
* Output style for rendered content and clears it
|
|
399
378
|
*
|
|
400
|
-
* @returns
|
|
379
|
+
* @returns Style
|
|
401
380
|
*/
|
|
402
381
|
outputStyle: () => Sync extends true ? string : Promise<string>;
|
|
403
|
-
/**
|
|
404
|
-
* Reset tex (including labels)
|
|
405
|
-
*/
|
|
382
|
+
/** Reset tex (including labels) */
|
|
406
383
|
reset: () => void;
|
|
407
|
-
/**
|
|
408
|
-
* Clear style cache
|
|
409
|
-
*/
|
|
384
|
+
/** Clear style cache */
|
|
410
385
|
clearStyle: () => void;
|
|
411
|
-
/**
|
|
412
|
-
* Output content transformer
|
|
413
|
-
*/
|
|
386
|
+
/** Output content transformer */
|
|
414
387
|
transformer: TeXTransformer | null;
|
|
415
388
|
}
|
|
416
389
|
//#endregion
|
|
@@ -427,4 +400,4 @@ declare const mathjax: (md: MarkdownIt, {
|
|
|
427
400
|
}: MathjaxInstance) => void;
|
|
428
401
|
//#endregion
|
|
429
402
|
export { createMathjaxInstance, getDocumentOptions, mathjax };
|
|
430
|
-
//# sourceMappingURL=sync.d.ts.map
|
|
403
|
+
//# sourceMappingURL=sync-node.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{createRequire as e}from"node:module";import{tex as t}from"@mdit/plugin-tex";const n=`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`.split(`.`);let r=!0,i,a,o,s,c,l,u,d=!0,f,p;const m=e(import.meta.url);try{({mathjax:i}=await import(`@mathjax/src/js/mathjax.js`)),[{TeX:a},{CHTML:o},{SVG:s},{liteAdaptor:c},{RegisterHTMLHandler:l},{AssistiveMmlHandler:u}]=await Promise.all([import(`@mathjax/src/js/input/tex.js`),import(`@mathjax/src/js/output/chtml.js`),import(`@mathjax/src/js/output/svg.js`),import(`@mathjax/src/js/adaptors/liteAdaptor.js`),import(`@mathjax/src/js/handlers/html.js`),import(`@mathjax/src/js/a11y/assistive-mml.js`),import(`@mathjax/src/js/input/tex/action/ActionConfiguration.js`),import(`@mathjax/src/js/input/tex/ams/AmsConfiguration.js`),import(`@mathjax/src/js/input/tex/amscd/AmsCdConfiguration.js`),import(`@mathjax/src/js/input/tex/base/BaseConfiguration.js`),import(`@mathjax/src/js/input/tex/bbm/BbmConfiguration.js`),import(`@mathjax/src/js/input/tex/bboldx/BboldxConfiguration.js`),import(`@mathjax/src/js/input/tex/bbox/BboxConfiguration.js`),import(`@mathjax/src/js/input/tex/begingroup/BegingroupConfiguration.js`),import(`@mathjax/src/js/input/tex/boldsymbol/BoldsymbolConfiguration.js`),import(`@mathjax/src/js/input/tex/braket/BraketConfiguration.js`),import(`@mathjax/src/js/input/tex/bussproofs/BussproofsConfiguration.js`),import(`@mathjax/src/js/input/tex/cancel/CancelConfiguration.js`),import(`@mathjax/src/js/input/tex/cases/CasesConfiguration.js`),import(`@mathjax/src/js/input/tex/centernot/CenternotConfiguration.js`),import(`@mathjax/src/js/input/tex/color/ColorConfiguration.js`),import(`@mathjax/src/js/input/tex/colortbl/ColortblConfiguration.js`),import(`@mathjax/src/js/input/tex/colorv2/ColorV2Configuration.js`),import(`@mathjax/src/js/input/tex/configmacros/ConfigMacrosConfiguration.js`),import(`@mathjax/src/js/input/tex/dsfont/DsfontConfiguration.js`),import(`@mathjax/src/js/input/tex/empheq/EmpheqConfiguration.js`),import(`@mathjax/src/js/input/tex/enclose/EncloseConfiguration.js`),import(`@mathjax/src/js/input/tex/extpfeil/ExtpfeilConfiguration.js`),import(`@mathjax/src/js/input/tex/gensymb/GensymbConfiguration.js`),import(`@mathjax/src/js/input/tex/html/HtmlConfiguration.js`),import(`@mathjax/src/js/input/tex/mathtools/MathtoolsConfiguration.js`),import(`@mathjax/src/js/input/tex/mhchem/MhchemConfiguration.js`),import(`@mathjax/src/js/input/tex/newcommand/NewcommandConfiguration.js`),import(`@mathjax/src/js/input/tex/noerrors/NoErrorsConfiguration.js`),import(`@mathjax/src/js/input/tex/noundefined/NoUndefinedConfiguration.js`),import(`@mathjax/src/js/input/tex/physics/PhysicsConfiguration.js`),import(`@mathjax/src/js/input/tex/setoptions/SetOptionsConfiguration.js`),import(`@mathjax/src/js/input/tex/tagformat/TagFormatConfiguration.js`),import(`@mathjax/src/js/input/tex/texhtml/TexHtmlConfiguration.js`),import(`@mathjax/src/js/input/tex/textcomp/TextcompConfiguration.js`),import(`@mathjax/src/js/input/tex/textmacros/TextMacrosConfiguration.js`),import(`@mathjax/src/js/input/tex/unicode/UnicodeConfiguration.js`),import(`@mathjax/src/js/input/tex/units/UnitsConfiguration.js`),import(`@mathjax/src/js/input/tex/upgreek/UpgreekConfiguration.js`),import(`@mathjax/src/js/input/tex/verb/VerbConfiguration.js`)]),i.asyncIsSynchronous=!0}catch{r=!1}try{f=(await import(`@mathjax/mathjax-newcm-font/js/chtml.js`)).MathJaxNewcmFont,p=(await import(`@mathjax/mathjax-newcm-font/js/svg.js`)).MathJaxNewcmFont}catch{d=!1}const h=e=>{if(!r)throw Error(`[@mdit/plugin-mathjax-slim] "@mathjax/src" is not installed!`);let t=e.output===`chtml`,c=(t?e.chtml:e.svg)??{};if(!c.fontData&&!d)throw Error(`[@mdit/plugin-mathjax-slim] "@mathjax/mathjax-newcm-font" is not installed!`);let l=Object.assign({fontData:t?f:p},c?.fontData?{}:{dynamicPrefix:`@mathjax/mathjax-newcm-font/js/${t?`chtml`:`svg`}/dynamic`},t&&!c.fontData?{fontURL:`https://cdn.jsdelivr.net/npm/@mathjax/mathjax-newcm-font/chtml/woff2`}:{},c);return i.asyncLoad=t=>{e.debug&&console.debug(`[MathJax]: sync loading ${t}...`),m(t)},{InputJax:new a({packages:[`base`,...n],...e.tex}),OutputJax:new(t?o:s)(l),enableAssistiveMml:e.a11y!==!1}},g=(e={})=>{let t=h(e),{OutputJax:n,InputJax:r}=t,a=c(),o=l(a);e.a11y!==!1&&u(o);let s=()=>{n.adaptor!=null&&(r.reset(),n.reset())};return{adaptor:a,documentOptions:t,allowInlineWithSpace:e.allowInlineWithSpace??!1,delimiters:e.delimiters??`dollars`,mathFence:e.mathFence??!1,clearStyle:s,reset:()=>{r.reset()},outputStyle:()=>{n.font.loadDynamicFilesSync();let e=a.cssText(n.styleSheet(i.document(``,t)));return s(),e},transformer:e.transformer??null}},_=(e,{allowInlineWithSpace:n,adaptor:r,delimiters:a,documentOptions:o,mathFence:s,transformer:c})=>{e.use(t,{allowInlineWithSpace:n,delimiters:a,mathFence:s,render:(e,t)=>{let n=i.document(e,o).convert(e,{display:t}),a=r.outerHTML(n);return c?.(a,t)??a}})};export{g as createMathjaxInstance,h as getDocumentOptions,_ as mathjax};
|
|
2
|
+
//# sourceMappingURL=sync-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-node.js","names":[],"sources":["../src/tex/packages.ts","../src/sync.ts"],"sourcesContent":["import type { TexPackage } from \"../mathjax.js\";\n\nexport const texPackages: TexPackage[] = [\n \"action\",\n \"ams\",\n \"amscd\",\n \"bbm\",\n \"bboldx\",\n \"bbox\",\n \"begingroup\",\n \"boldsymbol\",\n \"braket\",\n \"bussproofs\",\n \"cancel\",\n \"cases\",\n \"centernot\",\n \"color\",\n \"colortbl\",\n \"colorv2\",\n \"configmacros\",\n \"dsfont\",\n \"empheq\",\n \"enclose\",\n \"extpfeil\",\n \"gensymb\",\n \"html\",\n \"mathtools\",\n \"mhchem\",\n \"newcommand\",\n \"noerrors\",\n \"noundefined\",\n \"physics\",\n \"setoptions\",\n \"tagformat\",\n \"texhtml\",\n \"textcomp\",\n \"textmacros\",\n \"unicode\",\n \"units\",\n \"upgreek\",\n \"verb\",\n];\n","/** Forked from https://github.com/tani/markdown-it-mathjax3/blob/master/index.ts */\n// oxlint-disable-next-line import/no-nodejs-modules\nimport { createRequire } from \"node:module\";\n\nimport type { MathJaxNewcmFont as MathJaxNewcmHTMLFont } from \"@mathjax/mathjax-newcm-font/js/chtml.js\";\nimport type { MathJaxNewcmFont as MathJaxNewcmSVGFont } from \"@mathjax/mathjax-newcm-font/js/svg.js\";\nimport type { AssistiveMmlHandler as AssistiveMmlHandlerType } from \"@mathjax/src/js/a11y/assistive-mml.js\";\nimport type { LiteDocument } from \"@mathjax/src/js/adaptors/lite/Document.js\";\nimport type { LiteElement, LiteNode } from \"@mathjax/src/js/adaptors/lite/Element.js\";\nimport type { LiteText } from \"@mathjax/src/js/adaptors/lite/Text.js\";\nimport type { liteAdaptor as liteAdaptorType } from \"@mathjax/src/js/adaptors/liteAdaptor.js\";\nimport type { MathDocument } from \"@mathjax/src/js/core/MathDocument.js\";\nimport type { RegisterHTMLHandler as RegisterHTMLHandlerType } from \"@mathjax/src/js/handlers/html.js\";\nimport type { TeX as TeXType } from \"@mathjax/src/js/input/tex.js\";\nimport type { mathjax as mathjaxType } from \"@mathjax/src/js/mathjax.js\";\nimport type { CHTML as CHTMLType } from \"@mathjax/src/js/output/chtml.js\";\nimport type { SVG as SVGType } from \"@mathjax/src/js/output/svg.js\";\nimport { tex } from \"@mdit/plugin-tex\";\nimport type MarkdownIt from \"markdown-it\";\n\nimport type { MarkdownItMathjaxOptions, DocumentOptions, MathjaxInstance } from \"./options.js\";\nimport { texPackages } from \"./tex/index.js\";\n\nlet isMathJaxInstalled = true;\nlet mathjaxLib: typeof mathjaxType;\nlet TeX: typeof TeXType;\nlet CHTML: typeof CHTMLType;\nlet SVG: typeof SVGType;\nlet liteAdaptor: typeof liteAdaptorType;\nlet RegisterHTMLHandler: typeof RegisterHTMLHandlerType;\nlet AssistiveMmlHandler: typeof AssistiveMmlHandlerType;\nlet isMathJaxNewcmFontInstalled = true;\nlet chtmlFont: typeof MathJaxNewcmHTMLFont;\nlet svgFont: typeof MathJaxNewcmSVGFont;\n\nconst require = createRequire(import.meta.url);\n\ntry {\n ({ mathjax: mathjaxLib } = await import(\"@mathjax/src/js/mathjax.js\"));\n [{ TeX }, { CHTML }, { SVG }, { liteAdaptor }, { RegisterHTMLHandler }, { AssistiveMmlHandler }] =\n await Promise.all([\n import(\"@mathjax/src/js/input/tex.js\"),\n import(\"@mathjax/src/js/output/chtml.js\"),\n import(\"@mathjax/src/js/output/svg.js\"),\n import(\"@mathjax/src/js/adaptors/liteAdaptor.js\"),\n import(\"@mathjax/src/js/handlers/html.js\"),\n import(\"@mathjax/src/js/a11y/assistive-mml.js\"),\n import(\"@mathjax/src/js/input/tex/action/ActionConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/ams/AmsConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/amscd/AmsCdConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/base/BaseConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/bbm/BbmConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/bboldx/BboldxConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/bbox/BboxConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/begingroup/BegingroupConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/boldsymbol/BoldsymbolConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/braket/BraketConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/bussproofs/BussproofsConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/cancel/CancelConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/cases/CasesConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/centernot/CenternotConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/color/ColorConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/colortbl/ColortblConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/colorv2/ColorV2Configuration.js\"),\n import(\"@mathjax/src/js/input/tex/configmacros/ConfigMacrosConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/dsfont/DsfontConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/empheq/EmpheqConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/enclose/EncloseConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/extpfeil/ExtpfeilConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/gensymb/GensymbConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/html/HtmlConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/mathtools/MathtoolsConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/mhchem/MhchemConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/newcommand/NewcommandConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/noerrors/NoErrorsConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/noundefined/NoUndefinedConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/physics/PhysicsConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/setoptions/SetOptionsConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/tagformat/TagFormatConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/texhtml/TexHtmlConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/textcomp/TextcompConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/textmacros/TextMacrosConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/unicode/UnicodeConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/units/UnitsConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/upgreek/UpgreekConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/verb/VerbConfiguration.js\"),\n ]);\n\n mathjaxLib.asyncIsSynchronous = true;\n} catch {\n /* istanbul ignore next -- @preserve */\n isMathJaxInstalled = false;\n}\n\ntry {\n chtmlFont = (await import(\"@mathjax/mathjax-newcm-font/js/chtml.js\")).MathJaxNewcmFont;\n svgFont = (await import(\"@mathjax/mathjax-newcm-font/js/svg.js\")).MathJaxNewcmFont;\n} catch {\n /* istanbul ignore next -- @preserve */\n isMathJaxNewcmFontInstalled = false;\n}\nexport const getDocumentOptions = (options: MarkdownItMathjaxOptions): DocumentOptions => {\n /* istanbul ignore if -- @preserve */\n if (!isMathJaxInstalled)\n throw new Error('[@mdit/plugin-mathjax-slim] \"@mathjax/src\" is not installed!');\n\n const isCHTML = options.output === \"chtml\";\n const userOptions = (isCHTML ? options.chtml : options.svg) ?? {};\n\n /* istanbul ignore if -- @preserve */\n if (!userOptions.fontData && !isMathJaxNewcmFontInstalled)\n throw new Error('[@mdit/plugin-mathjax-slim] \"@mathjax/mathjax-newcm-font\" is not installed!');\n\n const outputOptions = Object.assign(\n {\n fontData: isCHTML ? chtmlFont : svgFont,\n },\n // fontURL can be set to undefined if you want to bundle the fonts yourself\n // both fontURL and dynamicPrefix shall be synced with fontData, so set it to undefined if fontData is customized\n userOptions?.fontData\n ? {}\n : { dynamicPrefix: `@mathjax/mathjax-newcm-font/js/${isCHTML ? \"chtml\" : \"svg\"}/dynamic` },\n isCHTML && !userOptions.fontData\n ? { fontURL: \"https://cdn.jsdelivr.net/npm/@mathjax/mathjax-newcm-font/chtml/woff2\" }\n : {},\n userOptions,\n );\n\n mathjaxLib.asyncLoad = (file): void => {\n if (options.debug)\n // oxlint-disable-next-line no-console\n console.debug(`[MathJax]: sync loading ${file}...`);\n // oxlint-disable-next-line import/no-dynamic-require\n require(file);\n };\n\n return {\n InputJax: new TeX<LiteElement, string, HTMLElement>({\n packages: [\"base\", ...texPackages],\n ...options.tex,\n }),\n OutputJax: new (isCHTML ? CHTML : SVG)<LiteElement, string, HTMLElement>(outputOptions),\n enableAssistiveMml: options.a11y !== false,\n };\n};\n\nexport const createMathjaxInstance = (\n options: MarkdownItMathjaxOptions = {},\n): MathjaxInstance<true> | null => {\n const documentOptions = getDocumentOptions(options);\n const { OutputJax, InputJax } = documentOptions;\n\n const adaptor = liteAdaptor();\n // oxlint-disable-next-line new-cap\n const handler = RegisterHTMLHandler(adaptor);\n // oxlint-disable-next-line new-cap\n if (options.a11y !== false) AssistiveMmlHandler<LiteNode, LiteText, LiteDocument>(handler);\n\n const clearStyle = (): void => {\n // if there is no adaptor, output jax is not initialized yet, so nothing to clear\n if (OutputJax.adaptor == null) return;\n\n InputJax.reset();\n OutputJax.reset();\n };\n\n const reset = (): void => {\n InputJax.reset();\n };\n\n const outputStyle = (): string => {\n OutputJax.font.loadDynamicFilesSync();\n\n const style = adaptor.cssText(\n OutputJax.styleSheet(\n mathjaxLib.document(\"\", documentOptions) as MathDocument<LiteElement, string, HTMLElement>,\n ),\n );\n\n clearStyle();\n\n return style;\n };\n\n return {\n adaptor,\n documentOptions,\n allowInlineWithSpace: options.allowInlineWithSpace ?? false,\n delimiters: options.delimiters ?? \"dollars\",\n mathFence: options.mathFence ?? false,\n clearStyle,\n reset,\n outputStyle,\n transformer: options.transformer ?? null,\n };\n};\n\nexport const mathjax = (\n md: MarkdownIt,\n {\n allowInlineWithSpace,\n adaptor,\n delimiters,\n documentOptions,\n mathFence,\n transformer,\n }: MathjaxInstance,\n): void => {\n md.use(tex, {\n allowInlineWithSpace,\n delimiters,\n mathFence,\n render: (content, displayMode) => {\n const mathDocument = mathjaxLib.document(content, documentOptions).convert(content, {\n display: displayMode,\n }) as LiteElement;\n\n const result = adaptor.outerHTML(mathDocument);\n\n return transformer?.(result, displayMode) ?? result;\n },\n });\n};\n"],"mappings":"mFAEA,MAAa,EAA4B,gUAuCzC,EClBA,IAAI,EAAqB,GACrB,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EAA8B,GAC9B,EACA,EAEJ,MAAM,EAAU,EAAc,OAAO,KAAK,GAAG,EAE7C,GAAI,EACD,CAAE,QAAS,GAAe,MAAM,OAAO,+BACxC,CAAC,QAAS,UAAW,QAAS,gBAAiB,wBAAyB,yBACtE,MAAM,QAAQ,IAAI,CAChB,OAAO,gCACP,OAAO,mCACP,OAAO,iCACP,OAAO,2CACP,OAAO,oCACP,OAAO,yCACP,OAAO,2DACP,OAAO,qDACP,OAAO,yDACP,OAAO,uDACP,OAAO,qDACP,OAAO,2DACP,OAAO,uDACP,OAAO,mEACP,OAAO,mEACP,OAAO,2DACP,OAAO,mEACP,OAAO,2DACP,OAAO,yDACP,OAAO,iEACP,OAAO,yDACP,OAAO,+DACP,OAAO,6DACP,OAAO,uEACP,OAAO,2DACP,OAAO,2DACP,OAAO,6DACP,OAAO,+DACP,OAAO,6DACP,OAAO,uDACP,OAAO,iEACP,OAAO,2DACP,OAAO,mEACP,OAAO,+DACP,OAAO,qEACP,OAAO,6DACP,OAAO,mEACP,OAAO,iEACP,OAAO,6DACP,OAAO,+DACP,OAAO,mEACP,OAAO,6DACP,OAAO,yDACP,OAAO,6DACP,OAAO,sDACT,CAAC,EAEH,EAAW,mBAAqB,EAClC,MAAQ,CAEN,EAAqB,EACvB,CAEA,GAAI,CACF,GAAa,MAAM,OAAO,2CAAA,CAA4C,iBACtE,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,IAAM,EAAQ,EAAQ,QACpB,EAAU,WACR,EAAW,SAAS,GAAI,CAAe,CACzC,CACF,EAIA,OAFA,EAAW,EAEJ,CACT,EAWE,YAAa,EAAQ,aAAe,IACtC,CACF,EAEa,GACX,EACA,CACE,uBACA,UACA,aACA,kBACA,YACA,iBAEO,CACT,EAAG,IAAI,EAAK,CACV,uBACA,aACA,YACA,QAAS,EAAS,IAAgB,CAChC,IAAM,EAAe,EAAW,SAAS,EAAS,CAAe,CAAC,CAAC,QAAQ,EAAS,CAClF,QAAS,CACX,CAAC,EAEK,EAAS,EAAQ,UAAU,CAAY,EAE7C,OAAO,IAAc,EAAQ,CAAW,GAAK,CAC/C,CACF,CAAC,CACH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdit/plugin-mathjax-slim",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "mathjax plugin for MarkdownIt",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown-it",
|
|
@@ -33,26 +33,30 @@
|
|
|
33
33
|
"default": "./dist/index.js"
|
|
34
34
|
},
|
|
35
35
|
"./sync": {
|
|
36
|
-
"types": "./dist/sync.d.ts",
|
|
37
|
-
"default": "./dist/sync.js"
|
|
36
|
+
"types": "./dist/sync-node.d.ts",
|
|
37
|
+
"default": "./dist/sync-node.js"
|
|
38
38
|
},
|
|
39
39
|
"./package.json": "./package.json"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsdown",
|
|
46
|
+
"clean": "rimraf ./dist"
|
|
47
|
+
},
|
|
44
48
|
"dependencies": {
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
49
|
+
"@mdit/plugin-tex": "1.0.1",
|
|
50
|
+
"@types/markdown-it": "^14.1.2"
|
|
47
51
|
},
|
|
48
52
|
"devDependencies": {
|
|
49
|
-
"@mathjax/mathjax-tex-font": "
|
|
50
|
-
"@mathjax/src": "4.1.
|
|
53
|
+
"@mathjax/mathjax-tex-font": "4.1.2",
|
|
54
|
+
"@mathjax/src": "4.1.2"
|
|
51
55
|
},
|
|
52
56
|
"peerDependencies": {
|
|
53
57
|
"@mathjax/mathjax-newcm-font": "^4.1.0",
|
|
54
58
|
"@mathjax/src": "^4.0.0",
|
|
55
|
-
"markdown-it": "^14.
|
|
59
|
+
"markdown-it": "^14.2.0"
|
|
56
60
|
},
|
|
57
61
|
"peerDependenciesMeta": {
|
|
58
62
|
"@mathjax/mathjax-newcm-font": {
|
|
@@ -66,10 +70,7 @@
|
|
|
66
70
|
}
|
|
67
71
|
},
|
|
68
72
|
"engines": {
|
|
69
|
-
"node": ">=
|
|
73
|
+
"node": ">=22"
|
|
70
74
|
},
|
|
71
|
-
"
|
|
72
|
-
|
|
73
|
-
"clean": "rimraf ./dist"
|
|
74
|
-
}
|
|
75
|
-
}
|
|
75
|
+
"gitHead": "c7daf5c94c0666029c39913cfaaf074dc34aa16e"
|
|
76
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"@mathjax/src/js/input/tex/action/ActionConfiguration.js";import"@mathjax/src/js/input/tex/ams/AmsConfiguration.js";import"@mathjax/src/js/input/tex/amscd/AmsCdConfiguration.js";import"@mathjax/src/js/input/tex/base/BaseConfiguration.js";import"@mathjax/src/js/input/tex/bbm/BbmConfiguration.js";import"@mathjax/src/js/input/tex/bboldx/BboldxConfiguration.js";import"@mathjax/src/js/input/tex/bbox/BboxConfiguration.js";import"@mathjax/src/js/input/tex/begingroup/BegingroupConfiguration.js";import"@mathjax/src/js/input/tex/boldsymbol/BoldsymbolConfiguration.js";import"@mathjax/src/js/input/tex/braket/BraketConfiguration.js";import"@mathjax/src/js/input/tex/bussproofs/BussproofsConfiguration.js";import"@mathjax/src/js/input/tex/cancel/CancelConfiguration.js";import"@mathjax/src/js/input/tex/cases/CasesConfiguration.js";import"@mathjax/src/js/input/tex/centernot/CenternotConfiguration.js";import"@mathjax/src/js/input/tex/color/ColorConfiguration.js";import"@mathjax/src/js/input/tex/colortbl/ColortblConfiguration.js";import"@mathjax/src/js/input/tex/colorv2/ColorV2Configuration.js";import"@mathjax/src/js/input/tex/configmacros/ConfigMacrosConfiguration.js";import"@mathjax/src/js/input/tex/dsfont/DsfontConfiguration.js";import"@mathjax/src/js/input/tex/empheq/EmpheqConfiguration.js";import"@mathjax/src/js/input/tex/enclose/EncloseConfiguration.js";import"@mathjax/src/js/input/tex/extpfeil/ExtpfeilConfiguration.js";import"@mathjax/src/js/input/tex/gensymb/GensymbConfiguration.js";import"@mathjax/src/js/input/tex/html/HtmlConfiguration.js";import"@mathjax/src/js/input/tex/mathtools/MathtoolsConfiguration.js";import"@mathjax/src/js/input/tex/mhchem/MhchemConfiguration.js";import"@mathjax/src/js/input/tex/newcommand/NewcommandConfiguration.js";import"@mathjax/src/js/input/tex/noerrors/NoErrorsConfiguration.js";import"@mathjax/src/js/input/tex/noundefined/NoUndefinedConfiguration.js";import"@mathjax/src/js/input/tex/physics/PhysicsConfiguration.js";import"@mathjax/src/js/input/tex/setoptions/SetOptionsConfiguration.js";import"@mathjax/src/js/input/tex/tagformat/TagFormatConfiguration.js";import"@mathjax/src/js/input/tex/texhtml/TexHtmlConfiguration.js";import"@mathjax/src/js/input/tex/textcomp/TextcompConfiguration.js";import"@mathjax/src/js/input/tex/textmacros/TextMacrosConfiguration.js";import"@mathjax/src/js/input/tex/unicode/UnicodeConfiguration.js";import"@mathjax/src/js/input/tex/units/UnitsConfiguration.js";import"@mathjax/src/js/input/tex/upgreek/UpgreekConfiguration.js";import"@mathjax/src/js/input/tex/verb/VerbConfiguration.js";
|
package/dist/sync.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{createRequire as e}from"node:module";import{tex as t}from"@mdit/plugin-tex";const n=`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`.split(`.`);let r=!0,i,a,o,s,c,l,u,d=!0,f,p;try{({mathjax:i}=await import(`@mathjax/src/js/mathjax.js`)),{TeX:a}=await import(`@mathjax/src/js/input/tex.js`),{CHTML:o}=await import(`@mathjax/src/js/output/chtml.js`),{SVG:s}=await import(`@mathjax/src/js/output/svg.js`),{liteAdaptor:c}=await import(`@mathjax/src/js/adaptors/liteAdaptor.js`),{RegisterHTMLHandler:l}=await import(`@mathjax/src/js/handlers/html.js`),{AssistiveMmlHandler:u}=await import(`@mathjax/src/js/a11y/assistive-mml.js`),await import(`./importer-jSCcpwWF.js`);let t=e(import.meta.url);i.asyncLoad=e=>{t(e)},i.asyncIsSynchronous=!0}catch{r=!1}try{f=(await import(`@mathjax/mathjax-newcm-font/js/chtml.js`)).MathJaxNewcmFont,p=(await import(`@mathjax/mathjax-newcm-font/js/svg.js`)).MathJaxNewcmFont}catch{d=!1}const m=e=>{if(!r)throw Error(`[@mdit/plugin-mathjax-slim] "@mathjax/src" is not installed!`);let t=e.output===`chtml`,i=(t?e.chtml:e.svg)??{};if(!i.fontData&&!d)throw Error(`[@mdit/plugin-mathjax-slim] "@mathjax/mathjax-newcm-font" is not installed!`);let c=Object.assign({fontData:t?f:p},i?.fontData?{}:{dynamicPrefix:`@mathjax/mathjax-newcm-font/js/${t?`chtml`:`svg`}/dynamic`},t&&!i.fontData?{fontURL:`https://cdn.jsdelivr.net/npm/@mathjax/mathjax-newcm-font/chtml/woff2`}:{},i);return{InputJax:new a({packages:[`base`,...n],...e.tex}),OutputJax:new(t?o:s)(c),enableAssistiveMml:e.a11y!==!1}},h=(e={})=>{let t=m(e),{OutputJax:n,InputJax:r}=t,a=c(),o=l(a);e.a11y!==!1&&u(o);let s=()=>{n.adaptor!=null&&(r.reset(),n.reset())};return{adaptor:a,documentOptions:t,allowInlineWithSpace:e.allowInlineWithSpace??!1,delimiters:e.delimiters??`dollars`,mathFence:e.mathFence??!1,clearStyle:s,reset:()=>{r.reset()},outputStyle:()=>{n.font.loadDynamicFilesSync();let e=a.cssText(n.styleSheet(i.document(``,t)));return s(),e},transformer:e.transformer??null}},g=(e,{allowInlineWithSpace:n,adaptor:r,delimiters:a,documentOptions:o,mathFence:s,transformer:c})=>{e.use(t,{allowInlineWithSpace:n,delimiters:a,mathFence:s,render:(e,t)=>{let n=i.document(e,o).convert(e,{display:t}),a=r.outerHTML(n);return c?.(a,t)??a}})};export{h as createMathjaxInstance,m as getDocumentOptions,g as mathjax};
|
|
2
|
-
//# sourceMappingURL=sync.js.map
|
package/dist/sync.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sync.js","names":[],"sources":["../src/tex/packages.ts","../src/sync.ts"],"sourcesContent":["import type { TexPackage } from \"../mathjax.js\";\n\nexport const texPackages: TexPackage[] = [\n \"action\",\n \"ams\",\n \"amscd\",\n \"bbm\",\n \"bboldx\",\n \"bbox\",\n \"begingroup\",\n \"boldsymbol\",\n \"braket\",\n \"bussproofs\",\n \"cancel\",\n \"cases\",\n \"centernot\",\n \"color\",\n \"colortbl\",\n \"colorv2\",\n \"configmacros\",\n \"dsfont\",\n \"empheq\",\n \"enclose\",\n \"extpfeil\",\n \"gensymb\",\n \"html\",\n \"mathtools\",\n \"mhchem\",\n \"newcommand\",\n \"noerrors\",\n \"noundefined\",\n \"physics\",\n \"setoptions\",\n \"tagformat\",\n \"texhtml\",\n \"textcomp\",\n \"textmacros\",\n \"unicode\",\n \"units\",\n \"upgreek\",\n \"verb\",\n];\n","/**\n * Forked from https://github.com/tani/markdown-it-mathjax3/blob/master/index.ts\n */\n// oxlint-disable-next-line import/no-nodejs-modules\nimport { createRequire } from \"node:module\";\n\nimport type { MathJaxNewcmFont as MathJaxNewcmHTMLFont } from \"@mathjax/mathjax-newcm-font/js/chtml.js\";\nimport type { MathJaxNewcmFont as MathJaxNewcmSVGFont } from \"@mathjax/mathjax-newcm-font/js/svg.js\";\nimport type { AssistiveMmlHandler as AssistiveMmlHandlerType } from \"@mathjax/src/js/a11y/assistive-mml.js\";\nimport type { LiteDocument } from \"@mathjax/src/js/adaptors/lite/Document.js\";\nimport type { LiteElement, LiteNode } from \"@mathjax/src/js/adaptors/lite/Element.js\";\nimport type { LiteText } from \"@mathjax/src/js/adaptors/lite/Text.js\";\nimport type { liteAdaptor as liteAdaptorType } from \"@mathjax/src/js/adaptors/liteAdaptor.js\";\nimport type { MathDocument } from \"@mathjax/src/js/core/MathDocument.js\";\nimport type { RegisterHTMLHandler as RegisterHTMLHandlerType } from \"@mathjax/src/js/handlers/html.js\";\nimport type { TeX as TeXType } from \"@mathjax/src/js/input/tex.js\";\nimport type { mathjax as mathjaxType } from \"@mathjax/src/js/mathjax.js\";\nimport type { CHTML as CHTMLType } from \"@mathjax/src/js/output/chtml.js\";\nimport type { SVG as SVGType } from \"@mathjax/src/js/output/svg.js\";\nimport { tex } from \"@mdit/plugin-tex\";\nimport type MarkdownIt from \"markdown-it\";\n\nimport type { MarkdownItMathjaxOptions, DocumentOptions, MathjaxInstance } from \"./options.js\";\nimport { texPackages } from \"./tex/index.js\";\n\nlet isMathJaxInstalled = true;\nlet mathjaxLib: typeof mathjaxType;\nlet TeX: typeof TeXType;\nlet CHTML: typeof CHTMLType;\nlet SVG: typeof SVGType;\nlet liteAdaptor: typeof liteAdaptorType;\nlet RegisterHTMLHandler: typeof RegisterHTMLHandlerType;\nlet AssistiveMmlHandler: typeof AssistiveMmlHandlerType;\nlet isMathJaxNewcmFontInstalled = true;\nlet chtmlFont: typeof MathJaxNewcmHTMLFont;\nlet svgFont: typeof MathJaxNewcmSVGFont;\n\ntry {\n ({ mathjax: mathjaxLib } = await import(\"@mathjax/src/js/mathjax.js\"));\n ({ TeX } = await import(\"@mathjax/src/js/input/tex.js\"));\n ({ CHTML } = await import(\"@mathjax/src/js/output/chtml.js\"));\n ({ SVG } = await import(\"@mathjax/src/js/output/svg.js\"));\n ({ liteAdaptor } = await import(\"@mathjax/src/js/adaptors/liteAdaptor.js\"));\n ({ RegisterHTMLHandler } = await import(\"@mathjax/src/js/handlers/html.js\"));\n ({ AssistiveMmlHandler } = await import(\"@mathjax/src/js/a11y/assistive-mml.js\"));\n await import(\"./importer.js\");\n\n const require = createRequire(import.meta.url);\n\n mathjaxLib.asyncLoad = (file): void => {\n // oxlint-disable-next-line import/no-dynamic-require\n require(file);\n };\n mathjaxLib.asyncIsSynchronous = true;\n} catch {\n /* istanbul ignore next -- @preserve */\n isMathJaxInstalled = false;\n}\n\ntry {\n chtmlFont = (await import(\"@mathjax/mathjax-newcm-font/js/chtml.js\")).MathJaxNewcmFont;\n svgFont = (await import(\"@mathjax/mathjax-newcm-font/js/svg.js\")).MathJaxNewcmFont;\n} catch {\n /* istanbul ignore next -- @preserve */\n isMathJaxNewcmFontInstalled = false;\n}\nexport const getDocumentOptions = (options: MarkdownItMathjaxOptions): DocumentOptions => {\n /* istanbul ignore if -- @preserve */\n if (!isMathJaxInstalled)\n throw new Error('[@mdit/plugin-mathjax-slim] \"@mathjax/src\" is not installed!');\n\n const isCHTML = options.output === \"chtml\";\n const userOptions = (isCHTML ? options.chtml : options.svg) ?? {};\n\n /* istanbul ignore if -- @preserve */\n if (!userOptions.fontData && !isMathJaxNewcmFontInstalled)\n throw new Error('[@mdit/plugin-mathjax-slim] \"@mathjax/mathjax-newcm-font\" is not installed!');\n\n const outputOptions = Object.assign(\n {\n fontData: isCHTML ? chtmlFont : svgFont,\n },\n // fontURL can be set to undefined if you want to bundle the fonts yourself\n // both fontURL and dynamicPrefix shall be synced with fontData, so set it to undefined if fontData is customized\n userOptions?.fontData\n ? {}\n : { dynamicPrefix: `@mathjax/mathjax-newcm-font/js/${isCHTML ? \"chtml\" : \"svg\"}/dynamic` },\n isCHTML && !userOptions.fontData\n ? { fontURL: \"https://cdn.jsdelivr.net/npm/@mathjax/mathjax-newcm-font/chtml/woff2\" }\n : {},\n userOptions,\n );\n\n return {\n InputJax: new TeX<LiteElement, string, HTMLElement>({\n packages: [\"base\", ...texPackages],\n ...options.tex,\n }),\n OutputJax: new (isCHTML ? CHTML : SVG)<LiteElement, string, HTMLElement>(outputOptions),\n enableAssistiveMml: options.a11y !== false,\n };\n};\n\nexport const createMathjaxInstance = (\n options: MarkdownItMathjaxOptions = {},\n): MathjaxInstance<true> | null => {\n const documentOptions = getDocumentOptions(options);\n const { OutputJax, InputJax } = documentOptions;\n\n const adaptor = liteAdaptor();\n // oxlint-disable-next-line new-cap\n const handler = RegisterHTMLHandler(adaptor);\n // oxlint-disable-next-line new-cap\n if (options.a11y !== false) AssistiveMmlHandler<LiteNode, LiteText, LiteDocument>(handler);\n\n const clearStyle = (): void => {\n // if there is no adaptor, output jax is not initialized yet, so nothing to clear\n if (OutputJax.adaptor == null) return;\n\n InputJax.reset();\n OutputJax.reset();\n };\n\n const reset = (): void => {\n InputJax.reset();\n };\n\n const outputStyle = (): string => {\n OutputJax.font.loadDynamicFilesSync();\n\n const style = adaptor.cssText(\n OutputJax.styleSheet(\n mathjaxLib.document(\"\", documentOptions) as MathDocument<LiteElement, string, HTMLElement>,\n ),\n );\n\n clearStyle();\n\n return style;\n };\n\n return {\n adaptor,\n documentOptions,\n allowInlineWithSpace: options.allowInlineWithSpace ?? false,\n delimiters: options.delimiters ?? \"dollars\",\n mathFence: options.mathFence ?? false,\n clearStyle,\n reset,\n outputStyle,\n transformer: options.transformer ?? null,\n };\n};\n\nexport const mathjax = (\n md: MarkdownIt,\n {\n allowInlineWithSpace,\n adaptor,\n delimiters,\n documentOptions,\n mathFence,\n transformer,\n }: MathjaxInstance,\n): void => {\n md.use(tex, {\n allowInlineWithSpace,\n delimiters,\n mathFence,\n render: (content, displayMode) => {\n const mathDocument = mathjaxLib.document(content, documentOptions).convert(content, {\n display: displayMode,\n }) as LiteElement;\n\n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