@mdit/plugin-mathjax-slim 0.22.0 → 0.23.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/lib/index.d.ts CHANGED
@@ -194,7 +194,7 @@ interface MathjaxSVGOutputOptions extends MathjaxCommonOutputOptions {
194
194
  }
195
195
 
196
196
  type TeXTransformer = (content: string, displayMode: boolean) => string;
197
- interface MarkdownItMathjaxOptions extends Pick<MarkdownItTexOptions, "allowInlineWithSpace" | "mathFence"> {
197
+ interface MarkdownItMathjaxOptions extends Pick<MarkdownItTexOptions, "allowInlineWithSpace" | "delimiters" | "mathFence"> {
198
198
  /**
199
199
  * Output syntax
200
200
  *
@@ -237,10 +237,6 @@ interface MarkdownItMathjaxOptions extends Pick<MarkdownItTexOptions, "allowInli
237
237
  transformer?: TeXTransformer;
238
238
  }
239
239
 
240
- /**
241
- * Forked from https://github.com/tani/markdown-it-mathjax3/blob/master/index.ts
242
- */
243
-
244
240
  interface DocumentOptions {
245
241
  InputJax: TeX<LiteElement, string, HTMLElement>;
246
242
  OutputJax: CHTML<LiteElement, string, HTMLElement> | SVG<LiteElement, string, HTMLElement>;
@@ -250,7 +246,7 @@ declare const getDocumentOptions: (options: MarkdownItMathjaxOptions) => Documen
250
246
  /**
251
247
  * Mathjax instance
252
248
  */
253
- interface MathjaxInstance extends Required<Pick<MarkdownItMathjaxOptions, "allowInlineWithSpace" | "mathFence">> {
249
+ interface MathjaxInstance extends Required<Pick<MarkdownItMathjaxOptions, "allowInlineWithSpace" | "delimiters" | "mathFence">> {
254
250
  /**
255
251
  * Mathjax adaptor
256
252
  */
@@ -279,7 +275,7 @@ interface MathjaxInstance extends Required<Pick<MarkdownItMathjaxOptions, "allow
279
275
  transformer: TeXTransformer | null;
280
276
  }
281
277
  declare const createMathjaxInstance: (options?: MarkdownItMathjaxOptions) => MathjaxInstance | null;
282
- declare const mathjax: (md: MarkdownIt, { allowInlineWithSpace, adaptor, documentOptions, mathFence, transformer, }: MathjaxInstance) => void;
278
+ declare const mathjax: (md: MarkdownIt, { allowInlineWithSpace, adaptor, delimiters, documentOptions, mathFence, transformer, }: MathjaxInstance) => void;
283
279
 
284
280
  export { createMathjaxInstance, getDocumentOptions, mathjax };
285
281
  export type { DocumentOptions, MarkdownItMathjaxOptions, MathJaxTexInputOptions, MathjaxCommonHTMLOutputOptions, MathjaxCommonOutputOptions, MathjaxInstance, MathjaxSVGOutputOptions, TeXTransformer };
package/lib/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{createRequire as j}from"node:module";import{tex as v}from"@mdit/plugin-tex";import y from"upath";const I=j(import.meta.url);let u=!0,c,h,f,p,w,d,x,S;try{({mathjax:c}=await import("mathjax-full/js/mathjax.js")),{AllPackages:h}=await import("mathjax-full/js/input/tex/AllPackages.js"),{TeX:f}=await import("mathjax-full/js/input/tex.js"),{CHTML:p}=await import("mathjax-full/js/output/chtml.js"),{SVG:w}=await import("mathjax-full/js/output/svg.js"),{liteAdaptor:d}=await import("mathjax-full/js/adaptors/liteAdaptor.js"),{RegisterHTMLHandler:x}=await import("mathjax-full/js/handlers/html.js"),{AssistiveMmlHandler:S}=await import("mathjax-full/js/a11y/assistive-mml.js")}catch{/* istanbul ignore next -- @preserve */u=!1}const M=t=>{/* istanbul ignore if -- @preserve */if(!u)throw new Error('[@mdit/mathjax] "mathjax-full" is not installed!');return{InputJax:new f({packages:h,...t.tex}),OutputJax:t.output==="chtml"?new p({fontURL:y.dirname(I.resolve("mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_Zero.woff")),adaptiveCSS:!0,...t.chtml}):new w({fontCache:"none",...t.svg}),enableAssistiveMml:t.a11y!==!1}},H=(t={})=>{const e=M(t),{OutputJax:a,InputJax:l}=e,r=d(),m=x(r);t.a11y!==!1&&S(m);const n=()=>{a instanceof p&&a.clearCache()},o=()=>{l.reset()},s=()=>{const i=r.innerHTML(a.styleSheet(c.document("",e)));return n(),i};return{adaptor:r,documentOptions:e,allowInlineWithSpace:t.allowInlineWithSpace??!1,mathFence:t.mathFence??!1,clearStyle:n,reset:o,outputStyle:s,transformer:t.transformer??null}},T=(t,{allowInlineWithSpace:e,adaptor:a,documentOptions:l,mathFence:r,transformer:m})=>{t.use(v,{allowInlineWithSpace:e,mathFence:r,render:(n,o)=>{const s=c.document(n,l).convert(n,{display:o}),i=a.outerHTML(s);return m?.(i,o)??i}})};export{H as createMathjaxInstance,M as getDocumentOptions,T as mathjax};
1
+ import{createRequire as v}from"node:module";import{tex as y}from"@mdit/plugin-tex";import H from"upath";const I=v(import.meta.url);let h=!0,c,f,d,p,w,x,S,M;try{({mathjax:c}=await import("mathjax-full/js/mathjax.js")),{AllPackages:f}=await import("mathjax-full/js/input/tex/AllPackages.js"),{TeX:d}=await import("mathjax-full/js/input/tex.js"),{CHTML:p}=await import("mathjax-full/js/output/chtml.js"),{SVG:w}=await import("mathjax-full/js/output/svg.js"),{liteAdaptor:x}=await import("mathjax-full/js/adaptors/liteAdaptor.js"),{RegisterHTMLHandler:S}=await import("mathjax-full/js/handlers/html.js"),{AssistiveMmlHandler:M}=await import("mathjax-full/js/a11y/assistive-mml.js")}catch{/* istanbul ignore next -- @preserve */h=!1}const j=t=>{/* istanbul ignore if -- @preserve */if(!h)throw new Error('[@mdit/mathjax] "mathjax-full" is not installed!');return{InputJax:new d({packages:f,...t.tex}),OutputJax:t.output==="chtml"?new p({fontURL:H.dirname(I.resolve("mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_Zero.woff")),adaptiveCSS:!0,...t.chtml}):new w({fontCache:"none",...t.svg}),enableAssistiveMml:t.a11y!==!1}},L=(t={})=>{const e=j(t),{OutputJax:a,InputJax:l}=e,r=x(),m=S(r);t.a11y!==!1&&M(m);const n=()=>{a instanceof p&&a.clearCache()},o=()=>{l.reset()},i=()=>{const s=r.innerHTML(a.styleSheet(c.document("",e)));return n(),s};return{adaptor:r,documentOptions:e,allowInlineWithSpace:t.allowInlineWithSpace??!1,delimiters:t.delimiters??"dollars",mathFence:t.mathFence??!1,clearStyle:n,reset:o,outputStyle:i,transformer:t.transformer??null}},g=(t,{allowInlineWithSpace:e,adaptor:a,delimiters:l,documentOptions:r,mathFence:m,transformer:n})=>{t.use(y,{allowInlineWithSpace:e,delimiters:l,mathFence:m,render:(o,i)=>{const s=c.document(o,r).convert(o,{display:i}),u=a.outerHTML(s);return n?.(u,i)??u}})};export{L as createMathjaxInstance,j as getDocumentOptions,g as mathjax};
2
2
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/plugin.ts"],"sourcesContent":["/**\n * Forked from https://github.com/tani/markdown-it-mathjax3/blob/master/index.ts\n */\n\n/* eslint-disable @typescript-eslint/consistent-type-imports */\nimport { createRequire } from \"node:module\";\n\nimport { tex } from \"@mdit/plugin-tex\";\nimport type MarkdownIt from \"markdown-it\";\nimport type { LiteDocument } from \"mathjax-full/js/adaptors/lite/Document.js\";\nimport type {\n LiteElement,\n LiteNode,\n} from \"mathjax-full/js/adaptors/lite/Element.js\";\nimport type { LiteText } from \"mathjax-full/js/adaptors/lite/Text.js\";\nimport type { LiteAdaptor } from \"mathjax-full/js/adaptors/liteAdaptor.js\";\nimport type { MathDocument } from \"mathjax-full/js/core/MathDocument.js\";\nimport type { TeX as TeXType } from \"mathjax-full/js/input/tex.js\";\nimport type { CHTML as CHTMLType } from \"mathjax-full/js/output/chtml.js\";\nimport type { SVG as SVGType } from \"mathjax-full/js/output/svg.js\";\nimport path from \"upath\";\n\nimport type { MarkdownItMathjaxOptions, TeXTransformer } from \"./options.js\";\n\nconst require = createRequire(import.meta.url);\n\nlet isMathJaxFullInstalled = true;\nlet mathjaxLib: typeof import(\"mathjax-full/js/mathjax.js\").mathjax;\nlet AllPackages: typeof import(\"mathjax-full/js/input/tex/AllPackages.js\").AllPackages;\nlet TeX: typeof import(\"mathjax-full/js/input/tex.js\").TeX;\nlet CHTML: typeof import(\"mathjax-full/js/output/chtml.js\").CHTML;\nlet SVG: typeof import(\"mathjax-full/js/output/svg.js\").SVG;\nlet liteAdaptor: typeof import(\"mathjax-full/js/adaptors/liteAdaptor.js\").liteAdaptor;\nlet RegisterHTMLHandler: typeof import(\"mathjax-full/js/handlers/html.js\").RegisterHTMLHandler;\nlet AssistiveMmlHandler: typeof import(\"mathjax-full/js/a11y/assistive-mml.js\").AssistiveMmlHandler;\n\ntry {\n ({ mathjax: mathjaxLib } = await import(\"mathjax-full/js/mathjax.js\"));\n ({ AllPackages } = await import(\"mathjax-full/js/input/tex/AllPackages.js\"));\n ({ TeX } = await import(\"mathjax-full/js/input/tex.js\"));\n ({ CHTML } = await import(\"mathjax-full/js/output/chtml.js\"));\n ({ SVG } = await import(\"mathjax-full/js/output/svg.js\"));\n ({ liteAdaptor } = await import(\"mathjax-full/js/adaptors/liteAdaptor.js\"));\n ({ RegisterHTMLHandler } = await import(\"mathjax-full/js/handlers/html.js\"));\n ({ AssistiveMmlHandler } = await import(\n \"mathjax-full/js/a11y/assistive-mml.js\"\n ));\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('[@mdit/mathjax] \"mathjax-full\" is not installed!');\n\n return {\n InputJax: new TeX<LiteElement, string, HTMLElement>({\n packages: AllPackages,\n ...options.tex,\n }),\n OutputJax:\n options.output === \"chtml\"\n ? new CHTML<LiteElement, string, HTMLElement>({\n fontURL: path.dirname(\n require.resolve(\n \"mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_Zero.woff\",\n ),\n ),\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\n extends Required<\n Pick<MarkdownItMathjaxOptions, \"allowInlineWithSpace\" | \"mathFence\">\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 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 documentOptions,\n mathFence,\n transformer,\n }: MathjaxInstance,\n): void => {\n md.use(tex, {\n allowInlineWithSpace,\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":["require","createRequire","isMathJaxFullInstalled","mathjaxLib","AllPackages","TeX","CHTML","SVG","liteAdaptor","RegisterHTMLHandler","AssistiveMmlHandler","getDocumentOptions","options","path","createMathjaxInstance","documentOptions","OutputJax","InputJax","adaptor","handler","clearStyle","reset","outputStyle","style","mathjax","md","allowInlineWithSpace","mathFence","transformer","tex","content","displayMode","mathDocument","result"],"mappings":"wGAwBA,MAAMA,EAAUC,EAAc,YAAY,GAAG,EAE7C,IAAIC,EAAyB,GACzBC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAI,EACD,CAAE,QAASP,CAAW,EAAI,aAAa,4BAA4B,GACnE,CAAE,YAAAC,CAAY,EAAI,KAAa,QAAA,0CAA0C,EACzE,CAAE,IAAAC,CAAI,EAAI,KAAa,QAAA,8BAA8B,EACrD,CAAE,MAAAC,CAAM,EAAI,KAAM,QAAO,iCAAiC,EAC1D,CAAE,IAAAC,CAAI,EAAI,KAAM,QAAO,+BAA+B,EACtD,CAAE,YAAAC,CAAY,EAAI,aAAa,yCAAyC,EACxE,CAAE,oBAAAC,CAAoB,EAAI,KAAa,QAAA,kCAAkC,EACzE,CAAE,oBAAAC,CAAoB,EAAI,KACzB,QAAA,uCACF,CACF,MAAQ,CAAA,uCAENR,EAAyB,EAC3B,OAUaS,EACXC,GACoB,CAEpB,qCAAA,GAAI,CAACV,EACH,MAAM,IAAI,MAAM,kDAAkD,EAEpE,MAAO,CACL,SAAU,IAAIG,EAAsC,CAClD,SAAUD,EACV,GAAGQ,EAAQ,GACb,CAAC,EACD,UACEA,EAAQ,SAAW,QACf,IAAIN,EAAwC,CAC1C,QAASO,EAAK,QACZb,EAAQ,QACN,+DACF,CACF,EACA,YAAa,GACb,GAAGY,EAAQ,KACb,CAAC,EACD,IAAIL,EAAsC,CACxC,UAAW,OACX,GAAGK,EAAQ,GACb,CAAC,EACP,mBAAoBA,EAAQ,OAAS,EACvC,CACF,EA0CaE,EAAwB,CACnCF,EAAoC,CAAA,IACT,CAC3B,MAAMG,EAAkBJ,EAAmBC,CAAO,EAE5C,CAAE,UAAAI,EAAW,SAAAC,CAAS,EAAIF,EAE1BG,EAAUV,EAAAA,EACVW,EAAUV,EAAoBS,CAAO,EAEvCN,EAAQ,OAAS,IACnBF,EAAsDS,CAAO,EAE/D,MAAMC,EAAa,IAAY,CAEzBJ,aAAqBV,GAAOU,EAAU,WAAW,CACvD,EAEMK,EAAQ,IAAY,CACxBJ,EAAS,MACX,CAAA,EAEMK,EAAc,IAAc,CAChC,MAAMC,EAAQL,EAAQ,UACpBF,EAAU,WACRb,EAAW,SAAS,GAAIY,CAAe,CAKzC,CACF,EAEA,OAAAK,IAEOG,CACT,EAEA,MAAO,CACL,QAAAL,EACA,gBAAAH,EACA,qBAAsBH,EAAQ,sBAAwB,GACtD,UAAWA,EAAQ,WAAa,GAChC,WAAAQ,EACA,MAAAC,EACA,YAAAC,EACA,YAAaV,EAAQ,aAAe,IACtC,CACF,EAEaY,EAAU,CACrBC,EACA,CACE,qBAAAC,EACA,QAAAR,EACA,gBAAAH,EACA,UAAAY,EACA,YAAAC,CACF,IACS,CACTH,EAAG,IAAII,EAAK,CACV,qBAAAH,EACA,UAAAC,EACA,OAAQ,CAACG,EAASC,IAAgB,CAChC,MAAMC,EAAe7B,EAClB,SAAS2B,EAASf,CAAe,EACjC,QAAQe,EAAS,CAChB,QAASC,CACX,CAAC,EAEGE,EAASf,EAAQ,UAAUc,CAAY,EAE7C,OAAOJ,IAAcK,EAAQF,CAAW,GAAKE,CAC/C,CACF,CAAC,CACH"}
1
+ {"version":3,"file":"index.js","sources":["../src/plugin.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/consistent-type-imports */\nimport { createRequire } from \"node:module\";\n\nimport { tex } from \"@mdit/plugin-tex\";\nimport type MarkdownIt from \"markdown-it\";\nimport type { LiteDocument } from \"mathjax-full/js/adaptors/lite/Document.js\";\nimport type {\n LiteElement,\n LiteNode,\n} from \"mathjax-full/js/adaptors/lite/Element.js\";\nimport type { LiteText } from \"mathjax-full/js/adaptors/lite/Text.js\";\nimport type { LiteAdaptor } from \"mathjax-full/js/adaptors/liteAdaptor.js\";\nimport type { MathDocument } from \"mathjax-full/js/core/MathDocument.js\";\nimport type { TeX as TeXType } from \"mathjax-full/js/input/tex.js\";\nimport type { CHTML as CHTMLType } from \"mathjax-full/js/output/chtml.js\";\nimport type { SVG as SVGType } from \"mathjax-full/js/output/svg.js\";\nimport path from \"upath\";\n\nimport type { MarkdownItMathjaxOptions, TeXTransformer } from \"./options.js\";\n\nconst require = createRequire(import.meta.url);\n\nlet isMathJaxFullInstalled = true;\nlet mathjaxLib: typeof import(\"mathjax-full/js/mathjax.js\").mathjax;\nlet AllPackages: typeof import(\"mathjax-full/js/input/tex/AllPackages.js\").AllPackages;\nlet TeX: typeof import(\"mathjax-full/js/input/tex.js\").TeX;\nlet CHTML: typeof import(\"mathjax-full/js/output/chtml.js\").CHTML;\nlet SVG: typeof import(\"mathjax-full/js/output/svg.js\").SVG;\nlet liteAdaptor: typeof import(\"mathjax-full/js/adaptors/liteAdaptor.js\").liteAdaptor;\nlet RegisterHTMLHandler: typeof import(\"mathjax-full/js/handlers/html.js\").RegisterHTMLHandler;\nlet AssistiveMmlHandler: typeof import(\"mathjax-full/js/a11y/assistive-mml.js\").AssistiveMmlHandler;\n\ntry {\n ({ mathjax: mathjaxLib } = await import(\"mathjax-full/js/mathjax.js\"));\n ({ AllPackages } = await import(\"mathjax-full/js/input/tex/AllPackages.js\"));\n ({ TeX } = await import(\"mathjax-full/js/input/tex.js\"));\n ({ CHTML } = await import(\"mathjax-full/js/output/chtml.js\"));\n ({ SVG } = await import(\"mathjax-full/js/output/svg.js\"));\n ({ liteAdaptor } = await import(\"mathjax-full/js/adaptors/liteAdaptor.js\"));\n ({ RegisterHTMLHandler } = await import(\"mathjax-full/js/handlers/html.js\"));\n ({ AssistiveMmlHandler } = await import(\n \"mathjax-full/js/a11y/assistive-mml.js\"\n ));\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('[@mdit/mathjax] \"mathjax-full\" is not installed!');\n\n return {\n InputJax: new TeX<LiteElement, string, HTMLElement>({\n packages: AllPackages,\n ...options.tex,\n }),\n OutputJax:\n options.output === \"chtml\"\n ? new CHTML<LiteElement, string, HTMLElement>({\n fontURL: path.dirname(\n require.resolve(\n \"mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_Zero.woff\",\n ),\n ),\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\n 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":["require","createRequire","isMathJaxFullInstalled","mathjaxLib","AllPackages","TeX","CHTML","SVG","liteAdaptor","RegisterHTMLHandler","AssistiveMmlHandler","getDocumentOptions","options","path","createMathjaxInstance","documentOptions","OutputJax","InputJax","adaptor","handler","clearStyle","reset","outputStyle","style","mathjax","md","allowInlineWithSpace","delimiters","mathFence","transformer","tex","content","displayMode","mathDocument","result"],"mappings":"wGAoBA,MAAMA,EAAUC,EAAc,YAAY,GAAG,EAE7C,IAAIC,EAAyB,GACzBC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAI,EACD,CAAE,QAASP,CAAW,EAAI,KAAM,QAAO,4BAA4B,GACnE,CAAE,YAAAC,CAAY,EAAI,KAAM,QAAO,0CAA0C,EACzE,CAAE,IAAAC,CAAI,EAAI,aAAa,8BAA8B,EACrD,CAAE,MAAAC,CAAM,EAAI,KAAa,QAAA,iCAAiC,EAC1D,CAAE,IAAAC,CAAI,EAAI,KAAa,QAAA,+BAA+B,EACtD,CAAE,YAAAC,CAAY,EAAI,KAAa,QAAA,yCAAyC,EACxE,CAAE,oBAAAC,CAAoB,EAAI,KAAa,QAAA,kCAAkC,EACzE,CAAE,oBAAAC,CAAoB,EAAI,KAAM,QAC/B,uCACF,CACF,MAAQ,CAAA,uCAENR,EAAyB,EAC3B,CAUa,MAAAS,EACXC,GACoB,CAAA,qCAEpB,GAAI,CAACV,EACH,MAAM,IAAI,MAAM,kDAAkD,EAEpE,MAAO,CACL,SAAU,IAAIG,EAAsC,CAClD,SAAUD,EACV,GAAGQ,EAAQ,GACb,CAAC,EACD,UACEA,EAAQ,SAAW,QACf,IAAIN,EAAwC,CAC1C,QAASO,EAAK,QACZb,EAAQ,QACN,+DACF,CACF,EACA,YAAa,GACb,GAAGY,EAAQ,KACb,CAAC,EACD,IAAIL,EAAsC,CACxC,UAAW,OACX,GAAGK,EAAQ,GACb,CAAC,EACP,mBAAoBA,EAAQ,OAAS,EACvC,CACF,EA6CaE,EAAwB,CACnCF,EAAoC,CAAA,IACT,CAC3B,MAAMG,EAAkBJ,EAAmBC,CAAO,EAE5C,CAAE,UAAAI,EAAW,SAAAC,CAAS,EAAIF,EAE1BG,EAAUV,IACVW,EAAUV,EAAoBS,CAAO,EAEvCN,EAAQ,OAAS,IACnBF,EAAsDS,CAAO,EAE/D,MAAMC,EAAa,IAAY,CAEzBJ,aAAqBV,GAAOU,EAAU,WAAW,CACvD,EAEMK,EAAQ,IAAY,CACxBJ,EAAS,OACX,EAEMK,EAAc,IAAc,CAChC,MAAMC,EAAQL,EAAQ,UACpBF,EAAU,WACRb,EAAW,SAAS,GAAIY,CAAe,CAKzC,CACF,EAEA,OAAAK,IAEOG,CACT,EAEA,MAAO,CACL,QAAAL,EACA,gBAAAH,EACA,qBAAsBH,EAAQ,sBAAwB,GACtD,WAAYA,EAAQ,YAAc,UAClC,UAAWA,EAAQ,WAAa,GAChC,WAAAQ,EACA,MAAAC,EACA,YAAAC,EACA,YAAaV,EAAQ,aAAe,IACtC,CACF,EAEaY,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,EAAe9B,EAClB,SAAS4B,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mdit/plugin-mathjax-slim",
3
- "version": "0.22.0",
3
+ "version": "0.23.1",
4
4
  "description": "mathjax plugin for MarkdownIt",
5
5
  "keywords": [
6
6
  "markdown-it",
@@ -30,15 +30,15 @@
30
30
  },
31
31
  "./package.json": "./package.json"
32
32
  },
33
- "main": "lib/index.js",
34
- "types": "lib/index.d.ts",
33
+ "main": "./lib/index.js",
34
+ "types": "./lib/index.d.ts",
35
35
  "files": [
36
36
  "lib"
37
37
  ],
38
38
  "dependencies": {
39
39
  "@types/markdown-it": "^14.1.2",
40
40
  "upath": "^2.0.1",
41
- "@mdit/plugin-tex": "0.22.0"
41
+ "@mdit/plugin-tex": "0.22.1"
42
42
  },
43
43
  "devDependencies": {
44
44
  "mathjax-full": "3.2.2"