@mdit/plugin-mathjax-slim 0.24.1 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/sync.js CHANGED
@@ -1,2 +1,2 @@
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
1
+ import{createRequire as e}from"node:module";import{tex as t}from"@mdit/plugin-tex";const n=`action.ams.amscd.bbm.bboldx.bbox.begingroup.boldsymbol.braket.bussproofs.cancel.cases.centernot.color.colortbl.colorv2.configmacros.dsfont.empheq.enclose.extpfeil.gensymb.html.mathtools.mhchem.newcommand.noerrors.noundefined.physics.setoptions.tagformat.texhtml.textcomp.textmacros.unicode.units.upgreek.verb`.split(`.`);let r=!0,i,a,o,s,c,l,u,d=!0,f,p;try{({mathjax:i}=await import(`@mathjax/src/cjs/mathjax.js`)),{TeX:a}=await import(`@mathjax/src/cjs/input/tex.js`),{CHTML:o}=await import(`@mathjax/src/cjs/output/chtml.js`),{SVG:s}=await import(`@mathjax/src/cjs/output/svg.js`),{liteAdaptor:c}=await import(`@mathjax/src/cjs/adaptors/liteAdaptor.js`),{RegisterHTMLHandler:l}=await import(`@mathjax/src/cjs/handlers/html.js`),{AssistiveMmlHandler:u}=await import(`@mathjax/src/cjs/a11y/assistive-mml.js`),await import(`./importer-N3BdKsx_.js`);let t=e(import.meta.url);i.asyncLoad=e=>{t(e)},i.asyncIsSynchronous=!0}catch{r=!1}try{f=(await import(`@mathjax/mathjax-newcm-font/cjs/chtml.js`)).MathJaxNewcmFont,p=(await import(`@mathjax/mathjax-newcm-font/cjs/svg.js`)).MathJaxNewcmFont}catch{d=!1}const m=e=>{if(!r)throw Error(`[@mdit/plugin-mathjax-slim] "@mathjax/src" is not installed!`);let t=e.output===`chtml`,i=(t?e.chtml:e.svg)??{};if(!i.fontData&&!d)throw Error(`[@mdit/plugin-mathjax-slim] "@mathjax/mathjax-newcm-font" is not installed!`);let c=Object.assign({fontData:t?f:p},i?.fontData?{}:{dynamicPrefix:`@mathjax/mathjax-newcm-font/cjs/${t?`chtml`:`svg`}/dynamic`},t&&!i.fontData?{fontURL:`https://cdn.jsdelivr.net/npm/@mathjax/mathjax-newcm-font/chtml/woff2`}:{},i);return{InputJax:new a({packages:[`base`,...n],...e.tex}),OutputJax:new(t?o:s)(c),enableAssistiveMml:e.a11y!==!1}},h=(e={})=>{let t=m(e),{OutputJax:n,InputJax:r}=t,a=c(),o=l(a);e.a11y!==!1&&u(o);let s=()=>{n.adaptor&&n.reset()};return{adaptor:a,documentOptions:t,allowInlineWithSpace:e.allowInlineWithSpace??!1,delimiters:e.delimiters??`dollars`,mathFence:e.mathFence??!1,clearStyle:s,reset:()=>{r.reset()},outputStyle:()=>{n.font.loadDynamicFilesSync();let e=a.cssText(n.styleSheet(i.document(``,t)));return s(),e},transformer:e.transformer??null}},g=(e,{allowInlineWithSpace:n,adaptor:r,delimiters:a,documentOptions:o,mathFence:s,transformer:c})=>{e.use(t,{allowInlineWithSpace:n,delimiters:a,mathFence:s,render:(e,t)=>{let n=i.document(e,o).convert(e,{display:t}),a=r.outerHTML(n);return c?.(a,t)??a}})};export{h as createMathjaxInstance,m as getDocumentOptions,g as mathjax};
2
+ //# sourceMappingURL=sync.js.map
package/lib/sync.js.map CHANGED
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"sync.js","names":[],"sources":["../src/tex/packages.ts","../src/sync.ts"],"sourcesContent":["import type { TexPackage } from \"../mathjax.js\";\n\nexport const texPackages: TexPackage[] = [\n \"action\",\n \"ams\",\n \"amscd\",\n \"bbm\",\n \"bboldx\",\n \"bbox\",\n \"begingroup\",\n \"boldsymbol\",\n \"braket\",\n \"bussproofs\",\n \"cancel\",\n \"cases\",\n \"centernot\",\n \"color\",\n \"colortbl\",\n \"colorv2\",\n \"configmacros\",\n \"dsfont\",\n \"empheq\",\n \"enclose\",\n \"extpfeil\",\n \"gensymb\",\n \"html\",\n \"mathtools\",\n \"mhchem\",\n \"newcommand\",\n \"noerrors\",\n \"noundefined\",\n \"physics\",\n \"setoptions\",\n \"tagformat\",\n \"texhtml\",\n \"textcomp\",\n \"textmacros\",\n \"unicode\",\n \"units\",\n \"upgreek\",\n \"verb\",\n];\n","/**\n * Forked from https://github.com/tani/markdown-it-mathjax3/blob/master/index.ts\n */\nimport type { MathJaxNewcmFont as MathJaxNewcmHTMLFont } from \"@mathjax/mathjax-newcm-font/cjs/chtml.js\";\nimport type { MathJaxNewcmFont as MathJaxNewcmSVGFont } from \"@mathjax/mathjax-newcm-font/cjs/svg.js\";\nimport type { AssistiveMmlHandler as AssistiveMmlHandlerType } from \"@mathjax/src/cjs/a11y/assistive-mml.js\";\nimport type { LiteDocument } from \"@mathjax/src/cjs/adaptors/lite/Document.js\";\nimport type { LiteElement, LiteNode } from \"@mathjax/src/cjs/adaptors/lite/Element.js\";\nimport type { LiteText } from \"@mathjax/src/cjs/adaptors/lite/Text.js\";\nimport type {\n LiteAdaptor,\n liteAdaptor as liteAdaptorType,\n} from \"@mathjax/src/cjs/adaptors/liteAdaptor.js\";\nimport type { MathDocument } from \"@mathjax/src/cjs/core/MathDocument.js\";\nimport type { RegisterHTMLHandler as RegisterHTMLHandlerType } from \"@mathjax/src/cjs/handlers/html.js\";\nimport type { TeX as TeXType } from \"@mathjax/src/cjs/input/tex.js\";\nimport type { mathjax as mathjaxType } from \"@mathjax/src/cjs/mathjax.js\";\nimport type { CHTML as CHTMLType } from \"@mathjax/src/cjs/output/chtml.js\";\nimport type { SVG as SVGType } from \"@mathjax/src/cjs/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\n// oxlint-disable-next-line import/no-unassigned-import\nimport \"./tex/importer.js\";\nimport { createRequire } from \"node:module\";\n\nlet isMathJaxFullInstalled = true;\nlet mathjaxLib: typeof mathjaxType;\nlet TeX: typeof TeXType;\nlet CHTML: typeof CHTMLType;\nlet SVG: typeof SVGType;\nlet liteAdaptor: typeof liteAdaptorType;\nlet RegisterHTMLHandler: typeof RegisterHTMLHandlerType;\nlet AssistiveMmlHandler: typeof AssistiveMmlHandlerType;\nlet isMathJaxNewcmFontInstalled = true;\nlet chtmlFont: typeof MathJaxNewcmHTMLFont;\nlet svgFont: typeof MathJaxNewcmSVGFont;\n\ntry {\n ({ mathjax: mathjaxLib } = await import(\"@mathjax/src/cjs/mathjax.js\"));\n ({ TeX } = await import(\"@mathjax/src/cjs/input/tex.js\"));\n ({ CHTML } = await import(\"@mathjax/src/cjs/output/chtml.js\"));\n ({ SVG } = await import(\"@mathjax/src/cjs/output/svg.js\"));\n ({ liteAdaptor } = await import(\"@mathjax/src/cjs/adaptors/liteAdaptor.js\"));\n ({ RegisterHTMLHandler } = await import(\"@mathjax/src/cjs/handlers/html.js\"));\n ({ AssistiveMmlHandler } = await import(\"@mathjax/src/cjs/a11y/assistive-mml.js\"));\n await import(\"./tex/importer.js\");\n\n const require = createRequire(import.meta.url);\n\n mathjaxLib.asyncLoad = (file) => {\n require(file);\n };\n mathjaxLib.asyncIsSynchronous = true;\n} catch {\n /* istanbul ignore next -- @preserve */\n isMathJaxFullInstalled = false;\n}\n\ntry {\n // oxlint-disable-next-line unicorn/no-await-expression-member\n chtmlFont = (await import(\"@mathjax/mathjax-newcm-font/cjs/chtml.js\")).MathJaxNewcmFont;\n // oxlint-disable-next-line unicorn/no-await-expression-member\n svgFont = (await import(\"@mathjax/mathjax-newcm-font/cjs/svg.js\")).MathJaxNewcmFont;\n} catch {\n /* istanbul ignore next -- @preserve */\n isMathJaxNewcmFontInstalled = 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 = (options: MarkdownItMathjaxOptions): DocumentOptions => {\n /* istanbul ignore if -- @preserve */\n if (!isMathJaxFullInstalled)\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/cjs/${isCHTML ? \"chtml\" : \"svg\"}/dynamic` },\n isCHTML && !userOptions.fontData\n ? { fontURL: \"https://cdn.jsdelivr.net/npm/@mathjax/mathjax-newcm-font/chtml/woff2\" }\n : {},\n userOptions,\n );\n\n return {\n InputJax: new TeX<LiteElement, string, HTMLElement>({\n packages: [\"base\", ...texPackages],\n ...options.tex,\n }),\n OutputJax: new (isCHTML ? CHTML : SVG)<LiteElement, string, HTMLElement>(outputOptions),\n\n enableAssistiveMml: options.a11y !== false,\n };\n};\n\n/**\n * Mathjax instance\n */\nexport interface MathjaxInstance extends Required<\n Pick<MarkdownItMathjaxOptions, \"allowInlineWithSpace\" | \"delimiters\" | \"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 // 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) return;\n\n OutputJax.reset();\n };\n\n const reset = (): void => {\n InputJax.reset();\n };\n\n const outputStyle = (): string => {\n OutputJax.font.loadDynamicFilesSync();\n\n const style = adaptor.cssText(\n OutputJax.styleSheet(\n mathjaxLib.document(\"\", documentOptions) as MathDocument<LiteElement, string, HTMLElement>,\n ),\n );\n\n clearStyle();\n\n return style;\n };\n\n return {\n adaptor,\n documentOptions,\n allowInlineWithSpace: options.allowInlineWithSpace ?? false,\n delimiters: options.delimiters ?? \"dollars\",\n mathFence: options.mathFence ?? false,\n clearStyle,\n reset,\n outputStyle,\n transformer: options.transformer ?? null,\n };\n};\n\nexport const mathjax = (\n md: MarkdownIt,\n {\n allowInlineWithSpace,\n adaptor,\n delimiters,\n documentOptions,\n mathFence,\n transformer,\n }: MathjaxInstance,\n): void => {\n md.use(tex, {\n allowInlineWithSpace,\n delimiters,\n mathFence,\n render: (content, displayMode) => {\n const mathDocument = mathjaxLib.document(content, documentOptions).convert(content, {\n display: displayMode,\n }) as LiteElement;\n\n const result = adaptor.outerHTML(mathDocument);\n\n return transformer?.(result, displayMode) ?? result;\n },\n });\n};\n"],"mappings":"mFAEA,MAAa,EAA4B,iUAuCxC,CCZD,IAAI,EAAyB,GACzB,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EAA8B,GAC9B,EACA,EAEJ,GAAI,EACD,CAAE,QAAS,GAAe,MAAM,OAAO,gCACvC,QAAU,MAAM,OAAO,iCACvB,UAAY,MAAM,OAAO,oCACzB,QAAU,MAAM,OAAO,kCACvB,gBAAkB,MAAM,OAAO,4CAC/B,wBAA0B,MAAM,OAAO,qCACvC,wBAA0B,MAAM,OAAO,0CACxC,MAAM,OAAO,0BAEb,IAAM,EAAU,EAAc,OAAO,KAAK,IAAI,CAE9C,EAAW,UAAa,GAAS,CAC/B,EAAQ,EAAK,EAEf,EAAW,mBAAqB,QAC1B,CAEN,EAAyB,GAG3B,GAAI,CAEF,GAAa,MAAM,OAAO,6CAA6C,iBAEvE,GAAW,MAAM,OAAO,2CAA2C,sBAC7D,CAEN,EAA8B,GAWhC,MAAa,EAAsB,GAAuD,CAExF,GAAI,CAAC,EACH,MAAU,MAAM,+DAA+D,CAEjF,IAAM,EAAU,EAAQ,SAAW,QAC7B,GAAe,EAAU,EAAQ,MAAQ,EAAQ,MAAQ,EAAE,CAGjE,GAAI,CAAC,EAAY,UAAY,CAAC,EAC5B,MAAU,MAAM,8EAA8E,CAEhG,IAAM,EAAgB,OAAO,OAC3B,CACE,SAAU,EAAU,EAAY,EACjC,CAGD,GAAa,SACT,EAAE,CACF,CAAE,cAAe,mCAAmC,EAAU,QAAU,MAAM,UAAW,CAC7F,GAAW,CAAC,EAAY,SACpB,CAAE,QAAS,uEAAwE,CACnF,EAAE,CACN,EACD,CAED,MAAO,CACL,SAAU,IAAI,EAAsC,CAClD,SAAU,CAAC,OAAQ,GAAG,EAAY,CAClC,GAAG,EAAQ,IACZ,CAAC,CACF,UAAW,IAAK,EAAU,EAAQ,GAAuC,EAAc,CAEvF,mBAAoB,EAAQ,OAAS,GACtC,EA0CU,GACX,EAAoC,EAAE,GACX,CAC3B,IAAM,EAAkB,EAAmB,EAAQ,CAE7C,CAAE,YAAW,YAAa,EAE1B,EAAU,GAAa,CAEvB,EAAU,EAAoB,EAAQ,CAGxC,EAAQ,OAAS,IAAO,EAAsD,EAAQ,CAE1F,IAAM,MAAyB,CAExB,EAAU,SAEf,EAAU,OAAO,EAqBnB,MAAO,CACL,UACA,kBACA,qBAAsB,EAAQ,sBAAwB,GACtD,WAAY,EAAQ,YAAc,UAClC,UAAW,EAAQ,WAAa,GAChC,aACA,UAzBwB,CACxB,EAAS,OAAO,EAyBhB,gBAtBgC,CAChC,EAAU,KAAK,sBAAsB,CAErC,IAAM,EAAQ,EAAQ,QACpB,EAAU,WACR,EAAW,SAAS,GAAI,EAAgB,CACzC,CACF,CAID,OAFA,GAAY,CAEL,GAYP,YAAa,EAAQ,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mdit/plugin-mathjax-slim",
3
- "version": "0.24.1",
3
+ "version": "0.25.0",
4
4
  "description": "mathjax plugin for MarkdownIt",
