fuc-new/doc/node_modules/@mdit/plugin-mathjax-slim/lib/index.js
hellcat 6adbc04d4b 1
2025-10-03 17:17:08 +08:00

3 lines
1.9 KiB
JavaScript

import{createRequire as v}from"node:module";import{tex as y}from"@mdit/plugin-tex";import H from"upath";const I=v(import.meta.url);let h=!0,c,f,d,p,w,x,S,M;try{({mathjax:c}=await import("mathjax-full/js/mathjax.js")),{AllPackages:f}=await import("mathjax-full/js/input/tex/AllPackages.js"),{TeX:d}=await import("mathjax-full/js/input/tex.js"),{CHTML:p}=await import("mathjax-full/js/output/chtml.js"),{SVG:w}=await import("mathjax-full/js/output/svg.js"),{liteAdaptor:x}=await import("mathjax-full/js/adaptors/liteAdaptor.js"),{RegisterHTMLHandler:S}=await import("mathjax-full/js/handlers/html.js"),{AssistiveMmlHandler:M}=await import("mathjax-full/js/a11y/assistive-mml.js")}catch{/* istanbul ignore next -- @preserve */h=!1}const j=t=>{/* istanbul ignore if -- @preserve */if(!h)throw new Error('[@mdit/mathjax] "mathjax-full" is not installed!');return{InputJax:new d({packages:f,...t.tex}),OutputJax:t.output==="chtml"?new p({fontURL:H.dirname(I.resolve("mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_Zero.woff")),adaptiveCSS:!0,...t.chtml}):new w({fontCache:"none",...t.svg}),enableAssistiveMml:t.a11y!==!1}},L=(t={})=>{const e=j(t),{OutputJax:a,InputJax:l}=e,r=x(),m=S(r);t.a11y!==!1&&M(m);const n=()=>{a instanceof p&&a.clearCache()},o=()=>{l.reset()},i=()=>{const s=r.innerHTML(a.styleSheet(c.document("",e)));return n(),s};return{adaptor:r,documentOptions:e,allowInlineWithSpace:t.allowInlineWithSpace??!1,delimiters:t.delimiters??"dollars",mathFence:t.mathFence??!1,clearStyle:n,reset:o,outputStyle:i,transformer:t.transformer??null}},g=(t,{allowInlineWithSpace:e,adaptor:a,delimiters:l,documentOptions:r,mathFence:m,transformer:n})=>{t.use(y,{allowInlineWithSpace:e,delimiters:l,mathFence:m,render:(o,i)=>{const s=c.document(o,r).convert(o,{display:i}),u=a.outerHTML(s);return n?.(u,i)??u}})};export{L as createMathjaxInstance,j as getDocumentOptions,g as mathjax};
//# sourceMappingURL=index.js.map