@mdit/plugin-mathjax-slim 0.24.1 → 0.26.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/dist/importer-N3BdKsx_.js +1 -0
- package/dist/index.d.ts +430 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/sync.d.ts +430 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +2 -0
- package/dist/sync.js.map +1 -0
- package/package.json +25 -29
- package/lib/importer-C5KF-eLj.js +0 -2
- package/lib/importer-C5KF-eLj.js.map +0 -1
- package/lib/index.d.ts +0 -296
- package/lib/index.js +0 -2
- package/lib/index.js.map +0 -1
- package/lib/sync.d.ts +0 -296
- package/lib/sync.js +0 -2
- package/lib/sync.js.map +0 -1
package/lib/index.d.ts
DELETED
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
import { MmlNode } from '@mathjax/src/js/core/MmlTree/MmlNode.js';
|
|
2
|
-
import TexError from '@mathjax/src/js/input/tex/TexError.js';
|
|
3
|
-
import { TeX } from '@mathjax/src/js/input/tex.js';
|
|
4
|
-
import { MarkdownItTexOptions } from '@mdit/plugin-tex';
|
|
5
|
-
import { LiteElement } from '@mathjax/src/js/adaptors/lite/Element.js';
|
|
6
|
-
import { LiteAdaptor } from '@mathjax/src/js/adaptors/liteAdaptor.js';
|
|
7
|
-
import { CHTML } from '@mathjax/src/js/output/chtml.js';
|
|
8
|
-
import { SVG } from '@mathjax/src/js/output/svg.js';
|
|
9
|
-
import MarkdownIt from 'markdown-it';
|
|
10
|
-
|
|
11
|
-
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
|
-
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;
|
|
96
|
-
}
|
|
97
|
-
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
|
|
118
|
-
*
|
|
119
|
-
* @default true
|
|
120
|
-
*/
|
|
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;
|
|
134
|
-
/**
|
|
135
|
-
* font to use for character that aren’t in MathJax's fonts
|
|
136
|
-
*
|
|
137
|
-
* @default "serif"
|
|
138
|
-
*/
|
|
139
|
-
unknownFamily?: string;
|
|
140
|
-
/**
|
|
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
|
|
161
|
-
*
|
|
162
|
-
* @default 0.5
|
|
163
|
-
*/
|
|
164
|
-
exFactor?: number;
|
|
165
|
-
}
|
|
166
|
-
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;
|
|
185
|
-
}
|
|
186
|
-
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;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
type TeXTransformer = (content: string, displayMode: boolean) => string;
|
|
208
|
-
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;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Forked from https://github.com/tani/markdown-it-mathjax3/blob/master/index.ts
|
|
253
|
-
*/
|
|
254
|
-
|
|
255
|
-
interface DocumentOptions {
|
|
256
|
-
InputJax: TeX<LiteElement, string, HTMLElement>;
|
|
257
|
-
OutputJax: CHTML<LiteElement, string, HTMLElement> | SVG<LiteElement, string, HTMLElement>;
|
|
258
|
-
enableAssistiveMml: boolean;
|
|
259
|
-
}
|
|
260
|
-
declare const getDocumentOptions: (options: MarkdownItMathjaxOptions) => Promise<DocumentOptions>;
|
|
261
|
-
/**
|
|
262
|
-
* Mathjax instance
|
|
263
|
-
*/
|
|
264
|
-
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;
|
|
291
|
-
}
|
|
292
|
-
declare const createMathjaxInstance: (options?: MarkdownItMathjaxOptions) => Promise<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, MarkdownItMathjaxOptions, MathJaxTexInputOptions, MathjaxCommonHTMLOutputOptions, MathjaxCommonOutputOptions, MathjaxInstance, MathjaxSVGOutputOptions, TeXTransformer, TexPackage };
|
package/lib/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{tex as S}from"@mdit/plugin-tex";const c=["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"],v={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")},k=async(t=c)=>{await import("@mathjax/src/js/input/tex/base/BaseConfiguration.js"),await Promise.all(t.filter(e=>c.includes(e)).map(e=>v[e]()))};let h=!0,l,b,d,x,f,w,g;try{({mathjax:l}=await import("@mathjax/src/js/mathjax.js")),{TeX:b}=await import("@mathjax/src/js/input/tex.js"),{CHTML:d}=await import("@mathjax/src/js/output/chtml.js"),{SVG:x}=await import("@mathjax/src/js/output/svg.js"),{liteAdaptor:f}=await import("@mathjax/src/js/adaptors/liteAdaptor.js"),{RegisterHTMLHandler:w}=await import("@mathjax/src/js/handlers/html.js"),{AssistiveMmlHandler:g}=await import("@mathjax/src/js/a11y/assistive-mml.js")}catch{/* istanbul ignore next -- @preserve */h=!1}const y=async t=>{/* istanbul ignore if -- @preserve */if(!h)throw new Error('[@mdit/plugin-mathjax-slim] "@mathjax/src" is not installed!');return await k(t.tex?.packages),{InputJax:new b({packages:["base",...c],...t.tex}),OutputJax:t.output==="chtml"?new d({adaptiveCSS:!0,...t.chtml}):new x({fontCache:"none",...t.svg}),enableAssistiveMml:t.a11y!==!1}},I=async(t={})=>{const e=await y(t),{OutputJax:o,InputJax:n}=e,r=f(),s=w(r);t.a11y!==!1&&g(s);const a=()=>{o instanceof d&&o.clearCache()},i=()=>{n.reset()},m=()=>{const p=r.innerHTML(o.styleSheet(l.document("",e)));return a(),p};return{adaptor:r,documentOptions:e,allowInlineWithSpace:t.allowInlineWithSpace??!1,delimiters:t.delimiters??"dollars",mathFence:t.mathFence??!1,clearStyle:a,reset:i,outputStyle:m,transformer:t.transformer??null}},M=(t,{allowInlineWithSpace:e,adaptor:o,delimiters:n,documentOptions:r,mathFence:s,transformer:a})=>{t.use(S,{allowInlineWithSpace:e,delimiters:n,mathFence:s,render:(i,m)=>{const p=l.document(i,r).convert(i,{display:m}),u=o.outerHTML(p);return a?.(u,m)??u}})};export{I as createMathjaxInstance,y as getDocumentOptions,M as mathjax};
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","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: () =>\n 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: () =>\n import(\"@mathjax/src/js/input/tex/bboldx/BboldxConfiguration.js\"),\n bbox: () => import(\"@mathjax/src/js/input/tex/bbox/BboxConfiguration.js\"),\n begingroup: () =>\n import(\"@mathjax/src/js/input/tex/begingroup/BegingroupConfiguration.js\"),\n boldsymbol: () =>\n import(\"@mathjax/src/js/input/tex/boldsymbol/BoldsymbolConfiguration.js\"),\n braket: () =>\n import(\"@mathjax/src/js/input/tex/braket/BraketConfiguration.js\"),\n bussproofs: () =>\n import(\"@mathjax/src/js/input/tex/bussproofs/BussproofsConfiguration.js\"),\n cancel: () =>\n import(\"@mathjax/src/js/input/tex/cancel/CancelConfiguration.js\"),\n cases: () => import(\"@mathjax/src/js/input/tex/cases/CasesConfiguration.js\"),\n centernot: () =>\n import(\"@mathjax/src/js/input/tex/centernot/CenternotConfiguration.js\"),\n color: () => import(\"@mathjax/src/js/input/tex/color/ColorConfiguration.js\"),\n colortbl: () =>\n import(\"@mathjax/src/js/input/tex/colortbl/ColortblConfiguration.js\"),\n colorv2: () =>\n import(\"@mathjax/src/js/input/tex/colorv2/ColorV2Configuration.js\"),\n configmacros: () =>\n import(\"@mathjax/src/js/input/tex/configmacros/ConfigMacrosConfiguration.js\"),\n dsfont: () =>\n import(\"@mathjax/src/js/input/tex/dsfont/DsfontConfiguration.js\"),\n empheq: () =>\n import(\"@mathjax/src/js/input/tex/empheq/EmpheqConfiguration.js\"),\n enclose: () =>\n import(\"@mathjax/src/js/input/tex/enclose/EncloseConfiguration.js\"),\n extpfeil: () =>\n import(\"@mathjax/src/js/input/tex/extpfeil/ExtpfeilConfiguration.js\"),\n gensymb: () =>\n import(\"@mathjax/src/js/input/tex/gensymb/GensymbConfiguration.js\"),\n html: () => import(\"@mathjax/src/js/input/tex/html/HtmlConfiguration.js\"),\n mathtools: () =>\n import(\"@mathjax/src/js/input/tex/mathtools/MathtoolsConfiguration.js\"),\n mhchem: () =>\n import(\"@mathjax/src/js/input/tex/mhchem/MhchemConfiguration.js\"),\n newcommand: () =>\n import(\"@mathjax/src/js/input/tex/newcommand/NewcommandConfiguration.js\"),\n noerrors: () =>\n import(\"@mathjax/src/js/input/tex/noerrors/NoErrorsConfiguration.js\"),\n noundefined: () =>\n import(\"@mathjax/src/js/input/tex/noundefined/NoUndefinedConfiguration.js\"),\n physics: () =>\n import(\"@mathjax/src/js/input/tex/physics/PhysicsConfiguration.js\"),\n setoptions: () =>\n import(\"@mathjax/src/js/input/tex/setoptions/SetOptionsConfiguration.js\"),\n tagformat: () =>\n import(\"@mathjax/src/js/input/tex/tagformat/TagFormatConfiguration.js\"),\n texhtml: () =>\n import(\"@mathjax/src/js/input/tex/texhtml/TexHtmlConfiguration.js\"),\n textcomp: () =>\n import(\"@mathjax/src/js/input/tex/textcomp/TextcompConfiguration.js\"),\n textmacros: () =>\n import(\"@mathjax/src/js/input/tex/textmacros/TextMacrosConfiguration.js\"),\n unicode: () =>\n import(\"@mathjax/src/js/input/tex/unicode/UnicodeConfiguration.js\"),\n units: () => import(\"@mathjax/src/js/input/tex/units/UnitsConfiguration.js\"),\n upgreek: () =>\n 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 (\n packages: TexPackage[] = texPackages,\n): Promise<void> => {\n await import(\"@mathjax/src/js/input/tex/base/BaseConfiguration.js\");\n\n await Promise.all(\n packages\n .filter((pkg) => texPackages.includes(pkg))\n .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 { AssistiveMmlHandler as AssistiveMmlHandlerType } from \"@mathjax/src/js/a11y/assistive-mml.js\";\nimport type { LiteDocument } from \"@mathjax/src/js/adaptors/lite/Document.js\";\nimport type {\n LiteElement,\n LiteNode,\n} from \"@mathjax/src/js/adaptors/lite/Element.js\";\nimport type { LiteText } from \"@mathjax/src/js/adaptors/lite/Text.js\";\nimport type {\n LiteAdaptor,\n liteAdaptor as liteAdaptorType,\n} 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, TeXTransformer } from \"./options.js\";\nimport { loadTexPackages, texPackages } from \"./tex/index.js\";\n\nlet isMathJaxFullInstalled = 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;\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 } =\n await import(\"@mathjax/src/js/a11y/assistive-mml.js\"));\n} catch {\n /* istanbul ignore next -- @preserve */\n isMathJaxFullInstalled = false;\n}\n\nexport interface DocumentOptions {\n InputJax: TeXType<LiteElement, string, HTMLElement>;\n OutputJax:\n | CHTMLType<LiteElement, string, HTMLElement>\n | SVGType<LiteElement, string, HTMLElement>;\n enableAssistiveMml: boolean;\n}\n\nexport const getDocumentOptions = async (\n options: MarkdownItMathjaxOptions,\n): Promise<DocumentOptions> => {\n /* istanbul ignore if -- @preserve */\n if (!isMathJaxFullInstalled)\n throw new Error(\n '[@mdit/plugin-mathjax-slim] \"@mathjax/src\" is not installed!',\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:\n options.output === \"chtml\"\n ? new CHTML<LiteElement, string, HTMLElement>({\n adaptiveCSS: true,\n ...options.chtml,\n })\n : new SVG<LiteElement, string, HTMLElement>({\n fontCache: \"none\",\n ...options.svg,\n }),\n enableAssistiveMml: options.a11y !== false,\n };\n};\n\n/**\n * Mathjax instance\n */\nexport interface MathjaxInstance extends Required<\n Pick<\n MarkdownItMathjaxOptions,\n \"allowInlineWithSpace\" | \"delimiters\" | \"mathFence\"\n >\n> {\n /**\n * Mathjax adaptor\n */\n adaptor: LiteAdaptor;\n\n /**\n * Mathjax document options\n */\n documentOptions: DocumentOptions;\n\n /**\n * Clear style cache\n */\n clearStyle: () => void;\n\n /**\n * Output style for rendered content and clears it\n *\n * @returns style\n */\n outputStyle: () => string;\n\n /**\n * Reset tex (including labels)\n */\n reset: () => void;\n\n /**\n * Output content transformer\n */\n transformer: TeXTransformer | null;\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 const handler = RegisterHTMLHandler(adaptor);\n\n if (options.a11y !== false)\n AssistiveMmlHandler<LiteNode, LiteText, LiteDocument>(handler);\n\n const clearStyle = (): void => {\n // clear style cache\n if (OutputJax instanceof CHTML) OutputJax.clearCache();\n };\n\n const reset = (): void => {\n InputJax.reset();\n };\n\n const outputStyle = (): string => {\n const style = adaptor.innerHTML(\n OutputJax.styleSheet(\n mathjaxLib.document(\"\", documentOptions) as MathDocument<\n LiteElement,\n string,\n HTMLElement\n >,\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\n .document(content, documentOptions)\n .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"],"names":["texPackages","texLoaders","loadTexPackages","packages","pkg","isMathJaxFullInstalled","mathjaxLib","TeX","CHTML","SVG","liteAdaptor","RegisterHTMLHandler","AssistiveMmlHandler","getDocumentOptions","options","createMathjaxInstance","documentOptions","OutputJax","InputJax","adaptor","handler","clearStyle","reset","outputStyle","style","mathjax","md","allowInlineWithSpace","delimiters","mathFence","transformer","tex","content","displayMode","mathDocument","result"],"mappings":"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"}
|
package/lib/sync.d.ts
DELETED
|
@@ -1,296 +0,0 @@
|
|
|
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';
|
|
10
|
-
|
|
11
|
-
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
|
-
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;
|
|
96
|
-
}
|
|
97
|
-
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
|
|
118
|
-
*
|
|
119
|
-
* @default true
|
|
120
|
-
*/
|
|
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;
|
|
134
|
-
/**
|
|
135
|
-
* font to use for character that aren’t in MathJax's fonts
|
|
136
|
-
*
|
|
137
|
-
* @default "serif"
|
|
138
|
-
*/
|
|
139
|
-
unknownFamily?: string;
|
|
140
|
-
/**
|
|
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
|
|
161
|
-
*
|
|
162
|
-
* @default 0.5
|
|
163
|
-
*/
|
|
164
|
-
exFactor?: number;
|
|
165
|
-
}
|
|
166
|
-
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;
|
|
185
|
-
}
|
|
186
|
-
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;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
type TeXTransformer = (content: string, displayMode: boolean) => string;
|
|
208
|
-
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;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Forked from https://github.com/tani/markdown-it-mathjax3/blob/master/index.ts
|
|
253
|
-
*/
|
|
254
|
-
|
|
255
|
-
interface DocumentOptions {
|
|
256
|
-
InputJax: TeX<LiteElement, string, HTMLElement>;
|
|
257
|
-
OutputJax: CHTML<LiteElement, string, HTMLElement> | SVG<LiteElement, string, HTMLElement>;
|
|
258
|
-
enableAssistiveMml: boolean;
|
|
259
|
-
}
|
|
260
|
-
declare const getDocumentOptions: (options: MarkdownItMathjaxOptions) => DocumentOptions;
|
|
261
|
-
/**
|
|
262
|
-
* Mathjax instance
|
|
263
|
-
*/
|
|
264
|
-
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;
|
|
291
|
-
}
|
|
292
|
-
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 };
|
package/lib/sync.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{tex as y}from"@mdit/plugin-tex";const S=["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"];let d=!0,c,h,p,x,f,w,b;try{({mathjax:c}=await import("@mathjax/src/js/mathjax.js")),{TeX:h}=await import("@mathjax/src/js/input/tex.js"),{CHTML:p}=await import("@mathjax/src/js/output/chtml.js"),{SVG:x}=await import("@mathjax/src/js/output/svg.js"),{liteAdaptor:f}=await import("@mathjax/src/js/adaptors/liteAdaptor.js"),{RegisterHTMLHandler:w}=await import("@mathjax/src/js/handlers/html.js"),{AssistiveMmlHandler:b}=await import("@mathjax/src/js/a11y/assistive-mml.js"),await import("./importer-C5KF-eLj.js")}catch{/* istanbul ignore next -- @preserve */d=!1}const g=e=>{/* istanbul ignore if -- @preserve */if(!d)throw new Error('[@mdit/plugin-mathjax-slim] "@mathjax/src" is not installed!');return{InputJax:new h({packages:["base",...S],...e.tex}),OutputJax:e.output==="chtml"?new p({adaptiveCSS:!0,...e.chtml}):new x({fontCache:"none",...e.svg}),enableAssistiveMml:e.a11y!==!1}},v=(e={})=>{const t=g(e),{OutputJax:a,InputJax:i}=t,o=f(),l=w(o);e.a11y!==!1&&b(l);const n=()=>{a instanceof p&&a.clearCache()},r=()=>{i.reset()},s=()=>{const m=o.innerHTML(a.styleSheet(c.document("",t)));return n(),m};return{adaptor:o,documentOptions:t,allowInlineWithSpace:e.allowInlineWithSpace??!1,delimiters:e.delimiters??"dollars",mathFence:e.mathFence??!1,clearStyle:n,reset:r,outputStyle:s,transformer:e.transformer??null}},I=(e,{allowInlineWithSpace:t,adaptor:a,delimiters:i,documentOptions:o,mathFence:l,transformer:n})=>{e.use(y,{allowInlineWithSpace:t,delimiters:i,mathFence:l,render:(r,s)=>{const m=c.document(r,o).convert(r,{display:s}),u=a.outerHTML(m);return n?.(u,s)??u}})};export{v as createMathjaxInstance,g as getDocumentOptions,I as mathjax};
|
|
2
|
-
//# sourceMappingURL=sync.js.map
|
package/lib/sync.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sync.js","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\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 {\n LiteElement,\n LiteNode,\n} from \"@mathjax/src/js/adaptors/lite/Element.js\";\nimport type { LiteText } from \"@mathjax/src/js/adaptors/lite/Text.js\";\nimport type {\n LiteAdaptor,\n liteAdaptor as liteAdaptorType,\n} 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, TeXTransformer } from \"./options.js\";\nimport { texPackages } from \"./tex/index.js\";\n\nlet isMathJaxFullInstalled = 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;\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 } =\n await import(\"@mathjax/src/js/a11y/assistive-mml.js\"));\n await import(\"./tex/importer.js\");\n} catch {\n /* istanbul ignore next -- @preserve */\n isMathJaxFullInstalled = false;\n}\n\nexport interface DocumentOptions {\n InputJax: TeXType<LiteElement, string, HTMLElement>;\n OutputJax:\n | CHTMLType<LiteElement, string, HTMLElement>\n | SVGType<LiteElement, string, HTMLElement>;\n enableAssistiveMml: boolean;\n}\n\nexport const getDocumentOptions = (\n options: MarkdownItMathjaxOptions,\n): DocumentOptions => {\n /* istanbul ignore if -- @preserve */\n if (!isMathJaxFullInstalled)\n throw new Error(\n '[@mdit/plugin-mathjax-slim] \"@mathjax/src\" is not installed!',\n );\n\n return {\n InputJax: new TeX<LiteElement, string, HTMLElement>({\n packages: [\"base\", ...texPackages],\n ...options.tex,\n }),\n OutputJax:\n options.output === \"chtml\"\n ? new CHTML<LiteElement, string, HTMLElement>({\n adaptiveCSS: true,\n ...options.chtml,\n })\n : new SVG<LiteElement, string, HTMLElement>({\n fontCache: \"none\",\n ...options.svg,\n }),\n enableAssistiveMml: options.a11y !== false,\n };\n};\n\n/**\n * Mathjax instance\n */\nexport interface MathjaxInstance extends Required<\n Pick<\n MarkdownItMathjaxOptions,\n \"allowInlineWithSpace\" | \"delimiters\" | \"mathFence\"\n >\n> {\n /**\n * Mathjax adaptor\n */\n adaptor: LiteAdaptor;\n\n /**\n * Mathjax document options\n */\n documentOptions: DocumentOptions;\n\n /**\n * Clear style cache\n */\n clearStyle: () => void;\n\n /**\n * Output style for rendered content and clears it\n *\n * @returns style\n */\n outputStyle: () => string;\n\n /**\n * Reset tex (including labels)\n */\n reset: () => void;\n\n /**\n * Output content transformer\n */\n transformer: TeXTransformer | null;\n}\n\nexport const createMathjaxInstance = (\n options: MarkdownItMathjaxOptions = {},\n): MathjaxInstance | null => {\n const documentOptions = getDocumentOptions(options);\n\n const { OutputJax, InputJax } = documentOptions;\n\n const adaptor = liteAdaptor();\n const handler = RegisterHTMLHandler(adaptor);\n\n if (options.a11y !== false)\n AssistiveMmlHandler<LiteNode, LiteText, LiteDocument>(handler);\n\n const clearStyle = (): void => {\n // clear style cache\n if (OutputJax instanceof CHTML) OutputJax.clearCache();\n };\n\n const reset = (): void => {\n InputJax.reset();\n };\n\n const outputStyle = (): string => {\n const style = adaptor.innerHTML(\n OutputJax.styleSheet(\n mathjaxLib.document(\"\", documentOptions) as MathDocument<\n LiteElement,\n string,\n HTMLElement\n >,\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\n .document(content, documentOptions)\n .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"],"names":["texPackages","isMathJaxFullInstalled","mathjaxLib","TeX","CHTML","SVG","liteAdaptor","RegisterHTMLHandler","AssistiveMmlHandler","getDocumentOptions","options","createMathjaxInstance","documentOptions","OutputJax","InputJax","adaptor","handler","clearStyle","reset","outputStyle","style","mathjax","md","allowInlineWithSpace","delimiters","mathFence","transformer","tex","content","displayMode","mathDocument","result"],"mappings":"uCAEO,MAAMA,EAA4B,CACvC,SACA,MACA,QACA,MACA,SACA,OACA,aACA,aACA,SACA,aACA,SACA,QACA,YACA,QACA,WACA,UACA,eACA,SACA,SACA,UACA,WACA,UACA,OACA,YACA,SACA,aACA,WACA,cACA,UACA,aACA,YACA,UACA,WACA,aACA,UACA,QACA,UACA,MACF,ECdA,IAAIC,EAAyB,GACzBC,EACAC,EACAC,EACAC,EACAC,EAEAC,EACAC,EAEJ,GAAI,EACD,CAAE,QAASN,CAAW,EAAI,KAAM,QAAO,4BAA4B,GACnE,CAAE,IAAAC,CAAI,EAAI,KAAM,QAAO,8BAA8B,EACrD,CAAE,MAAAC,CAAM,EAAI,KAAM,QAAO,iCAAiC,EAC1D,CAAE,IAAAC,CAAI,EAAI,KAAM,QAAO,+BAA+B,EACtD,CAAE,YAAAC,CAAY,EAAI,KAAM,QAAO,yCAAyC,EACxE,CAAE,oBAAAC,CAAoB,EAAI,KAAM,QAAO,kCAAkC,EACzE,CAAE,oBAAAC,CAAoB,EACrB,aAAa,uCAAuC,EACtD,KAAM,QAAO,wBAAmB,CAClC,MAAQ,CAAA,uCAENP,EAAyB,EAC3B,CAUO,MAAMQ,EACXC,GACoB,CAAA,qCAEpB,GAAI,CAACT,EACH,MAAM,IAAI,MACR,8DACF,EAEF,MAAO,CACL,SAAU,IAAIE,EAAsC,CAClD,SAAU,CAAC,OAAQ,GAAGH,CAAW,EACjC,GAAGU,EAAQ,GACb,CAAC,EACD,UACEA,EAAQ,SAAW,QACf,IAAIN,EAAwC,CAC1C,YAAa,GACb,GAAGM,EAAQ,KACb,CAAC,EACD,IAAIL,EAAsC,CACxC,UAAW,OACX,GAAGK,EAAQ,GACb,CAAC,EACP,mBAAoBA,EAAQ,OAAS,EACvC,CACF,EA4CaC,EAAwB,CACnCD,EAAoC,CAAA,IACT,CAC3B,MAAME,EAAkBH,EAAmBC,CAAO,EAE5C,CAAE,UAAAG,EAAW,SAAAC,CAAS,EAAIF,EAE1BG,EAAUT,EAAAA,EACVU,EAAUT,EAAoBQ,CAAO,EAEvCL,EAAQ,OAAS,IACnBF,EAAsDQ,CAAO,EAE/D,MAAMC,EAAa,IAAY,CAEzBJ,aAAqBT,GAAOS,EAAU,YAC5C,EAEMK,EAAQ,IAAY,CACxBJ,EAAS,MAAA,CACX,EAEMK,EAAc,IAAc,CAChC,MAAMC,EAAQL,EAAQ,UACpBF,EAAU,WACRX,EAAW,SAAS,GAAIU,CAAe,CAKzC,CACF,EAEA,OAAAK,EAAAA,EAEOG,CACT,EAEA,MAAO,CACL,QAAAL,EACA,gBAAAH,EACA,qBAAsBF,EAAQ,sBAAwB,GACtD,WAAYA,EAAQ,YAAc,UAClC,UAAWA,EAAQ,WAAa,GAChC,WAAAO,EACA,MAAAC,EACA,YAAAC,EACA,YAAaT,EAAQ,aAAe,IACtC,CACF,EAEaW,EAAU,CACrBC,EACA,CACE,qBAAAC,EACA,QAAAR,EACA,WAAAS,EACA,gBAAAZ,EACA,UAAAa,EACA,YAAAC,CACF,IACS,CACTJ,EAAG,IAAIK,EAAK,CACV,qBAAAJ,EACA,WAAAC,EACA,UAAAC,EACA,OAAQ,CAACG,EAASC,IAAgB,CAChC,MAAMC,EAAe5B,EAClB,SAAS0B,EAAShB,CAAe,EACjC,QAAQgB,EAAS,CAChB,QAASC,CACX,CAAC,EAEGE,EAAShB,EAAQ,UAAUe,CAAY,EAE7C,OAAOJ,IAAcK,EAAQF,CAAW,GAAKE,CAC/C,CACF,CAAC,CACH"}
|