5
5
  "keywords": [
6
6
  "markdown-it",
@@ -11,18 +11,23 @@
11
11
  "bugs": {
12
12
  "url": "https://github.com/mdit-plugins/mdit-plugins/issues"
13
13
  },
14
- "repository": {
15
- "type": "git",
16
- "url": "git+https://github.com/mdit-plugins/mdit-plugins.git",
17
- "directory": "packages/mathjax"
18
- },
19
14
  "license": "MIT",
20
15
  "author": {
21
16
  "name": "Mr.Hope",
22
17
  "email": "mister-hope@outlook.com",
23
18
  "url": "https://mister-hope.com"
24
19
  },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/mdit-plugins/mdit-plugins.git",
23
+ "directory": "packages/mathjax"
24
+ },
25
+ "files": [
26
+ "lib"
27
+ ],
25
28
  "type": "module",
29
+ "main": "./lib/index.js",
30
+ "types": "./lib/index.d.ts",
26
31
  "exports": {
27
32
  ".": {
28
33
  "type": "./lib/index.d.ts",
@@ -34,23 +39,26 @@
34
39
  },
35
40
  "./package.json": "./package.json"
36
41
  },
37
- "main": "./lib/index.js",
38
- "types": "./lib/index.d.ts",
39
- "files": [
40
- "lib"
41
- ],
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
42
45
  "dependencies": {
43
46
  "@types/markdown-it": "^14.1.2",
44
- "@mdit/plugin-tex": "0.23.0"
47
+ "@mdit/plugin-tex": "0.23.1"
45
48
  },
