@mdit/plugin-mathjax-slim 0.26.0 → 0.26.2
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-jSCcpwWF.js +1 -0
- package/dist/index.d.ts +260 -260
- package/dist/index.js.map +1 -1
- package/dist/sync.d.ts +257 -257
- package/dist/sync.js +1 -1
- package/package.json +13 -5
- package/dist/importer-N3BdKsx_.js +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/sync.d.ts.map +0 -1
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 { 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\";\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\";\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,eAAk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Q,aAAe,KACrC,EAGU,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,EAAgB,CAAC,QAAQ,EAAS,CAClF,QAAS,EACV,CAAC,CAEI,EAAS,EAAQ,UAAU,EAAa,CAE9C,OAAO,IAAc,EAAQ,EAAY,EAAI,GAEhD,CAAC"}
|
|
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,OAA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