@mdit/plugin-mathjax-slim 1.2.1 → 1.2.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/index.js CHANGED
@@ -1,2 +1,10 @@
1
- import{tex as e}from"@mdit/plugin-tex";const t=`action.ams.amscd.bbm.bboldx.bbox.begingroup.boldsymbol.braket.bussproofs.cancel.cases.centernot.color.colortbl.colorv2.configmacros.dsfont.empheq.enclose.extpfeil.gensymb.html.mathtools.mhchem.newcommand.noerrors.noundefined.physics.setoptions.tagformat.texhtml.textcomp.textmacros.unicode.units.upgreek.verb`.split(`.`),n={action:()=>import(`@mathjax/src/js/input/tex/action/ActionConfiguration.js`),ams:()=>import(`@mathjax/src/js/input/tex/ams/AmsConfiguration.js`),amscd:()=>import(`@mathjax/src/js/input/tex/amscd/AmsCdConfiguration.js`),bbm:()=>import(`@mathjax/src/js/input/tex/bbm/BbmConfiguration.js`),bboldx:()=>import(`@mathjax/src/js/input/tex/bboldx/BboldxConfiguration.js`),bbox:()=>import(`@mathjax/src/js/input/tex/bbox/BboxConfiguration.js`),begingroup:()=>import(`@mathjax/src/js/input/tex/begingroup/BegingroupConfiguration.js`),boldsymbol:()=>import(`@mathjax/src/js/input/tex/boldsymbol/BoldsymbolConfiguration.js`),braket:()=>import(`@mathjax/src/js/input/tex/braket/BraketConfiguration.js`),bussproofs:()=>import(`@mathjax/src/js/input/tex/bussproofs/BussproofsConfiguration.js`),cancel:()=>import(`@mathjax/src/js/input/tex/cancel/CancelConfiguration.js`),cases:()=>import(`@mathjax/src/js/input/tex/cases/CasesConfiguration.js`),centernot:()=>import(`@mathjax/src/js/input/tex/centernot/CenternotConfiguration.js`),color:()=>import(`@mathjax/src/js/input/tex/color/ColorConfiguration.js`),colortbl:()=>import(`@mathjax/src/js/input/tex/colortbl/ColortblConfiguration.js`),colorv2:()=>import(`@mathjax/src/js/input/tex/colorv2/ColorV2Configuration.js`),configmacros:()=>import(`@mathjax/src/js/input/tex/configmacros/ConfigMacrosConfiguration.js`),dsfont:()=>import(`@mathjax/src/js/input/tex/dsfont/DsfontConfiguration.js`),empheq:()=>import(`@mathjax/src/js/input/tex/empheq/EmpheqConfiguration.js`),enclose:()=>import(`@mathjax/src/js/input/tex/enclose/EncloseConfiguration.js`),extpfeil:()=>import(`@mathjax/src/js/input/tex/extpfeil/ExtpfeilConfiguration.js`),gensymb:()=>import(`@mathjax/src/js/input/tex/gensymb/GensymbConfiguration.js`),html:()=>import(`@mathjax/src/js/input/tex/html/HtmlConfiguration.js`),mathtools:()=>import(`@mathjax/src/js/input/tex/mathtools/MathtoolsConfiguration.js`),mhchem:()=>import(`@mathjax/src/js/input/tex/mhchem/MhchemConfiguration.js`),newcommand:()=>import(`@mathjax/src/js/input/tex/newcommand/NewcommandConfiguration.js`),noerrors:()=>import(`@mathjax/src/js/input/tex/noerrors/NoErrorsConfiguration.js`),noundefined:()=>import(`@mathjax/src/js/input/tex/noundefined/NoUndefinedConfiguration.js`),physics:()=>import(`@mathjax/src/js/input/tex/physics/PhysicsConfiguration.js`),setoptions:()=>import(`@mathjax/src/js/input/tex/setoptions/SetOptionsConfiguration.js`),tagformat:()=>import(`@mathjax/src/js/input/tex/tagformat/TagFormatConfiguration.js`),texhtml:()=>import(`@mathjax/src/js/input/tex/texhtml/TexHtmlConfiguration.js`),textcomp:()=>import(`@mathjax/src/js/input/tex/textcomp/TextcompConfiguration.js`),textmacros:()=>import(`@mathjax/src/js/input/tex/textmacros/TextMacrosConfiguration.js`),unicode:()=>import(`@mathjax/src/js/input/tex/unicode/UnicodeConfiguration.js`),units:()=>import(`@mathjax/src/js/input/tex/units/UnitsConfiguration.js`),upgreek:()=>import(`@mathjax/src/js/input/tex/upgreek/UpgreekConfiguration.js`),verb:()=>import(`@mathjax/src/js/input/tex/verb/VerbConfiguration.js`)},r=async(e=t)=>{await import(`@mathjax/src/js/input/tex/base/BaseConfiguration.js`),await Promise.all(e.filter(e=>t.includes(e)).map(e=>n[e]()))},i=[{handler:`macro`,name:`new-Command`},{handler:`environment`,name:`new-Environment`},{handler:`delimiter`,name:`new-Delimiter`}],a=e=>{for(let{handler:t,name:n}of i)e.parseOptions.handlers.get(t).retrieve(n)?.map.clear()};let o,s,c,l,u,d,f,p,m,h=!0,g=!0;try{({mathjax:p}=await import(`@mathjax/src/js/mathjax.js`)),{TeX:u}=await import(`@mathjax/src/js/input/tex.js`),{CHTML:s}=await import(`@mathjax/src/js/output/chtml.js`),{SVG:l}=await import(`@mathjax/src/js/output/svg.js`),{liteAdaptor:f}=await import(`@mathjax/src/js/adaptors/liteAdaptor.js`),{RegisterHTMLHandler:c}=await import(`@mathjax/src/js/handlers/html.js`),{AssistiveMmlHandler:o}=await import(`@mathjax/src/js/a11y/assistive-mml.js`)}catch{h=!1}try{d=(await import(`@mathjax/mathjax-newcm-font/js/chtml.js`)).MathJaxNewcmFont,m=(await import(`@mathjax/mathjax-newcm-font/js/svg.js`)).MathJaxNewcmFont}catch{g=!1}const _=async e=>{if(!h)throw Error(`[@mdit/plugin-mathjax-slim] "@mathjax/src" is not installed!`);let n=e.output===`chtml`,i=(n?e.chtml:e.svg)??{};if(!i.fontData&&!g)throw Error(`[@mdit/plugin-mathjax-slim] "@mathjax/mathjax-newcm-font" is not installed!`);let a=Object.assign({fontData:n?d:m},i?.fontData?{}:{dynamicPrefix:`@mathjax/mathjax-newcm-font/js/${n?`chtml`:`svg`}/dynamic`},n&&!i.fontData?{fontURL:`https://cdn.jsdelivr.net/npm/@mathjax/mathjax-newcm-font/chtml/woff2`}:{},i);return p.asyncLoad=t=>(e.debug&&console.debug(`[MathJax]: loading ${t}...`),import(t)),await r(e.tex?.packages),{InputJax:new u({packages:[`base`,...t],...e.tex}),OutputJax:new(n?s:l)(a),enableAssistiveMml:e.a11y!==!1}},v=async(e={})=>{let t=await _(e),{OutputJax:n,InputJax:r}=t,i=f(),s=c(i);e.a11y!==!1&&o(s);let l=()=>{n.adaptor!=null&&(r.reset(),n.reset())};return{adaptor:i,documentOptions:t,allowInlineWithSpace:e.allowInlineWithSpace??!1,delimiters:e.delimiters??`dollars`,mathFence:e.mathFence??!1,clearStyle:l,reset:()=>{r.reset(),a(r)},outputStyle:async()=>{await n.font.loadDynamicFiles();let e=i.cssText(n.styleSheet(p.document(``,t)));return l(),e},transformer:e.transformer??null}},y=(t,{allowInlineWithSpace:n,adaptor:r,delimiters:i,documentOptions:a,mathFence:o,reset:s,transformer:c})=>{let l=t.render.bind(t),u=t.renderInline.bind(t);t.render=(e,t)=>{try{return l(e,t)}finally{s()}},t.renderInline=(e,t)=>{try{return u(e,t)}finally{s()}},t.use(e,{allowInlineWithSpace:n,delimiters:i,mathFence:o,render:(e,t)=>{let n=p.document(e,a).convert(e,{display:t}),i=r.outerHTML(n);return c?.(i,t)??i}})};export{v as createMathjaxInstance,_ as getDocumentOptions,y as mathjax};
1
+ import{tex as e}from"@mdit/plugin-tex";const t=/* @__PURE__ */ `action.ams.amscd.bbm.bboldx.bbox.begingroup.boldsymbol.braket.bussproofs.cancel.cases.centernot.color.colortbl.colorv2.configmacros.dsfont.empheq.enclose.extpfeil.gensymb.html.mathtools.mhchem.newcommand.noerrors.noundefined.physics.setoptions.tagformat.texhtml.textcomp.textmacros.unicode.units.upgreek.verb`.split(`.`),n={action:()=>import(`@mathjax/src/js/input/tex/action/ActionConfiguration.js`),ams:()=>import(`@mathjax/src/js/input/tex/ams/AmsConfiguration.js`),amscd:()=>import(`@mathjax/src/js/input/tex/amscd/AmsCdConfiguration.js`),bbm:()=>import(`@mathjax/src/js/input/tex/bbm/BbmConfiguration.js`),bboldx:()=>import(`@mathjax/src/js/input/tex/bboldx/BboldxConfiguration.js`),bbox:()=>import(`@mathjax/src/js/input/tex/bbox/BboxConfiguration.js`),begingroup:()=>import(`@mathjax/src/js/input/tex/begingroup/BegingroupConfiguration.js`),boldsymbol:()=>import(`@mathjax/src/js/input/tex/boldsymbol/BoldsymbolConfiguration.js`),braket:()=>import(`@mathjax/src/js/input/tex/braket/BraketConfiguration.js`),bussproofs:()=>import(`@mathjax/src/js/input/tex/bussproofs/BussproofsConfiguration.js`),cancel:()=>import(`@mathjax/src/js/input/tex/cancel/CancelConfiguration.js`),cases:()=>import(`@mathjax/src/js/input/tex/cases/CasesConfiguration.js`),centernot:()=>import(`@mathjax/src/js/input/tex/centernot/CenternotConfiguration.js`),color:()=>import(`@mathjax/src/js/input/tex/color/ColorConfiguration.js`),colortbl:()=>import(`@mathjax/src/js/input/tex/colortbl/ColortblConfiguration.js`),colorv2:()=>import(`@mathjax/src/js/input/tex/colorv2/ColorV2Configuration.js`),configmacros:()=>import(`@mathjax/src/js/input/tex/configmacros/ConfigMacrosConfiguration.js`),dsfont:()=>import(`@mathjax/src/js/input/tex/dsfont/DsfontConfiguration.js`),empheq:()=>import(`@mathjax/src/js/input/tex/empheq/EmpheqConfiguration.js`),enclose:()=>import(`@mathjax/src/js/input/tex/enclose/EncloseConfiguration.js`),extpfeil:()=>import(`@mathjax/src/js/input/tex/extpfeil/ExtpfeilConfiguration.js`),gensymb:()=>import(`@mathjax/src/js/input/tex/gensymb/GensymbConfiguration.js`),html:()=>import(`@mathjax/src/js/input/tex/html/HtmlConfiguration.js`),mathtools:()=>import(`@mathjax/src/js/input/tex/mathtools/MathtoolsConfiguration.js`),mhchem:()=>import(`@mathjax/src/js/input/tex/mhchem/MhchemConfiguration.js`),newcommand:()=>import(`@mathjax/src/js/input/tex/newcommand/NewcommandConfiguration.js`),noerrors:()=>import(`@mathjax/src/js/input/tex/noerrors/NoErrorsConfiguration.js`),noundefined:()=>import(`@mathjax/src/js/input/tex/noundefined/NoUndefinedConfiguration.js`),physics:()=>import(`@mathjax/src/js/input/tex/physics/PhysicsConfiguration.js`),setoptions:()=>import(`@mathjax/src/js/input/tex/setoptions/SetOptionsConfiguration.js`),tagformat:()=>import(`@mathjax/src/js/input/tex/tagformat/TagFormatConfiguration.js`),texhtml:()=>import(`@mathjax/src/js/input/tex/texhtml/TexHtmlConfiguration.js`),textcomp:()=>import(`@mathjax/src/js/input/tex/textcomp/TextcompConfiguration.js`),textmacros:()=>import(`@mathjax/src/js/input/tex/textmacros/TextMacrosConfiguration.js`),unicode:()=>import(`@mathjax/src/js/input/tex/unicode/UnicodeConfiguration.js`),units:()=>import(`@mathjax/src/js/input/tex/units/UnitsConfiguration.js`),upgreek:()=>import(`@mathjax/src/js/input/tex/upgreek/UpgreekConfiguration.js`),verb:()=>import(`@mathjax/src/js/input/tex/verb/VerbConfiguration.js`)},r=async(e=t)=>{await import(`@mathjax/src/js/input/tex/base/BaseConfiguration.js`),await Promise.all(e.filter(e=>t.includes(e)).map(e=>n[e]()))},i=[{handler:`macro`,name:`new-Command`},{handler:`environment`,name:`new-Environment`},{handler:`delimiter`,name:`new-Delimiter`}],a=e=>{for(let{handler:t,name:n}of i)e.parseOptions.handlers.get(t).retrieve(n)?.map.clear()};let o,s,c,l,u,d,f,p,m,h=!0,g=!0;try{({mathjax:p}=await import(`@mathjax/src/js/mathjax.js`)),{TeX:u}=await import(`@mathjax/src/js/input/tex.js`),{CHTML:s}=await import(`@mathjax/src/js/output/chtml.js`),{SVG:l}=await import(`@mathjax/src/js/output/svg.js`),{liteAdaptor:f}=await import(`@mathjax/src/js/adaptors/liteAdaptor.js`),{RegisterHTMLHandler:c}=await import(`@mathjax/src/js/handlers/html.js`),{AssistiveMmlHandler:o}=await import(`@mathjax/src/js/a11y/assistive-mml.js`)}catch{
2
+ /* istanbul ignore next -- @preserve */
3
+ h=!1}try{d=(await import(`@mathjax/mathjax-newcm-font/js/chtml.js`)).MathJaxNewcmFont,m=(await import(`@mathjax/mathjax-newcm-font/js/svg.js`)).MathJaxNewcmFont}catch{
4
+ /* istanbul ignore next -- @preserve */
5
+ g=!1}const _=async e=>{
6
+ /* istanbul ignore if -- @preserve */
7
+ if(!h)throw Error(`[@mdit/plugin-mathjax-slim] "@mathjax/src" is not installed!`);let n=e.output===`chtml`,i=(n?e.chtml:e.svg)??{};
8
+ /* istanbul ignore if -- @preserve */
9
+ if(!i.fontData&&!g)throw Error(`[@mdit/plugin-mathjax-slim] "@mathjax/mathjax-newcm-font" is not installed!`);let a=Object.assign({fontData:n?d:m},i?.fontData?{}:{dynamicPrefix:`@mathjax/mathjax-newcm-font/js/${n?`chtml`:`svg`}/dynamic`},n&&!i.fontData?{fontURL:`https://cdn.jsdelivr.net/npm/@mathjax/mathjax-newcm-font/chtml/woff2`}:{},i);return p.asyncLoad=t=>(e.debug&&console.debug(`[MathJax]: loading ${t}...`),import(t)),await r(e.tex?.packages),{InputJax:new u({packages:[`base`,...t],...e.tex}),OutputJax:new(n?s:l)(a),enableAssistiveMml:e.a11y!==!1}},v=async(e={})=>{let t=await _(e),{OutputJax:n,InputJax:r}=t,i=f(),s=c(i);e.a11y!==!1&&o(s);let l=()=>{n.adaptor!=null&&(r.reset(),n.reset())};return{adaptor:i,documentOptions:t,allowInlineWithSpace:e.allowInlineWithSpace??!1,delimiters:e.delimiters??`dollars`,mathFence:e.mathFence??!1,clearStyle:l,reset:()=>{r.reset(),a(r)},outputStyle:async()=>{await n.font.loadDynamicFiles();let e=i.cssText(n.styleSheet(p.document(``,t)));return l(),e},transformer:e.transformer??null}},y=(t,{allowInlineWithSpace:n,adaptor:r,delimiters:i,documentOptions:a,mathFence:o,reset:s,transformer:c})=>{let l=t.render.bind(t),u=t.renderInline.bind(t);t.render=(e,t)=>{try{return l(e,t)}finally{s()}},t.renderInline=(e,t)=>{try{return u(e,t)}finally{s()}},t.use(e,{allowInlineWithSpace:n,delimiters:i,mathFence:o,render:(e,t)=>{let n=p.document(e,a).convert(e,{display:t}),i=r.outerHTML(n);return c?.(i,t)??i}})};export{v as createMathjaxInstance,_ as getDocumentOptions,y as mathjax};
2
10
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/tex/packages.ts","../src/tex/loader.ts","../src/tex/utils.ts","../src/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","import type { LiteElement } from \"@mathjax/src/js/adaptors/lite/Element.js\";\nimport type { TeX } from \"@mathjax/src/js/input/tex.js\";\nimport type { HandlerType } from \"@mathjax/src/js/input/tex/HandlerTypes.js\";\n\ninterface TeXMacroMap {\n map: Map<string, unknown>;\n}\n\nconst USER_MAPS: { handler: HandlerType; name: string }[] = [\n { handler: \"macro\" as HandlerType.MACRO, name: \"new-Command\" },\n { handler: \"environment\" as HandlerType.ENVIRONMENT, name: \"new-Environment\" },\n { handler: \"delimiter\" as HandlerType.DELIMITER, name: \"new-Delimiter\" },\n];\n\n/**\n * Clear user-defined TeX state (macros/environments/delimiters) on a MathJax TeX input jax.\n *\n * MathJax stores user-defined macros, environments and delimiters in dedicated `new-*` maps that\n * are separate from the built-in maps, and `InputJax.reset()` does not clear them, so they would\n * leak across documents rendered by the same instance. This reaches into the internal maps to\n * remove only user-defined entries.\n *\n * 清除 MathJax TeX 输入 jax 上由 `\\newcommand`/`\\def`/`\\newenvironment` 等定义的用户状态。\n *\n * MathJax 将用户自定义的宏、环境与分隔符存放在独立的 `new-*` 映射中,与内置映射分离,且 `InputJax.reset()`\n * 不会清除它们,因此同一实例渲染多篇文档时状态会跨文档泄漏。此处直接访问内部映射,仅移除用户自定义条目。\n *\n * @param InputJax - MathJax TeX input jax / MathJax TeX 输入 jax\n */\nexport const clearUserState = (InputJax: TeX<LiteElement, string, HTMLElement>): void => {\n for (const { handler, name } of USER_MAPS) {\n const handlerMap = InputJax.parseOptions.handlers.get(handler);\n const userMap = handlerMap.retrieve(name) as unknown as TeXMacroMap | null;\n\n userMap?.map.clear();\n }\n};\n","/** Forked from https://github.com/tani/markdown-it-mathjax3/blob/master/index.ts */\n\nimport type { MathJaxNewcmFont as chtmlFontType } from \"@mathjax/mathjax-newcm-font/js/chtml.js\";\nimport type { MathJaxNewcmFont as svgFontType } from \"@mathjax/mathjax-newcm-font/js/svg.js\";\nimport type { AssistiveMmlHandler as AssistiveMmlHandlerType } from \"@mathjax/src/js/a11y/assistive-mml.js\";\nimport type { LiteDocument } from \"@mathjax/src/js/adaptors/lite/Document.js\";\nimport type { LiteElement, LiteNode } from \"@mathjax/src/js/adaptors/lite/Element.js\";\nimport type { LiteText } from \"@mathjax/src/js/adaptors/lite/Text.js\";\nimport type { liteAdaptor as liteAdaptorType } from \"@mathjax/src/js/adaptors/liteAdaptor.js\";\nimport type { MathDocument } from \"@mathjax/src/js/core/MathDocument.js\";\nimport type { RegisterHTMLHandler as RegisterHTMLHandlerType } from \"@mathjax/src/js/handlers/html.js\";\nimport type { TeX as TeXType } from \"@mathjax/src/js/input/tex.js\";\nimport type { mathjax as mathjaxType } from \"@mathjax/src/js/mathjax.js\";\nimport type { CHTML as CHTMLType } from \"@mathjax/src/js/output/chtml.js\";\nimport type { SVG as SVGType } from \"@mathjax/src/js/output/svg.js\";\nimport { tex } from \"@mdit/plugin-tex\";\nimport type { MarkdownIt } from \"markdown-it\";\n\nimport type { MarkdownItMathjaxOptions, DocumentOptions, MathjaxInstance } from \"./options.js\";\nimport { loadTexPackages, texPackages } from \"./tex/index.js\";\nimport { clearUserState } from \"./utils.js\";\n\nlet AssistiveMmlHandler: typeof AssistiveMmlHandlerType,\n CHTML: typeof CHTMLType,\n RegisterHTMLHandler: typeof RegisterHTMLHandlerType,\n SVG: typeof SVGType,\n TeX: typeof TeXType,\n chtmlFont: typeof chtmlFontType,\n liteAdaptor: typeof liteAdaptorType,\n mathjaxLib: typeof mathjaxType,\n svgFont: typeof svgFontType;\nlet isMathJaxInstalled = true;\nlet isMathJaxNewcmFontInstalled = true;\n\ntry {\n ({ mathjax: mathjaxLib } = await import(\"@mathjax/src/js/mathjax.js\"));\n ({ TeX } = await import(\"@mathjax/src/js/input/tex.js\"));\n ({ CHTML } = await import(\"@mathjax/src/js/output/chtml.js\"));\n ({ SVG } = await import(\"@mathjax/src/js/output/svg.js\"));\n ({ liteAdaptor } = await import(\"@mathjax/src/js/adaptors/liteAdaptor.js\"));\n ({ RegisterHTMLHandler } = await import(\"@mathjax/src/js/handlers/html.js\"));\n ({ AssistiveMmlHandler } = await import(\"@mathjax/src/js/a11y/assistive-mml.js\"));\n} catch {\n /* istanbul ignore next -- @preserve */\n isMathJaxInstalled = false;\n}\n\ntry {\n chtmlFont = (await import(\"@mathjax/mathjax-newcm-font/js/chtml.js\")).MathJaxNewcmFont;\n svgFont = (await import(\"@mathjax/mathjax-newcm-font/js/svg.js\")).MathJaxNewcmFont;\n} catch {\n /* istanbul ignore next -- @preserve */\n isMathJaxNewcmFontInstalled = false;\n}\n\nexport const getDocumentOptions = async (\n options: MarkdownItMathjaxOptions,\n): Promise<DocumentOptions> => {\n /* istanbul ignore if -- @preserve */\n if (!isMathJaxInstalled)\n throw new Error('[@mdit/plugin-mathjax-slim] \"@mathjax/src\" is not installed!');\n\n const isCHTML = options.output === \"chtml\";\n const userOptions = (isCHTML ? options.chtml : options.svg) ?? {};\n\n /* istanbul ignore if -- @preserve */\n if (!userOptions.fontData && !isMathJaxNewcmFontInstalled)\n throw new Error('[@mdit/plugin-mathjax-slim] \"@mathjax/mathjax-newcm-font\" is not installed!');\n\n const outputOptions = Object.assign(\n {\n fontData: isCHTML ? chtmlFont : svgFont,\n },\n // fontURL can be set to undefined if you want to bundle the fonts yourself\n // both fontURL and dynamicPrefix shall be synced with fontData, so set it to undefined if fontData is customized\n userOptions?.fontData\n ? {}\n : { dynamicPrefix: `@mathjax/mathjax-newcm-font/js/${isCHTML ? \"chtml\" : \"svg\"}/dynamic` },\n isCHTML && !userOptions.fontData\n ? { fontURL: \"https://cdn.jsdelivr.net/npm/@mathjax/mathjax-newcm-font/chtml/woff2\" }\n : {},\n userOptions,\n );\n\n mathjaxLib.asyncLoad = (file): Promise<unknown> => {\n if (options.debug)\n // oxlint-disable-next-line no-console\n console.debug(`[MathJax]: loading ${file}...`);\n\n return import(file);\n };\n\n await loadTexPackages(options.tex?.packages);\n\n return {\n InputJax: new TeX<LiteElement, string, HTMLElement>({\n packages: [\"base\", ...texPackages],\n ...options.tex,\n }),\n OutputJax: new (isCHTML ? CHTML : SVG)<LiteElement, string, HTMLElement>(outputOptions),\n enableAssistiveMml: options.a11y !== false,\n };\n};\n\nexport const createMathjaxInstance = async (\n options: MarkdownItMathjaxOptions = {},\n): Promise<MathjaxInstance | null> => {\n const documentOptions = await getDocumentOptions(options);\n\n const { OutputJax, InputJax } = documentOptions;\n\n const adaptor = liteAdaptor();\n // oxlint-disable-next-line new-cap\n const handler = RegisterHTMLHandler(adaptor);\n\n // oxlint-disable-next-line new-cap\n if (options.a11y !== false) AssistiveMmlHandler<LiteNode, LiteText, LiteDocument>(handler);\n\n const clearStyle = (): void => {\n // if there is no adaptor, output jax is not initialized yet, so nothing to clear\n if (OutputJax.adaptor == null) return;\n\n InputJax.reset();\n OutputJax.reset();\n };\n\n const reset = (): void => {\n InputJax.reset();\n clearUserState(InputJax);\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 reset,\n transformer,\n }: MathjaxInstance,\n): void => {\n // Reset the shared TeX input state (macros/labels) after each render so that\n // state does not leak across documents rendered by the same instance.\n const render = md.render.bind(md);\n const renderInline = md.renderInline.bind(md);\n\n md.render = (src, env): string => {\n try {\n return render(src, env);\n } finally {\n reset();\n }\n };\n md.renderInline = (src, env): string => {\n try {\n return renderInline(src, env);\n } finally {\n reset();\n }\n };\n\n md.use(tex, {\n allowInlineWithSpace,\n delimiters,\n mathFence,\n render: (content, displayMode) => {\n const mathDocument = mathjaxLib.document(content, documentOptions).convert(content, {\n display: displayMode,\n }) as LiteElement;\n\n const result = adaptor.outerHTML(mathDocument);\n\n return transformer?.(result, displayMode) ?? result;\n },\n });\n};\n"],"mappings":"uCAEA,MAAa,EAA4B,gUAuCzC,ECvCa,EAAyD,CACpE,WAAc,OAAO,2DACrB,QAAW,OAAO,qDAClB,UAAa,OAAO,yDACpB,QAAW,OAAO,qDAClB,WAAc,OAAO,2DACrB,SAAY,OAAO,uDACnB,eAAkB,OAAO,mEACzB,eAAkB,OAAO,mEACzB,WAAc,OAAO,2DACrB,eAAkB,OAAO,mEACzB,WAAc,OAAO,2DACrB,UAAa,OAAO,yDACpB,cAAiB,OAAO,iEACxB,UAAa,OAAO,yDACpB,aAAgB,OAAO,+DACvB,YAAe,OAAO,6DACtB,iBAAoB,OAAO,uEAC3B,WAAc,OAAO,2DACrB,WAAc,OAAO,2DACrB,YAAe,OAAO,6DACtB,aAAgB,OAAO,+DACvB,YAAe,OAAO,6DACtB,SAAY,OAAO,uDACnB,cAAiB,OAAO,iEACxB,WAAc,OAAO,2DACrB,eAAkB,OAAO,mEACzB,aAAgB,OAAO,+DACvB,gBAAmB,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CACT,EAWE,YAAa,EAAQ,aAAe,IACtC,CACF,EAEa,GACX,EACA,CACE,uBACA,UACA,aACA,kBACA,YACA,QACA,iBAEO,CAGT,IAAM,EAAS,EAAG,OAAO,KAAK,CAAE,EAC1B,EAAe,EAAG,aAAa,KAAK,CAAE,EAE5C,EAAG,QAAU,EAAK,IAAgB,CAChC,GAAI,CACF,OAAO,EAAO,EAAK,CAAG,CACxB,QAAU,CACR,EAAM,CACR,CACF,EACA,EAAG,cAAgB,EAAK,IAAgB,CACtC,GAAI,CACF,OAAO,EAAa,EAAK,CAAG,CAC9B,QAAU,CACR,EAAM,CACR,CACF,EAEA,EAAG,IAAI,EAAK,CACV,uBACA,aACA,YACA,QAAS,EAAS,IAAgB,CAChC,IAAM,EAAe,EAAW,SAAS,EAAS,CAAe,CAAC,CAAC,QAAQ,EAAS,CAClF,QAAS,CACX,CAAC,EAEK,EAAS,EAAQ,UAAU,CAAY,EAE7C,OAAO,IAAc,EAAQ,CAAW,GAAK,CAC/C,CACF,CAAC,CACH"}
1
+ {"version":3,"file":"index.js","names":["texPackages","texLoaders","loadTexPackages","packages","pkg","USER_MAPS","clearUserState","InputJax","handler","name","AssistiveMmlHandler","CHTML","RegisterHTMLHandler","SVG","TeX","chtmlFont","liteAdaptor","mathjaxLib","svgFont","isMathJaxInstalled","isMathJaxNewcmFontInstalled","getDocumentOptions","isCHTML","options","userOptions","outputOptions","file","createMathjaxInstance","documentOptions","adaptor","clearStyle","OutputJax","style","mathjax","render","md","renderInline","src","env","reset","tex","mathDocument","content","displayMode","result","transformer"],"sources":["../src/tex/packages.ts","../src/tex/loader.ts","../src/tex/utils.ts","../src/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","import type { LiteElement } from \"@mathjax/src/js/adaptors/lite/Element.js\";\nimport type { TeX } from \"@mathjax/src/js/input/tex.js\";\nimport type { HandlerType } from \"@mathjax/src/js/input/tex/HandlerTypes.js\";\n\ninterface TeXMacroMap {\n map: Map<string, unknown>;\n}\n\nconst USER_MAPS: { handler: HandlerType; name: string }[] = [\n { handler: \"macro\" as HandlerType.MACRO, name: \"new-Command\" },\n { handler: \"environment\" as HandlerType.ENVIRONMENT, name: \"new-Environment\" },\n { handler: \"delimiter\" as HandlerType.DELIMITER, name: \"new-Delimiter\" },\n];\n\n/**\n * Clear user-defined TeX state (macros/environments/delimiters) on a MathJax TeX input jax.\n *\n * MathJax stores user-defined macros, environments and delimiters in dedicated `new-*` maps that\n * are separate from the built-in maps, and `InputJax.reset()` does not clear them, so they would\n * leak across documents rendered by the same instance. This reaches into the internal maps to\n * remove only user-defined entries.\n *\n * 清除 MathJax TeX 输入 jax 上由 `\\newcommand`/`\\def`/`\\newenvironment` 等定义的用户状态。\n *\n * MathJax 将用户自定义的宏、环境与分隔符存放在独立的 `new-*` 映射中,与内置映射分离,且 `InputJax.reset()`\n * 不会清除它们,因此同一实例渲染多篇文档时状态会跨文档泄漏。此处直接访问内部映射,仅移除用户自定义条目。\n *\n * @param InputJax - MathJax TeX input jax / MathJax TeX 输入 jax\n */\nexport const clearUserState = (InputJax: TeX<LiteElement, string, HTMLElement>): void => {\n for (const { handler, name } of USER_MAPS) {\n const handlerMap = InputJax.parseOptions.handlers.get(handler);\n const userMap = handlerMap.retrieve(name) as unknown as TeXMacroMap | null;\n\n userMap?.map.clear();\n }\n};\n","/** Forked from https://github.com/tani/markdown-it-mathjax3/blob/master/index.ts */\n\nimport type { MathJaxNewcmFont as chtmlFontType } from \"@mathjax/mathjax-newcm-font/js/chtml.js\";\nimport type { MathJaxNewcmFont as svgFontType } from \"@mathjax/mathjax-newcm-font/js/svg.js\";\nimport type { AssistiveMmlHandler as AssistiveMmlHandlerType } from \"@mathjax/src/js/a11y/assistive-mml.js\";\nimport type { LiteDocument } from \"@mathjax/src/js/adaptors/lite/Document.js\";\nimport type { LiteElement, LiteNode } from \"@mathjax/src/js/adaptors/lite/Element.js\";\nimport type { LiteText } from \"@mathjax/src/js/adaptors/lite/Text.js\";\nimport type { liteAdaptor as liteAdaptorType } from \"@mathjax/src/js/adaptors/liteAdaptor.js\";\nimport type { MathDocument } from \"@mathjax/src/js/core/MathDocument.js\";\nimport type { RegisterHTMLHandler as RegisterHTMLHandlerType } from \"@mathjax/src/js/handlers/html.js\";\nimport type { TeX as TeXType } from \"@mathjax/src/js/input/tex.js\";\nimport type { mathjax as mathjaxType } from \"@mathjax/src/js/mathjax.js\";\nimport type { CHTML as CHTMLType } from \"@mathjax/src/js/output/chtml.js\";\nimport type { SVG as SVGType } from \"@mathjax/src/js/output/svg.js\";\nimport { tex } from \"@mdit/plugin-tex\";\nimport type { MarkdownIt } from \"markdown-it\";\n\nimport type { MarkdownItMathjaxOptions, DocumentOptions, MathjaxInstance } from \"./options.js\";\nimport { loadTexPackages, texPackages } from \"./tex/index.js\";\nimport { clearUserState } from \"./utils.js\";\n\nlet AssistiveMmlHandler: typeof AssistiveMmlHandlerType,\n CHTML: typeof CHTMLType,\n RegisterHTMLHandler: typeof RegisterHTMLHandlerType,\n SVG: typeof SVGType,\n TeX: typeof TeXType,\n chtmlFont: typeof chtmlFontType,\n liteAdaptor: typeof liteAdaptorType,\n mathjaxLib: typeof mathjaxType,\n svgFont: typeof svgFontType;\nlet isMathJaxInstalled = true;\nlet isMathJaxNewcmFontInstalled = true;\n\ntry {\n ({ mathjax: mathjaxLib } = await import(\"@mathjax/src/js/mathjax.js\"));\n ({ TeX } = await import(\"@mathjax/src/js/input/tex.js\"));\n ({ CHTML } = await import(\"@mathjax/src/js/output/chtml.js\"));\n ({ SVG } = await import(\"@mathjax/src/js/output/svg.js\"));\n ({ liteAdaptor } = await import(\"@mathjax/src/js/adaptors/liteAdaptor.js\"));\n ({ RegisterHTMLHandler } = await import(\"@mathjax/src/js/handlers/html.js\"));\n ({ AssistiveMmlHandler } = await import(\"@mathjax/src/js/a11y/assistive-mml.js\"));\n} catch {\n /* istanbul ignore next -- @preserve */\n isMathJaxInstalled = false;\n}\n\ntry {\n chtmlFont = (await import(\"@mathjax/mathjax-newcm-font/js/chtml.js\")).MathJaxNewcmFont;\n svgFont = (await import(\"@mathjax/mathjax-newcm-font/js/svg.js\")).MathJaxNewcmFont;\n} catch {\n /* istanbul ignore next -- @preserve */\n isMathJaxNewcmFontInstalled = false;\n}\n\nexport const getDocumentOptions = async (\n options: MarkdownItMathjaxOptions,\n): Promise<DocumentOptions> => {\n /* istanbul ignore if -- @preserve */\n if (!isMathJaxInstalled)\n throw new Error('[@mdit/plugin-mathjax-slim] \"@mathjax/src\" is not installed!');\n\n const isCHTML = options.output === \"chtml\";\n const userOptions = (isCHTML ? options.chtml : options.svg) ?? {};\n\n /* istanbul ignore if -- @preserve */\n if (!userOptions.fontData && !isMathJaxNewcmFontInstalled)\n throw new Error('[@mdit/plugin-mathjax-slim] \"@mathjax/mathjax-newcm-font\" is not installed!');\n\n const outputOptions = Object.assign(\n {\n fontData: isCHTML ? chtmlFont : svgFont,\n },\n // fontURL can be set to undefined if you want to bundle the fonts yourself\n // both fontURL and dynamicPrefix shall be synced with fontData, so set it to undefined if fontData is customized\n userOptions?.fontData\n ? {}\n : { dynamicPrefix: `@mathjax/mathjax-newcm-font/js/${isCHTML ? \"chtml\" : \"svg\"}/dynamic` },\n isCHTML && !userOptions.fontData\n ? { fontURL: \"https://cdn.jsdelivr.net/npm/@mathjax/mathjax-newcm-font/chtml/woff2\" }\n : {},\n userOptions,\n );\n\n mathjaxLib.asyncLoad = (file): Promise<unknown> => {\n if (options.debug)\n // oxlint-disable-next-line no-console\n console.debug(`[MathJax]: loading ${file}...`);\n\n return import(file);\n };\n\n await loadTexPackages(options.tex?.packages);\n\n return {\n InputJax: new TeX<LiteElement, string, HTMLElement>({\n packages: [\"base\", ...texPackages],\n ...options.tex,\n }),\n OutputJax: new (isCHTML ? CHTML : SVG)<LiteElement, string, HTMLElement>(outputOptions),\n enableAssistiveMml: options.a11y !== false,\n };\n};\n\nexport const createMathjaxInstance = async (\n options: MarkdownItMathjaxOptions = {},\n): Promise<MathjaxInstance | null> => {\n const documentOptions = await getDocumentOptions(options);\n\n const { OutputJax, InputJax } = documentOptions;\n\n const adaptor = liteAdaptor();\n // oxlint-disable-next-line new-cap\n const handler = RegisterHTMLHandler(adaptor);\n\n // oxlint-disable-next-line new-cap\n if (options.a11y !== false) AssistiveMmlHandler<LiteNode, LiteText, LiteDocument>(handler);\n\n const clearStyle = (): void => {\n // if there is no adaptor, output jax is not initialized yet, so nothing to clear\n if (OutputJax.adaptor == null) return;\n\n InputJax.reset();\n OutputJax.reset();\n };\n\n const reset = (): void => {\n InputJax.reset();\n clearUserState(InputJax);\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 reset,\n transformer,\n }: MathjaxInstance,\n): void => {\n // Reset the shared TeX input state (macros/labels) after each render so that\n // state does not leak across documents rendered by the same instance.\n const render = md.render.bind(md);\n const renderInline = md.renderInline.bind(md);\n\n md.render = (src, env): string => {\n try {\n return render(src, env);\n } finally {\n reset();\n }\n };\n md.renderInline = (src, env): string => {\n try {\n return renderInline(src, env);\n } finally {\n reset();\n }\n };\n\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,MAAaA,EAA4B,gVAuCzC,ECvCaC,EAAyD,CACpE,WAAc,OAAO,2DACrB,QAAW,OAAO,qDAClB,UAAa,OAAO,yDACpB,QAAW,OAAO,qDAClB,WAAc,OAAO,2DACrB,SAAY,OAAO,uDACnB,eAAkB,OAAO,mEACzB,eAAkB,OAAO,mEACzB,WAAc,OAAO,2DACrB,eAAkB,OAAO,mEACzB,WAAc,OAAO,2DACrB,UAAa,OAAO,yDACpB,cAAiB,OAAO,iEACxB,UAAa,OAAO,yDACpB,aAAgB,OAAO,+DACvB,YAAe,OAAO,6DACtB,iBAAoB,OAAO,uEAC3B,WAAc,OAAO,2DACrB,WAAc,OAAO,2DACrB,YAAe,OAAO,6DACtB,aAAgB,OAAO,+DACvB,YAAe,OAAO,6DACtB,SAAY,OAAO,uDACnB,cAAiB,OAAO,iEACxB,WAAc,OAAO,2DACrB,eAAkB,OAAO,mEACzB,aAAgB,OAAO,+DACvB,gBAAmB,OAAO,qEAC1B,YAAe,OAAO,6DACtB,eAAkB,OAAO,mEACzB,cAAiB,OAAO,iEACxB,YAAe,OAAO,6DACtB,aAAgB,OAAO,+DACvB,eAAkB,OAAO,mEACzB,YAAe,OAAO,6DACtB,UAAa,OAAO,yDACpB,YAAe,OAA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A,kBACA,YACA,QACA,iBAEO,CAGT,IAAMC,EAASC,EAAG,OAAO,KAAKA,CAAE,EAC1BC,EAAeD,EAAG,aAAa,KAAKA,CAAE,EAE5C,EAAG,QAAU,EAAK,IAAgB,CAChC,GAAI,CACF,OAAOD,EAAOG,EAAKC,CAAG,CACxB,QAAU,CACRC,EAAM,CACR,CACF,EACA,EAAG,cAAgB,EAAK,IAAgB,CACtC,GAAI,CACF,OAAOH,EAAaC,EAAKC,CAAG,CAC9B,QAAU,CACRC,EAAM,CACR,CACF,EAEAJ,EAAG,IAAIK,EAAK,CACV,uBACA,aACA,YACA,QAAS,EAAS,IAAgB,CAChC,IAAMC,EAAexB,EAAW,SAASyB,EAASd,CAAe,CAAC,CAAC,QAAQc,EAAS,CAClF,QAASC,CACX,CAAC,EAEKC,EAASf,EAAQ,UAAUY,CAAY,EAE7C,OAAOI,IAAcD,EAAQD,CAAW,GAAKC,CAC/C,CACF,CAAC,CACH"}
package/dist/sync-node.js CHANGED
@@ -1,2 +1,10 @@
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(`.`),r=[{handler:`macro`,name:`new-Command`},{handler:`environment`,name:`new-Environment`},{handler:`delimiter`,name:`new-Delimiter`}],i=e=>{for(let{handler:t,name:n}of r)e.parseOptions.handlers.get(t).retrieve(n)?.map.clear()};let a=!0,o,s,c,l,u,d,f,p=!0,m,h;const g=e(import.meta.url);try{({mathjax:f}=await import(`@mathjax/src/js/mathjax.js`)),[{TeX:u},{CHTML:s},{SVG:l},{liteAdaptor:d},{RegisterHTMLHandler:c},{AssistiveMmlHandler:o}]=await Promise.all([import(`@mathjax/src/js/input/tex.js`),import(`@mathjax/src/js/output/chtml.js`),import(`@mathjax/src/js/output/svg.js`),import(`@mathjax/src/js/adaptors/liteAdaptor.js`),import(`@mathjax/src/js/handlers/html.js`),import(`@mathjax/src/js/a11y/assistive-mml.js`),import(`@mathjax/src/js/input/tex/action/ActionConfiguration.js`),import(`@mathjax/src/js/input/tex/ams/AmsConfiguration.js`),import(`@mathjax/src/js/input/tex/amscd/AmsCdConfiguration.js`),import(`@mathjax/src/js/input/tex/base/BaseConfiguration.js`),import(`@mathjax/src/js/input/tex/bbm/BbmConfiguration.js`),import(`@mathjax/src/js/input/tex/bboldx/BboldxConfiguration.js`),import(`@mathjax/src/js/input/tex/bbox/BboxConfiguration.js`),import(`@mathjax/src/js/input/tex/begingroup/BegingroupConfiguration.js`),import(`@mathjax/src/js/input/tex/boldsymbol/BoldsymbolConfiguration.js`),import(`@mathjax/src/js/input/tex/braket/BraketConfiguration.js`),import(`@mathjax/src/js/input/tex/bussproofs/BussproofsConfiguration.js`),import(`@mathjax/src/js/input/tex/cancel/CancelConfiguration.js`),import(`@mathjax/src/js/input/tex/cases/CasesConfiguration.js`),import(`@mathjax/src/js/input/tex/centernot/CenternotConfiguration.js`),import(`@mathjax/src/js/input/tex/color/ColorConfiguration.js`),import(`@mathjax/src/js/input/tex/colortbl/ColortblConfiguration.js`),import(`@mathjax/src/js/input/tex/colorv2/ColorV2Configuration.js`),import(`@mathjax/src/js/input/tex/configmacros/ConfigMacrosConfiguration.js`),import(`@mathjax/src/js/input/tex/dsfont/DsfontConfiguration.js`),import(`@mathjax/src/js/input/tex/empheq/EmpheqConfiguration.js`),import(`@mathjax/src/js/input/tex/enclose/EncloseConfiguration.js`),import(`@mathjax/src/js/input/tex/extpfeil/ExtpfeilConfiguration.js`),import(`@mathjax/src/js/input/tex/gensymb/GensymbConfiguration.js`),import(`@mathjax/src/js/input/tex/html/HtmlConfiguration.js`),import(`@mathjax/src/js/input/tex/mathtools/MathtoolsConfiguration.js`),import(`@mathjax/src/js/input/tex/mhchem/MhchemConfiguration.js`),import(`@mathjax/src/js/input/tex/newcommand/NewcommandConfiguration.js`),import(`@mathjax/src/js/input/tex/noerrors/NoErrorsConfiguration.js`),import(`@mathjax/src/js/input/tex/noundefined/NoUndefinedConfiguration.js`),import(`@mathjax/src/js/input/tex/physics/PhysicsConfiguration.js`),import(`@mathjax/src/js/input/tex/setoptions/SetOptionsConfiguration.js`),import(`@mathjax/src/js/input/tex/tagformat/TagFormatConfiguration.js`),import(`@mathjax/src/js/input/tex/texhtml/TexHtmlConfiguration.js`),import(`@mathjax/src/js/input/tex/textcomp/TextcompConfiguration.js`),import(`@mathjax/src/js/input/tex/textmacros/TextMacrosConfiguration.js`),import(`@mathjax/src/js/input/tex/unicode/UnicodeConfiguration.js`),import(`@mathjax/src/js/input/tex/units/UnitsConfiguration.js`),import(`@mathjax/src/js/input/tex/upgreek/UpgreekConfiguration.js`),import(`@mathjax/src/js/input/tex/verb/VerbConfiguration.js`)]),f.asyncIsSynchronous=!0}catch{a=!1}try{m=(await import(`@mathjax/mathjax-newcm-font/js/chtml.js`)).MathJaxNewcmFont,h=(await import(`@mathjax/mathjax-newcm-font/js/svg.js`)).MathJaxNewcmFont}catch{p=!1}const _=e=>{if(!a)throw Error(`[@mdit/plugin-mathjax-slim] "@mathjax/src" is not installed!`);let t=e.output===`chtml`,r=(t?e.chtml:e.svg)??{};if(!r.fontData&&!p)throw Error(`[@mdit/plugin-mathjax-slim] "@mathjax/mathjax-newcm-font" is not installed!`);let i=Object.assign({fontData:t?m:h},r?.fontData?{}:{dynamicPrefix:`@mathjax/mathjax-newcm-font/js/${t?`chtml`:`svg`}/dynamic`},t&&!r.fontData?{fontURL:`https://cdn.jsdelivr.net/npm/@mathjax/mathjax-newcm-font/chtml/woff2`}:{},r);return f.asyncLoad=t=>{e.debug&&console.debug(`[MathJax]: sync loading ${t}...`),g(t)},{InputJax:new u({packages:[`base`,...n],...e.tex}),OutputJax:new(t?s:l)(i),enableAssistiveMml:e.a11y!==!1}},v=(e={})=>{let t=_(e),{OutputJax:n,InputJax:r}=t,a=d(),s=c(a);e.a11y!==!1&&o(s);let l=()=>{n.adaptor!=null&&(r.reset(),n.reset())};return{adaptor:a,documentOptions:t,allowInlineWithSpace:e.allowInlineWithSpace??!1,delimiters:e.delimiters??`dollars`,mathFence:e.mathFence??!1,clearStyle:l,reset:()=>{r.reset(),i(r)},outputStyle:()=>{n.font.loadDynamicFilesSync();let e=a.cssText(n.styleSheet(f.document(``,t)));return l(),e},transformer:e.transformer??null}},y=(e,{allowInlineWithSpace:n,adaptor:r,delimiters:i,documentOptions:a,mathFence:o,reset:s,transformer:c})=>{let l=e.render.bind(e),u=e.renderInline.bind(e);e.render=(e,t)=>{try{return l(e,t)}finally{s()}},e.renderInline=(e,t)=>{try{return u(e,t)}finally{s()}},e.use(t,{allowInlineWithSpace:n,delimiters:i,mathFence:o,render:(e,t)=>{let n=f.document(e,a).convert(e,{display:t}),i=r.outerHTML(n);return c?.(i,t)??i}})};export{v as createMathjaxInstance,_ as getDocumentOptions,y as mathjax};
1
+ import{createRequire as e}from"node:module";import{tex as t}from"@mdit/plugin-tex";const n=/* @__PURE__ */ `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(`.`),r=[{handler:`macro`,name:`new-Command`},{handler:`environment`,name:`new-Environment`},{handler:`delimiter`,name:`new-Delimiter`}],i=e=>{for(let{handler:t,name:n}of r)e.parseOptions.handlers.get(t).retrieve(n)?.map.clear()};let a=!0,o,s,c,l,u,d,f,p=!0,m,h;const g=e(import.meta.url);try{({mathjax:f}=await import(`@mathjax/src/js/mathjax.js`)),[{TeX:u},{CHTML:s},{SVG:l},{liteAdaptor:d},{RegisterHTMLHandler:c},{AssistiveMmlHandler:o}]=await Promise.all([import(`@mathjax/src/js/input/tex.js`),import(`@mathjax/src/js/output/chtml.js`),import(`@mathjax/src/js/output/svg.js`),import(`@mathjax/src/js/adaptors/liteAdaptor.js`),import(`@mathjax/src/js/handlers/html.js`),import(`@mathjax/src/js/a11y/assistive-mml.js`),import(`@mathjax/src/js/input/tex/action/ActionConfiguration.js`),import(`@mathjax/src/js/input/tex/ams/AmsConfiguration.js`),import(`@mathjax/src/js/input/tex/amscd/AmsCdConfiguration.js`),import(`@mathjax/src/js/input/tex/base/BaseConfiguration.js`),import(`@mathjax/src/js/input/tex/bbm/BbmConfiguration.js`),import(`@mathjax/src/js/input/tex/bboldx/BboldxConfiguration.js`),import(`@mathjax/src/js/input/tex/bbox/BboxConfiguration.js`),import(`@mathjax/src/js/input/tex/begingroup/BegingroupConfiguration.js`),import(`@mathjax/src/js/input/tex/boldsymbol/BoldsymbolConfiguration.js`),import(`@mathjax/src/js/input/tex/braket/BraketConfiguration.js`),import(`@mathjax/src/js/input/tex/bussproofs/BussproofsConfiguration.js`),import(`@mathjax/src/js/input/tex/cancel/CancelConfiguration.js`),import(`@mathjax/src/js/input/tex/cases/CasesConfiguration.js`),import(`@mathjax/src/js/input/tex/centernot/CenternotConfiguration.js`),import(`@mathjax/src/js/input/tex/color/ColorConfiguration.js`),import(`@mathjax/src/js/input/tex/colortbl/ColortblConfiguration.js`),import(`@mathjax/src/js/input/tex/colorv2/ColorV2Configuration.js`),import(`@mathjax/src/js/input/tex/configmacros/ConfigMacrosConfiguration.js`),import(`@mathjax/src/js/input/tex/dsfont/DsfontConfiguration.js`),import(`@mathjax/src/js/input/tex/empheq/EmpheqConfiguration.js`),import(`@mathjax/src/js/input/tex/enclose/EncloseConfiguration.js`),import(`@mathjax/src/js/input/tex/extpfeil/ExtpfeilConfiguration.js`),import(`@mathjax/src/js/input/tex/gensymb/GensymbConfiguration.js`),import(`@mathjax/src/js/input/tex/html/HtmlConfiguration.js`),import(`@mathjax/src/js/input/tex/mathtools/MathtoolsConfiguration.js`),import(`@mathjax/src/js/input/tex/mhchem/MhchemConfiguration.js`),import(`@mathjax/src/js/input/tex/newcommand/NewcommandConfiguration.js`),import(`@mathjax/src/js/input/tex/noerrors/NoErrorsConfiguration.js`),import(`@mathjax/src/js/input/tex/noundefined/NoUndefinedConfiguration.js`),import(`@mathjax/src/js/input/tex/physics/PhysicsConfiguration.js`),import(`@mathjax/src/js/input/tex/setoptions/SetOptionsConfiguration.js`),import(`@mathjax/src/js/input/tex/tagformat/TagFormatConfiguration.js`),import(`@mathjax/src/js/input/tex/texhtml/TexHtmlConfiguration.js`),import(`@mathjax/src/js/input/tex/textcomp/TextcompConfiguration.js`),import(`@mathjax/src/js/input/tex/textmacros/TextMacrosConfiguration.js`),import(`@mathjax/src/js/input/tex/unicode/UnicodeConfiguration.js`),import(`@mathjax/src/js/input/tex/units/UnitsConfiguration.js`),import(`@mathjax/src/js/input/tex/upgreek/UpgreekConfiguration.js`),import(`@mathjax/src/js/input/tex/verb/VerbConfiguration.js`)]),f.asyncIsSynchronous=!0}catch{
2
+ /* istanbul ignore next -- @preserve */
3
+ a=!1}try{m=(await import(`@mathjax/mathjax-newcm-font/js/chtml.js`)).MathJaxNewcmFont,h=(await import(`@mathjax/mathjax-newcm-font/js/svg.js`)).MathJaxNewcmFont}catch{
4
+ /* istanbul ignore next -- @preserve */
5
+ p=!1}const _=e=>{
6
+ /* istanbul ignore if -- @preserve */
7
+ if(!a)throw Error(`[@mdit/plugin-mathjax-slim] "@mathjax/src" is not installed!`);let t=e.output===`chtml`,r=(t?e.chtml:e.svg)??{};
8
+ /* istanbul ignore if -- @preserve */
9
+ if(!r.fontData&&!p)throw Error(`[@mdit/plugin-mathjax-slim] "@mathjax/mathjax-newcm-font" is not installed!`);let i=Object.assign({fontData:t?m:h},r?.fontData?{}:{dynamicPrefix:`@mathjax/mathjax-newcm-font/js/${t?`chtml`:`svg`}/dynamic`},t&&!r.fontData?{fontURL:`https://cdn.jsdelivr.net/npm/@mathjax/mathjax-newcm-font/chtml/woff2`}:{},r);return f.asyncLoad=t=>{e.debug&&console.debug(`[MathJax]: sync loading ${t}...`),g(t)},{InputJax:new u({packages:[`base`,...n],...e.tex}),OutputJax:new(t?s:l)(i),enableAssistiveMml:e.a11y!==!1}},v=(e={})=>{let t=_(e),{OutputJax:n,InputJax:r}=t,a=d(),s=c(a);e.a11y!==!1&&o(s);let l=()=>{n.adaptor!=null&&(r.reset(),n.reset())};return{adaptor:a,documentOptions:t,allowInlineWithSpace:e.allowInlineWithSpace??!1,delimiters:e.delimiters??`dollars`,mathFence:e.mathFence??!1,clearStyle:l,reset:()=>{r.reset(),i(r)},outputStyle:()=>{n.font.loadDynamicFilesSync();let e=a.cssText(n.styleSheet(f.document(``,t)));return l(),e},transformer:e.transformer??null}},y=(e,{allowInlineWithSpace:n,adaptor:r,delimiters:i,documentOptions:a,mathFence:o,reset:s,transformer:c})=>{let l=e.render.bind(e),u=e.renderInline.bind(e);e.render=(e,t)=>{try{return l(e,t)}finally{s()}},e.renderInline=(e,t)=>{try{return u(e,t)}finally{s()}},e.use(t,{allowInlineWithSpace:n,delimiters:i,mathFence:o,render:(e,t)=>{let n=f.document(e,a).convert(e,{display:t}),i=r.outerHTML(n);return c?.(i,t)??i}})};export{v as createMathjaxInstance,_ as getDocumentOptions,y as mathjax};
2
10
  //# sourceMappingURL=sync-node.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sync-node.js","names":[],"sources":["../src/tex/packages.ts","../src/utils.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","import type { LiteElement } from \"@mathjax/src/js/adaptors/lite/Element.js\";\nimport type { TeX } from \"@mathjax/src/js/input/tex.js\";\nimport type { HandlerType } from \"@mathjax/src/js/input/tex/HandlerTypes.js\";\n\ninterface TeXMacroMap {\n map: Map<string, unknown>;\n}\n\nconst USER_MAPS: { handler: HandlerType; name: string }[] = [\n { handler: \"macro\" as HandlerType.MACRO, name: \"new-Command\" },\n { handler: \"environment\" as HandlerType.ENVIRONMENT, name: \"new-Environment\" },\n { handler: \"delimiter\" as HandlerType.DELIMITER, name: \"new-Delimiter\" },\n];\n\n/**\n * Clear user-defined TeX state (macros/environments/delimiters) on a MathJax TeX input jax.\n *\n * MathJax stores user-defined macros, environments and delimiters in dedicated `new-*` maps that\n * are separate from the built-in maps, and `InputJax.reset()` does not clear them, so they would\n * leak across documents rendered by the same instance. This reaches into the internal maps to\n * remove only user-defined entries.\n *\n * 清除 MathJax TeX 输入 jax 上由 `\\newcommand`/`\\def`/`\\newenvironment` 等定义的用户状态。\n *\n * MathJax 将用户自定义的宏、环境与分隔符存放在独立的 `new-*` 映射中,与内置映射分离,且 `InputJax.reset()`\n * 不会清除它们,因此同一实例渲染多篇文档时状态会跨文档泄漏。此处直接访问内部映射,仅移除用户自定义条目。\n *\n * @param InputJax - MathJax TeX input jax / MathJax TeX 输入 jax\n */\nexport const clearUserState = (InputJax: TeX<LiteElement, string, HTMLElement>): void => {\n for (const { handler, name } of USER_MAPS) {\n const handlerMap = InputJax.parseOptions.handlers.get(handler);\n const userMap = handlerMap.retrieve(name) as unknown as TeXMacroMap | null;\n\n userMap?.map.clear();\n }\n};\n","/** Forked from https://github.com/tani/markdown-it-mathjax3/blob/master/index.ts */\n// oxlint-disable-next-line import/no-nodejs-modules\nimport { createRequire } from \"node:module\";\n\nimport type { MathJaxNewcmFont as MathJaxNewcmHTMLFont } from \"@mathjax/mathjax-newcm-font/js/chtml.js\";\nimport type { MathJaxNewcmFont as MathJaxNewcmSVGFont } from \"@mathjax/mathjax-newcm-font/js/svg.js\";\nimport type { AssistiveMmlHandler as AssistiveMmlHandlerType } from \"@mathjax/src/js/a11y/assistive-mml.js\";\nimport type { LiteDocument } from \"@mathjax/src/js/adaptors/lite/Document.js\";\nimport type { LiteElement, LiteNode } from \"@mathjax/src/js/adaptors/lite/Element.js\";\nimport type { LiteText } from \"@mathjax/src/js/adaptors/lite/Text.js\";\nimport type { liteAdaptor as liteAdaptorType } from \"@mathjax/src/js/adaptors/liteAdaptor.js\";\nimport type { MathDocument } from \"@mathjax/src/js/core/MathDocument.js\";\nimport type { RegisterHTMLHandler as RegisterHTMLHandlerType } from \"@mathjax/src/js/handlers/html.js\";\nimport type { TeX as TeXType } from \"@mathjax/src/js/input/tex.js\";\nimport type { mathjax as mathjaxType } from \"@mathjax/src/js/mathjax.js\";\nimport type { CHTML as CHTMLType } from \"@mathjax/src/js/output/chtml.js\";\nimport type { SVG as SVGType } from \"@mathjax/src/js/output/svg.js\";\nimport { tex } from \"@mdit/plugin-tex\";\nimport type { MarkdownIt } from \"markdown-it\";\n\nimport type { MarkdownItMathjaxOptions, DocumentOptions, MathjaxInstance } from \"./options.js\";\nimport { texPackages } from \"./tex/index.js\";\nimport { clearUserState } from \"./utils.js\";\n\nlet isMathJaxInstalled = true;\nlet AssistiveMmlHandler: typeof AssistiveMmlHandlerType,\n CHTML: typeof CHTMLType,\n RegisterHTMLHandler: typeof RegisterHTMLHandlerType,\n SVG: typeof SVGType,\n TeX: typeof TeXType,\n liteAdaptor: typeof liteAdaptorType,\n mathjaxLib: typeof mathjaxType;\nlet isMathJaxNewcmFontInstalled = true;\nlet chtmlFont: typeof MathJaxNewcmHTMLFont, svgFont: typeof MathJaxNewcmSVGFont;\n\nconst require = createRequire(import.meta.url);\n\ntry {\n ({ mathjax: mathjaxLib } = await import(\"@mathjax/src/js/mathjax.js\"));\n [{ TeX }, { CHTML }, { SVG }, { liteAdaptor }, { RegisterHTMLHandler }, { AssistiveMmlHandler }] =\n await Promise.all([\n import(\"@mathjax/src/js/input/tex.js\"),\n import(\"@mathjax/src/js/output/chtml.js\"),\n import(\"@mathjax/src/js/output/svg.js\"),\n import(\"@mathjax/src/js/adaptors/liteAdaptor.js\"),\n import(\"@mathjax/src/js/handlers/html.js\"),\n import(\"@mathjax/src/js/a11y/assistive-mml.js\"),\n import(\"@mathjax/src/js/input/tex/action/ActionConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/ams/AmsConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/amscd/AmsCdConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/base/BaseConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/bbm/BbmConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/bboldx/BboldxConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/bbox/BboxConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/begingroup/BegingroupConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/boldsymbol/BoldsymbolConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/braket/BraketConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/bussproofs/BussproofsConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/cancel/CancelConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/cases/CasesConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/centernot/CenternotConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/color/ColorConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/colortbl/ColortblConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/colorv2/ColorV2Configuration.js\"),\n import(\"@mathjax/src/js/input/tex/configmacros/ConfigMacrosConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/dsfont/DsfontConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/empheq/EmpheqConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/enclose/EncloseConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/extpfeil/ExtpfeilConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/gensymb/GensymbConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/html/HtmlConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/mathtools/MathtoolsConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/mhchem/MhchemConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/newcommand/NewcommandConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/noerrors/NoErrorsConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/noundefined/NoUndefinedConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/physics/PhysicsConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/setoptions/SetOptionsConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/tagformat/TagFormatConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/texhtml/TexHtmlConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/textcomp/TextcompConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/textmacros/TextMacrosConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/unicode/UnicodeConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/units/UnitsConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/upgreek/UpgreekConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/verb/VerbConfiguration.js\"),\n ]);\n\n mathjaxLib.asyncIsSynchronous = true;\n} catch {\n /* istanbul ignore next -- @preserve */\n isMathJaxInstalled = false;\n}\n\ntry {\n chtmlFont = (await import(\"@mathjax/mathjax-newcm-font/js/chtml.js\")).MathJaxNewcmFont;\n svgFont = (await import(\"@mathjax/mathjax-newcm-font/js/svg.js\")).MathJaxNewcmFont;\n} catch {\n /* istanbul ignore next -- @preserve */\n isMathJaxNewcmFontInstalled = false;\n}\nexport const getDocumentOptions = (options: MarkdownItMathjaxOptions): DocumentOptions => {\n /* istanbul ignore if -- @preserve */\n if (!isMathJaxInstalled)\n throw new Error('[@mdit/plugin-mathjax-slim] \"@mathjax/src\" is not installed!');\n\n const isCHTML = options.output === \"chtml\";\n const userOptions = (isCHTML ? options.chtml : options.svg) ?? {};\n\n /* istanbul ignore if -- @preserve */\n if (!userOptions.fontData && !isMathJaxNewcmFontInstalled)\n throw new Error('[@mdit/plugin-mathjax-slim] \"@mathjax/mathjax-newcm-font\" is not installed!');\n\n const outputOptions = Object.assign(\n {\n fontData: isCHTML ? chtmlFont : svgFont,\n },\n // fontURL can be set to undefined if you want to bundle the fonts yourself\n // both fontURL and dynamicPrefix shall be synced with fontData, so set it to undefined if fontData is customized\n userOptions?.fontData\n ? {}\n : { dynamicPrefix: `@mathjax/mathjax-newcm-font/js/${isCHTML ? \"chtml\" : \"svg\"}/dynamic` },\n isCHTML && !userOptions.fontData\n ? { fontURL: \"https://cdn.jsdelivr.net/npm/@mathjax/mathjax-newcm-font/chtml/woff2\" }\n : {},\n userOptions,\n );\n\n mathjaxLib.asyncLoad = (file): void => {\n if (options.debug)\n // oxlint-disable-next-line no-console\n console.debug(`[MathJax]: sync loading ${file}...`);\n // oxlint-disable-next-line import/no-dynamic-require\n require(file);\n };\n\n return {\n InputJax: new TeX<LiteElement, string, HTMLElement>({\n packages: [\"base\", ...texPackages],\n ...options.tex,\n }),\n OutputJax: new (isCHTML ? CHTML : SVG)<LiteElement, string, HTMLElement>(outputOptions),\n enableAssistiveMml: options.a11y !== false,\n };\n};\n\nexport const createMathjaxInstance = (\n options: MarkdownItMathjaxOptions = {},\n): MathjaxInstance<true> | null => {\n const documentOptions = getDocumentOptions(options);\n const { OutputJax, InputJax } = documentOptions;\n\n const adaptor = liteAdaptor();\n // oxlint-disable-next-line new-cap\n const handler = RegisterHTMLHandler(adaptor);\n // oxlint-disable-next-line new-cap\n if (options.a11y !== false) AssistiveMmlHandler<LiteNode, LiteText, LiteDocument>(handler);\n\n const clearStyle = (): void => {\n // if there is no adaptor, output jax is not initialized yet, so nothing to clear\n if (OutputJax.adaptor == null) return;\n\n InputJax.reset();\n OutputJax.reset();\n };\n\n const reset = (): void => {\n InputJax.reset();\n clearUserState(InputJax);\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 reset,\n transformer,\n }: MathjaxInstance<true>,\n): void => {\n // Reset the shared TeX input state (macros/labels) after each render so that\n // state does not leak across documents rendered by the same instance.\n const render = md.render.bind(md);\n const renderInline = md.renderInline.bind(md);\n\n md.render = (src, env): string => {\n try {\n return render(src, env);\n } finally {\n reset();\n }\n };\n md.renderInline = (src, env): string => {\n try {\n return renderInline(src, env);\n } finally {\n reset();\n }\n };\n\n md.use(tex, {\n allowInlineWithSpace,\n delimiters,\n mathFence,\n render: (content, displayMode) => {\n const mathDocument = mathjaxLib.document(content, documentOptions).convert(content, {\n display: displayMode,\n }) as LiteElement;\n\n const result = adaptor.outerHTML(mathDocument);\n\n return transformer?.(result, displayMode) ?? result;\n },\n });\n};\n"],"mappings":"mFAEA,MAAa,EAA4B,gUAuCzC,ECjCM,EAAsD,CAC1D,CAAE,QAAS,QAA8B,KAAM,aAAc,EAC7D,CAAE,QAAS,cAA0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EJ,CACT,EAWE,YAAa,EAAQ,aAAe,IACtC,CACF,EAEa,GACX,EACA,CACE,uBACA,UACA,aACA,kBACA,YACA,QACA,iBAEO,CAGT,IAAM,EAAS,EAAG,OAAO,KAAK,CAAE,EAC1B,EAAe,EAAG,aAAa,KAAK,CAAE,EAE5C,EAAG,QAAU,EAAK,IAAgB,CAChC,GAAI,CACF,OAAO,EAAO,EAAK,CAAG,CACxB,QAAU,CACR,EAAM,CACR,CACF,EACA,EAAG,cAAgB,EAAK,IAAgB,CACtC,GAAI,CACF,OAAO,EAAa,EAAK,CAAG,CAC9B,QAAU,CACR,EAAM,CACR,CACF,EAEA,EAAG,IAAI,EAAK,CACV,uBACA,aACA,YACA,QAAS,EAAS,IAAgB,CAChC,IAAM,EAAe,EAAW,SAAS,EAAS,CAAe,CAAC,CAAC,QAAQ,EAAS,CAClF,QAAS,CACX,CAAC,EAEK,EAAS,EAAQ,UAAU,CAAY,EAE7C,OAAO,IAAc,EAAQ,CAAW,GAAK,CAC/C,CACF,CAAC,CACH"}
1
+ {"version":3,"file":"sync-node.js","names":["texPackages","USER_MAPS","clearUserState","InputJax","handler","name","isMathJaxInstalled","AssistiveMmlHandler","CHTML","RegisterHTMLHandler","SVG","TeX","liteAdaptor","mathjaxLib","isMathJaxNewcmFontInstalled","chtmlFont","svgFont","require","createRequire","getDocumentOptions","isCHTML","options","userOptions","outputOptions","file","createMathjaxInstance","documentOptions","adaptor","clearStyle","OutputJax","style","mathjax","render","md","renderInline","src","env","reset","tex","mathDocument","content","displayMode","result","transformer"],"sources":["../src/tex/packages.ts","../src/utils.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","import type { LiteElement } from \"@mathjax/src/js/adaptors/lite/Element.js\";\nimport type { TeX } from \"@mathjax/src/js/input/tex.js\";\nimport type { HandlerType } from \"@mathjax/src/js/input/tex/HandlerTypes.js\";\n\ninterface TeXMacroMap {\n map: Map<string, unknown>;\n}\n\nconst USER_MAPS: { handler: HandlerType; name: string }[] = [\n { handler: \"macro\" as HandlerType.MACRO, name: \"new-Command\" },\n { handler: \"environment\" as HandlerType.ENVIRONMENT, name: \"new-Environment\" },\n { handler: \"delimiter\" as HandlerType.DELIMITER, name: \"new-Delimiter\" },\n];\n\n/**\n * Clear user-defined TeX state (macros/environments/delimiters) on a MathJax TeX input jax.\n *\n * MathJax stores user-defined macros, environments and delimiters in dedicated `new-*` maps that\n * are separate from the built-in maps, and `InputJax.reset()` does not clear them, so they would\n * leak across documents rendered by the same instance. This reaches into the internal maps to\n * remove only user-defined entries.\n *\n * 清除 MathJax TeX 输入 jax 上由 `\\newcommand`/`\\def`/`\\newenvironment` 等定义的用户状态。\n *\n * MathJax 将用户自定义的宏、环境与分隔符存放在独立的 `new-*` 映射中,与内置映射分离,且 `InputJax.reset()`\n * 不会清除它们,因此同一实例渲染多篇文档时状态会跨文档泄漏。此处直接访问内部映射,仅移除用户自定义条目。\n *\n * @param InputJax - MathJax TeX input jax / MathJax TeX 输入 jax\n */\nexport const clearUserState = (InputJax: TeX<LiteElement, string, HTMLElement>): void => {\n for (const { handler, name } of USER_MAPS) {\n const handlerMap = InputJax.parseOptions.handlers.get(handler);\n const userMap = handlerMap.retrieve(name) as unknown as TeXMacroMap | null;\n\n userMap?.map.clear();\n }\n};\n","/** Forked from https://github.com/tani/markdown-it-mathjax3/blob/master/index.ts */\n// oxlint-disable-next-line import/no-nodejs-modules\nimport { createRequire } from \"node:module\";\n\nimport type { MathJaxNewcmFont as MathJaxNewcmHTMLFont } from \"@mathjax/mathjax-newcm-font/js/chtml.js\";\nimport type { MathJaxNewcmFont as MathJaxNewcmSVGFont } from \"@mathjax/mathjax-newcm-font/js/svg.js\";\nimport type { AssistiveMmlHandler as AssistiveMmlHandlerType } from \"@mathjax/src/js/a11y/assistive-mml.js\";\nimport type { LiteDocument } from \"@mathjax/src/js/adaptors/lite/Document.js\";\nimport type { LiteElement, LiteNode } from \"@mathjax/src/js/adaptors/lite/Element.js\";\nimport type { LiteText } from \"@mathjax/src/js/adaptors/lite/Text.js\";\nimport type { liteAdaptor as liteAdaptorType } from \"@mathjax/src/js/adaptors/liteAdaptor.js\";\nimport type { MathDocument } from \"@mathjax/src/js/core/MathDocument.js\";\nimport type { RegisterHTMLHandler as RegisterHTMLHandlerType } from \"@mathjax/src/js/handlers/html.js\";\nimport type { TeX as TeXType } from \"@mathjax/src/js/input/tex.js\";\nimport type { mathjax as mathjaxType } from \"@mathjax/src/js/mathjax.js\";\nimport type { CHTML as CHTMLType } from \"@mathjax/src/js/output/chtml.js\";\nimport type { SVG as SVGType } from \"@mathjax/src/js/output/svg.js\";\nimport { tex } from \"@mdit/plugin-tex\";\nimport type { MarkdownIt } from \"markdown-it\";\n\nimport type { MarkdownItMathjaxOptions, DocumentOptions, MathjaxInstance } from \"./options.js\";\nimport { texPackages } from \"./tex/index.js\";\nimport { clearUserState } from \"./utils.js\";\n\nlet isMathJaxInstalled = true;\nlet AssistiveMmlHandler: typeof AssistiveMmlHandlerType,\n CHTML: typeof CHTMLType,\n RegisterHTMLHandler: typeof RegisterHTMLHandlerType,\n SVG: typeof SVGType,\n TeX: typeof TeXType,\n liteAdaptor: typeof liteAdaptorType,\n mathjaxLib: typeof mathjaxType;\nlet isMathJaxNewcmFontInstalled = true;\nlet chtmlFont: typeof MathJaxNewcmHTMLFont, svgFont: typeof MathJaxNewcmSVGFont;\n\nconst require = createRequire(import.meta.url);\n\ntry {\n ({ mathjax: mathjaxLib } = await import(\"@mathjax/src/js/mathjax.js\"));\n [{ TeX }, { CHTML }, { SVG }, { liteAdaptor }, { RegisterHTMLHandler }, { AssistiveMmlHandler }] =\n await Promise.all([\n import(\"@mathjax/src/js/input/tex.js\"),\n import(\"@mathjax/src/js/output/chtml.js\"),\n import(\"@mathjax/src/js/output/svg.js\"),\n import(\"@mathjax/src/js/adaptors/liteAdaptor.js\"),\n import(\"@mathjax/src/js/handlers/html.js\"),\n import(\"@mathjax/src/js/a11y/assistive-mml.js\"),\n import(\"@mathjax/src/js/input/tex/action/ActionConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/ams/AmsConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/amscd/AmsCdConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/base/BaseConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/bbm/BbmConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/bboldx/BboldxConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/bbox/BboxConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/begingroup/BegingroupConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/boldsymbol/BoldsymbolConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/braket/BraketConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/bussproofs/BussproofsConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/cancel/CancelConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/cases/CasesConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/centernot/CenternotConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/color/ColorConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/colortbl/ColortblConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/colorv2/ColorV2Configuration.js\"),\n import(\"@mathjax/src/js/input/tex/configmacros/ConfigMacrosConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/dsfont/DsfontConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/empheq/EmpheqConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/enclose/EncloseConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/extpfeil/ExtpfeilConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/gensymb/GensymbConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/html/HtmlConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/mathtools/MathtoolsConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/mhchem/MhchemConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/newcommand/NewcommandConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/noerrors/NoErrorsConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/noundefined/NoUndefinedConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/physics/PhysicsConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/setoptions/SetOptionsConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/tagformat/TagFormatConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/texhtml/TexHtmlConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/textcomp/TextcompConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/textmacros/TextMacrosConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/unicode/UnicodeConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/units/UnitsConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/upgreek/UpgreekConfiguration.js\"),\n import(\"@mathjax/src/js/input/tex/verb/VerbConfiguration.js\"),\n ]);\n\n mathjaxLib.asyncIsSynchronous = true;\n} catch {\n /* istanbul ignore next -- @preserve */\n isMathJaxInstalled = false;\n}\n\ntry {\n chtmlFont = (await import(\"@mathjax/mathjax-newcm-font/js/chtml.js\")).MathJaxNewcmFont;\n svgFont = (await import(\"@mathjax/mathjax-newcm-font/js/svg.js\")).MathJaxNewcmFont;\n} catch {\n /* istanbul ignore next -- @preserve */\n isMathJaxNewcmFontInstalled = false;\n}\nexport const getDocumentOptions = (options: MarkdownItMathjaxOptions): DocumentOptions => {\n /* istanbul ignore if -- @preserve */\n if (!isMathJaxInstalled)\n throw new Error('[@mdit/plugin-mathjax-slim] \"@mathjax/src\" is not installed!');\n\n const isCHTML = options.output === \"chtml\";\n const userOptions = (isCHTML ? options.chtml : options.svg) ?? {};\n\n /* istanbul ignore if -- @preserve */\n if (!userOptions.fontData && !isMathJaxNewcmFontInstalled)\n throw new Error('[@mdit/plugin-mathjax-slim] \"@mathjax/mathjax-newcm-font\" is not installed!');\n\n const outputOptions = Object.assign(\n {\n fontData: isCHTML ? chtmlFont : svgFont,\n },\n // fontURL can be set to undefined if you want to bundle the fonts yourself\n // both fontURL and dynamicPrefix shall be synced with fontData, so set it to undefined if fontData is customized\n userOptions?.fontData\n ? {}\n : { dynamicPrefix: `@mathjax/mathjax-newcm-font/js/${isCHTML ? \"chtml\" : \"svg\"}/dynamic` },\n isCHTML && !userOptions.fontData\n ? { fontURL: \"https://cdn.jsdelivr.net/npm/@mathjax/mathjax-newcm-font/chtml/woff2\" }\n : {},\n userOptions,\n );\n\n mathjaxLib.asyncLoad = (file): void => {\n if (options.debug)\n // oxlint-disable-next-line no-console\n console.debug(`[MathJax]: sync loading ${file}...`);\n // oxlint-disable-next-line import/no-dynamic-require\n require(file);\n };\n\n return {\n InputJax: new TeX<LiteElement, string, HTMLElement>({\n packages: [\"base\", ...texPackages],\n ...options.tex,\n }),\n OutputJax: new (isCHTML ? CHTML : SVG)<LiteElement, string, HTMLElement>(outputOptions),\n enableAssistiveMml: options.a11y !== false,\n };\n};\n\nexport const createMathjaxInstance = (\n options: MarkdownItMathjaxOptions = {},\n): MathjaxInstance<true> | null => {\n const documentOptions = getDocumentOptions(options);\n const { OutputJax, InputJax } = documentOptions;\n\n const adaptor = liteAdaptor();\n // oxlint-disable-next-line new-cap\n const handler = RegisterHTMLHandler(adaptor);\n // oxlint-disable-next-line new-cap\n if (options.a11y !== false) AssistiveMmlHandler<LiteNode, LiteText, LiteDocument>(handler);\n\n const clearStyle = (): void => {\n // if there is no adaptor, output jax is not initialized yet, so nothing to clear\n if (OutputJax.adaptor == null) return;\n\n InputJax.reset();\n OutputJax.reset();\n };\n\n const reset = (): void => {\n InputJax.reset();\n clearUserState(InputJax);\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 reset,\n transformer,\n }: MathjaxInstance<true>,\n): void => {\n // Reset the shared TeX input state (macros/labels) after each render so that\n // state does not leak across documents rendered by the same instance.\n const render = md.render.bind(md);\n const renderInline = md.renderInline.bind(md);\n\n md.render = (src, env): string => {\n try {\n return render(src, env);\n } finally {\n reset();\n }\n };\n md.renderInline = (src, env): string => {\n try {\n return renderInline(src, env);\n } finally {\n reset();\n }\n };\n\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,MAAaA,EAA4B,gVAuCzC,ECjCMC,EAAsD,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Q,CACzB,EAwBE,gBAtBgC,CAChC0B,EAAU,KAAK,qBAAqB,EAEpC,IAAMC,EAAQH,EAAQ,QACpBE,EAAU,WACRhB,EAAW,SAAS,GAAIa,CAAe,CACzC,CACF,EAIA,OAFAE,EAAW,EAEJE,CACT,EAWE,YAAaT,EAAQ,aAAe,IACtC,CACF,EAEaU,GACX,EACA,CACE,uBACA,UACA,aACA,kBACA,YACA,QACA,iBAEO,CAGT,IAAMC,EAASC,EAAG,OAAO,KAAKA,CAAE,EAC1BC,EAAeD,EAAG,aAAa,KAAKA,CAAE,EAE5C,EAAG,QAAU,EAAK,IAAgB,CAChC,GAAI,CACF,OAAOD,EAAOG,EAAKC,CAAG,CACxB,QAAU,CACRC,EAAM,CACR,CACF,EACA,EAAG,cAAgB,EAAK,IAAgB,CACtC,GAAI,CACF,OAAOH,EAAaC,EAAKC,CAAG,CAC9B,QAAU,CACRC,EAAM,CACR,CACF,EAEAJ,EAAG,IAAIK,EAAK,CACV,uBACA,aACA,YACA,QAAS,EAAS,IAAgB,CAChC,IAAMC,EAAe1B,EAAW,SAAS2B,EAASd,CAAe,CAAC,CAAC,QAAQc,EAAS,CAClF,QAASC,CACX,CAAC,EAEKC,EAASf,EAAQ,UAAUY,CAAY,EAE7C,OAAOI,IAAcD,EAAQD,CAAW,GAAKC,CAC/C,CACF,CAAC,CACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mdit/plugin-mathjax-slim",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "mathjax plugin for MarkdownIt",
5
5
  "keywords": [
6
6
  "markdown-it",
@@ -46,16 +46,16 @@
46
46
  "clean": "rimraf ./dist"
47
47
  },
48
48
  "dependencies": {
49
- "@mdit/plugin-tex": "1.1.1"
49
+ "@mdit/plugin-tex": "1.1.2"
50
50
  },
51
51
  "devDependencies": {
52
- "@mathjax/mathjax-tex-font": "4.1.3",
53
- "@mathjax/src": "4.1.3"
52
+ "@mathjax/mathjax-tex-font": "^4.1.3",
53
+ "@mathjax/src": "^4.1.3"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "@mathjax/mathjax-newcm-font": "^4.1.3",
57
57
  "@mathjax/src": "^4.1.3",
58
- "markdown-it": "^15.0.0"
58
+ "markdown-it": "^15.0.2"
59
59
  },
60
60
  "peerDependenciesMeta": {
61
61
  "@mathjax/mathjax-newcm-font": {
@@ -71,5 +71,5 @@
71
71
  "engines": {
72
72
  "node": ">=22"
73
73
  },
74
- "gitHead": "1b4c236a56b2fd99c6e6da03dd10354f43a8fa05"
74
+ "gitHead": "f77fa56e8c1c8bede78559673447f8072ba3292e"
75
75
  }