46
49
  "devDependencies": {
47
- "@mathjax/src": "4.0.0"
50
+ "@mathjax/mathjax-tex-font": "^4.1.0",
51
+ "@mathjax/src": "4.1.0"
48
52
  },
49
53
  "peerDependencies": {
54
+ "@mathjax/mathjax-newcm-font": "^4.1.0",
50
55
  "@mathjax/src": "^4.0.0",
51
56
  "markdown-it": "^14.1.0"
52
57
  },
53
58
  "peerDependenciesMeta": {
59
+ "@mathjax/mathjax-newcm-font": {
60
+ "optional": true
61
+ },
54
62
  "@mathjax/src": {
55
63
  "optional": true
56
64
  },
@@ -61,11 +69,8 @@
61
69
  "engines": {
62
70
  "node": ">= 18"
63
71
  },
64
- "publishConfig": {
65
- "access": "public"
66
- },
67
72
  "scripts": {
68
- "build": "rollup -c rollup.config.ts --configPlugin esbuild",
73
+ "build": "tsdown --config-loader unrun",
69
74
  "clean": "rimraf ./lib"
70
75
  }
71
76
  }
@@ -1,2 +0,0 @@
1
- import"@mathjax/src/js/input/tex/action/ActionConfiguration.js";import"@mathjax/src/js/input/tex/ams/AmsConfiguration.js";import"@mathjax/src/js/input/tex/amscd/AmsCdConfiguration.js";import"@mathjax/src/js/input/tex/base/BaseConfiguration.js";import"@mathjax/src/js/input/tex/bbm/BbmConfiguration.js";import"@mathjax/src/js/input/tex/bboldx/BboldxConfiguration.js";import"@mathjax/src/js/input/tex/bbox/BboxConfiguration.js";import"@mathjax/src/js/input/tex/begingroup/BegingroupConfiguration.js";import"@mathjax/src/js/input/tex/boldsymbol/BoldsymbolConfiguration.js";import"@mathjax/src/js/input/tex/braket/BraketConfiguration.js";import"@mathjax/src/js/input/tex/bussproofs/BussproofsConfiguration.js";import"@mathjax/src/js/input/tex/cancel/CancelConfiguration.js";import"@mathjax/src/js/input/tex/cases/CasesConfiguration.js";import"@mathjax/src/js/input/tex/centernot/CenternotConfiguration.js";import"@mathjax/src/js/input/tex/color/ColorConfiguration.js";import"@mathjax/src/js/input/tex/colortbl/ColortblConfiguration.js";import"@mathjax/src/js/input/tex/colorv2/ColorV2Configuration.js";import"@mathjax/src/js/input/tex/configmacros/ConfigMacrosConfiguration.js";import"@mathjax/src/js/input/tex/dsfont/DsfontConfiguration.js";import"@mathjax/src/js/input/tex/empheq/EmpheqConfiguration.js";import"@mathjax/src/js/input/tex/enclose/EncloseConfiguration.js";import"@mathjax/src/js/input/tex/extpfeil/ExtpfeilConfiguration.js";import"@mathjax/src/js/input/tex/gensymb/GensymbConfiguration.js";import"@mathjax/src/js/input/tex/html/HtmlConfiguration.js";import"@mathjax/src/js/input/tex/mathtools/MathtoolsConfiguration.js";import"@mathjax/src/js/input/tex/mhchem/MhchemConfiguration.js";import"@mathjax/src/js/input/tex/newcommand/NewcommandConfiguration.js";import"@mathjax/src/js/input/tex/noerrors/NoErrorsConfiguration.js";import"@mathjax/src/js/input/tex/noundefined/NoUndefinedConfiguration.js";import"@mathjax/src/js/input/tex/physics/PhysicsConfiguration.js";import"@mathjax/src/js/input/tex/setoptions/SetOptionsConfiguration.js";import"@mathjax/src/js/input/tex/tagformat/TagFormatConfiguration.js";import"@mathjax/src/js/input/tex/texhtml/TexHtmlConfiguration.js";import"@mathjax/src/js/input/tex/textcomp/TextcompConfiguration.js";import"@mathjax/src/js/input/tex/textmacros/TextMacrosConfiguration.js";import"@mathjax/src/js/input/tex/unicode/UnicodeConfiguration.js";import"@mathjax/src/js/input/tex/units/UnitsConfiguration.js";import"@mathjax/src/js/input/tex/upgreek/UpgreekConfiguration.js";import"@mathjax/src/js/input/tex/verb/VerbConfiguration.js";
2
- //# sourceMappingURL=importer-C5KF-eLj.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"importer-C5KF-eLj.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}