@mdit/plugin-mathjax-slim 2.0.0 → 2.1.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/README.md CHANGED
@@ -20,3 +20,13 @@ npm i -D @mdit/plugin-mathjax-slim @mathjax/src
20
20
  # yarn
21
21
  yarn add -D @mdit/plugin-mathjax-slim @mathjax/src
22
22
  ```
23
+
24
+ ## Comparison / 对比
25
+
26
+ Compared against the upstream [`markdown-it-mathjax3`](https://www.npmjs.com/package/markdown-it-mathjax3) package `5.2.0`.
27
+
28
+ - Correctness: **8/25** cases match the reference exactly (11 matching after normalization, 3 reference errors, 1 differences).
29
+ - Throughput: **1.15×** the reference (geometric mean across 6 benchmark cases; above 1× means faster).
30
+ - Entry gzip: **1.7 kB** versus **1.7 kB** for the reference (import cost).
31
+
32
+ See the full comparison report: [English](https://mdit-plugins.github.io/compare.html) · [中文](https://mdit-plugins.github.io/zh/compare.html).
@@ -324,9 +324,10 @@ interface MarkdownItMathjaxOptions extends Pick<MarkdownItTexOptions, "allowInli
324
324
  */
325
325
  output?: "chtml" | "svg";
326
326
  /**
327
- * Enable A11y
327
+ * Whether to include assistive MathML for screen readers. When disabled, math is still rendered
328
+ * but the hidden `<mjx-assistive-mml>` output is omitted.
328
329
  *
329
- * 是否启用无障碍
330
+ * 是否包含供屏幕阅读器使用的辅助 MathML。关闭后数学公式仍会渲染,但不再输出隐藏的 `<mjx-assistive-mml>`。
330
331
  *
331
332
  * @default true
332
333
  */
@@ -403,5 +404,4 @@ interface MathjaxInstance<Sync extends boolean = false> extends Required<Pick<Ma
403
404
  export declare const getDocumentOptions: (options: MarkdownItMathjaxOptions) => Promise<DocumentOptions>;
404
405
  export declare const createMathjaxInstance: (options?: MarkdownItMathjaxOptions) => Promise<MathjaxInstance | null>;
405
406
  export declare const mathjax: (md: MarkdownIt, instance: MathjaxInstance) => void;
406
- export type { DocumentOptions, MarkdownItMathjaxOptions, MathJaxTexInputOptions, MathjaxCommonHTMLOutputOptions, MathjaxCommonOutputOptions, MathjaxFilter, MathjaxFilterData, MathjaxInstance, MathjaxSVGOutputOptions, TeXTransformer, TexPackage };
407
- //# sourceMappingURL=index.d.ts.map
407
+ export type { DocumentOptions, MarkdownItMathjaxOptions, MathJaxTexInputOptions, MathjaxCommonHTMLOutputOptions, MathjaxCommonOutputOptions, MathjaxFilter, MathjaxFilterData, MathjaxInstance, MathjaxSVGOutputOptions, TeXTransformer, TexPackage };
@@ -6,5 +6,5 @@ x=!1}const S=async e=>{
6
6
  /* istanbul ignore if -- @preserve */
7
7
  if(!b)throw Error(`[@mdit/plugin-mathjax-slim] "@mathjax/src" is not installed!`);let t=e.output===`chtml`,n=(t?e.chtml:e.svg)??{};
8
8
  /* istanbul ignore if -- @preserve */
9
- if(!n.fontData&&!x)throw Error(`[@mdit/plugin-mathjax-slim] "@mathjax/mathjax-newcm-font" is not installed!`);let r=Object.assign({fontData:t?g:y},n?.fontData?{}:{dynamicPrefix:`@mathjax/mathjax-newcm-font/js/${t?`chtml`:`svg`}/dynamic`},t&&!n.fontData?{fontURL:`https://cdn.jsdelivr.net/npm/@mathjax/mathjax-newcm-font/chtml/woff2`}:{},n);v.asyncLoad=t=>(e.debug&&console.debug(`[MathJax]: loading ${t}...`),import(t));let o=e.tex?.packages;return await a([...i(o),`html`,`texhtml`]),{InputJax:new h({...e.tex,packages:i(o)}),OutputJax:new(t?f:m)(r),enableAssistiveMml:e.a11y!==!1}},C=async(e={})=>{let t=await S(e),{OutputJax:n}=t,r=_(),a=p(r);e.a11y!==!1&&d(a);let o=()=>{n.adaptor!=null&&(t.InputJax.reset(),n.reset())},l={adaptor:r,documentOptions:t,allowInlineWithSpace:e.allowInlineWithSpace??!1,delimiters:e.delimiters??`dollars`,mathFence:e.mathFence??!1,clearStyle:o,render:(e,n)=>{let i=v.document(e,t).convert(e,{display:n});return r.outerHTML(i)},reset:()=>{t.InputJax.reset(),s(t.InputJax)},outputStyle:async()=>{await n.font.loadDynamicFiles();let e=r.cssText(n.styleSheet(v.document(``,t)));return o(),e},transformer:e.transformer??null};return c.set(l,{enableHtml:!1,createInputJax:t=>new h({...e.tex,packages:i(e.tex?.packages,t)})}),l},w=(t,n)=>{if(l.has(n))throw Error("[@mdit/plugin-mathjax-slim] the instance is already installed on a MarkdownIt instance. Create a separate MathJax instance with `createMathjaxInstance` for each `MarkdownIt` instance");u(n,t.options.html),l.add(n);let{allowInlineWithSpace:r,delimiters:i,mathFence:a,render:o,reset:s,transformer:c}=n,d=t.render.bind(t),f=t.renderInline.bind(t);t.render=(e,t)=>{try{return d(e,t)}finally{s()}},t.renderInline=(e,t)=>{try{return f(e,t)}finally{s()}},t.use(e,{allowInlineWithSpace:r,delimiters:i,mathFence:a,render:(e,t)=>{let n=o(e,t);return c?.(n,t)??n}})};export{C as createMathjaxInstance,S as getDocumentOptions,w as mathjax};
9
+ if(!n.fontData&&!x)throw Error(`[@mdit/plugin-mathjax-slim] "@mathjax/mathjax-newcm-font" is not installed!`);let r=Object.assign({fontData:t?g:y},n?.fontData?{}:{dynamicPrefix:`@mathjax/mathjax-newcm-font/js/${t?`chtml`:`svg`}/dynamic`},t&&!n.fontData?{fontURL:`https://cdn.jsdelivr.net/npm/@mathjax/mathjax-newcm-font/chtml/woff2`}:{},n);v.asyncLoad=t=>(e.debug&&console.debug(`[MathJax]: loading ${t}...`),import(t));let o=e.tex?.packages;return await a([...i(o),`html`,`texhtml`]),{InputJax:new h({...e.tex,packages:i(o)}),OutputJax:new(t?f:m)(r),enableAssistiveMml:e.a11y!==!1}},C=async(e={})=>{let t=await S(e),{OutputJax:n}=t,r=_(),a=p(r);d(a);let o=()=>{n.adaptor!=null&&(t.InputJax.reset(),n.reset())},l={adaptor:r,documentOptions:t,allowInlineWithSpace:e.allowInlineWithSpace??!1,delimiters:e.delimiters??`dollars`,mathFence:e.mathFence??!1,clearStyle:o,render:(e,n)=>{let i=v.document(e,t).convert(e,{display:n});return r.outerHTML(i)},reset:()=>{t.InputJax.reset(),s(t.InputJax)},outputStyle:async()=>{await n.font.loadDynamicFiles();let e=r.cssText(n.styleSheet(v.document(``,t)));return o(),e},transformer:e.transformer??null};return c.set(l,{enableHtml:!1,createInputJax:t=>new h({...e.tex,packages:i(e.tex?.packages,t)})}),l},w=(t,n)=>{if(l.has(n))throw Error("[@mdit/plugin-mathjax-slim] the instance is already installed on a MarkdownIt instance. Create a separate MathJax instance with `createMathjaxInstance` for each `MarkdownIt` instance");u(n,t.options.html),l.add(n);let{allowInlineWithSpace:r,delimiters:i,mathFence:a,render:o,reset:s,transformer:c}=n,d=t.render.bind(t),f=t.renderInline.bind(t);t.render=(e,t)=>{try{return d(e,t)}finally{s()}},t.renderInline=(e,t)=>{try{return f(e,t)}finally{s()}},t.use(e,{allowInlineWithSpace:r,delimiters:i,mathFence:a,render:(e,t)=>{let n=o(e,t);return c?.(n,t)??n}})};export{C as createMathjaxInstance,S as getDocumentOptions,w as mathjax};
10
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["texPackages","texLoaders","HTML_PACKAGES","resolveTexPackages","packages","userPackages","pkg","enableHtml","loadTexPackages","USER_MAP_NAMES","clearUserState","name","InputJax","instanceTexStates","installedInstances","applyHtmlPackages","state","instance","AssistiveMmlHandler","CHTML","RegisterHTMLHandler","SVG","TeX","chtmlFont","liteAdaptor","mathjaxLib","svgFont","isMathJaxInstalled","isMathJaxNewcmFontInstalled","getDocumentOptions","isCHTML","options","userOptions","outputOptions","file","createMathjaxInstance","documentOptions","adaptor","handler","clearStyle","OutputJax","mathDocument","content","displayMode","style","mathjax","md","renderMath","render","renderInline","src","env","reset","tex","result","transformer"],"sources":["../../src/tex/packages.ts","../../src/tex/loader.ts","../../src/tex/utils.ts","../../src/utils.ts","../../src/async/plugin.ts"],"sourcesContent":["import type { TexPackage } from \"../mathjax.js\";\n\n/**\n * Default TeX packages.\n *\n * The HTML-related packages (`html`, which provides `\\href`, `\\class`, `\\style` and `\\cssId`, and\n * `texhtml`, which registers the `<tex-html>` handler) are intentionally excluded. They are added\n * to the default list when the markdown-it instance enables raw HTML (`new MarkdownIt({ html: true\n * })`), or can be enabled explicitly through `tex.packages`, see `resolveTexPackages` in\n * `./utils.ts`.\n *\n * The font-extension packages (`bbm`, `bboldx` and `dsfont`) are also excluded: the bundled\n * `@mathjax/mathjax-newcm-font` font does not ship their extension data, so loading them would\n * replace standard macros (e.g. `\\mathbb`) with missing font variants and fall back with an\n * `Invalid variant` warning. They can still be enabled explicitly through `tex.packages`.\n *\n * 默认 TeX 包。\n *\n * 提供 `\\href`、`\\class`、`\\style`、`\\cssId` 等能力的 HTML 相关包(`html`)与注册 `<tex-html>` 处理器的 `texhtml`\n * 默认不启用:仅在 markdown-it 实例开启 `html: true` 时加入默认列表,或通过 `tex.packages` 显式启用, 见 `./utils.ts` 的\n * `resolveTexPackages`。\n *\n * 依赖字体扩展数据的 `bbm`、`bboldx`、`dsfont` 同样默认不启用:随包的 `@mathjax/mathjax-newcm-font`\n * 字体不包含这些扩展数据,加载后会用缺失的字体变体替换标准宏(如 `\\mathbb`)并触发 `Invalid variant` 警告后回退。 仍可通过 `tex.packages` 显式启用。\n */\nexport const texPackages: TexPackage[] = [\n \"action\",\n \"ams\",\n \"amscd\",\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 \"empheq\",\n \"enclose\",\n \"extpfeil\",\n \"gensymb\",\n \"mathtools\",\n \"mhchem\",\n \"newcommand\",\n \"noerrors\",\n \"noundefined\",\n \"physics\",\n \"setoptions\",\n \"tagformat\",\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\n/**\n * TeX packages that provide HTML-related capabilities: `html` adds `\\href`, `\\class`, `\\style` and\n * `\\cssId`, and `texhtml` registers the `<tex-html>` handler (inert unless MathJax's `allowTexHTML`\n * option is enabled).\n *\n * 提供 HTML 相关能力的 TeX 包:`html` 提供 `\\href`、`\\class`、`\\style`、`\\cssId`;`texhtml` 注册 `<tex-html>`\n * 处理器(除非开启 MathJax 的 `allowTexHTML` 选项,否则不生效)。\n */\nconst HTML_PACKAGES: TexPackage[] = [\"html\", \"texhtml\"];\n\n/**\n * Resolve the TeX packages to load.\n *\n * The default package list never contains the HTML-related packages; they are only added to that\n * default list when the markdown-it instance enables raw HTML. An explicit `tex.packages` list is\n * treated as trusted developer configuration and used as-is, so enabling the HTML-related packages\n * is possible even when markdown-it itself has raw HTML disabled.\n *\n * 解析需要加载的 TeX 包。\n *\n * 默认包列表从不包含 HTML 相关包;仅当 markdown-it 实例开启原始 HTML 时才会把它们加入默认列表。 显式提供的 `tex.packages`\n * 视为可信的开发者配置并原样使用,因此即使 markdown-it 关闭原始 HTML,也可以启用 HTML 相关包。\n *\n * @param userPackages - User-defined packages / 用户定义的包\n * @param enableHtml - Whether markdown-it enables HTML / markdown-it 是否开启 HTML\n * @returns Resolved package list with `base` first / 解析后的包列表(`base` 在最前)\n */\nexport const resolveTexPackages = (\n userPackages?: TexPackage[],\n enableHtml = false,\n): TexPackage[] => {\n // `base` is always loaded and is not part of the public `TexPackage` union.\n // `base` 总会加载,且不在公开的 `TexPackage` 联合类型中。\n const packages = new Set<string>([\"base\"]);\n\n if (userPackages) {\n // Trusted developer configuration: use the list as-is.\n // 可信的开发者配置:原样使用该列表。\n for (const pkg of userPackages) packages.add(pkg);\n } else {\n for (const pkg of texPackages) packages.add(pkg);\n\n // The markdown-it `html` option only decides the default package list.\n // markdown-it 的 `html` 选项只决定默认包列表。\n if (enableHtml) for (const pkg of HTML_PACKAGES) packages.add(pkg);\n }\n\n return [...packages] as TexPackage[];\n};\n\n/**\n * Load the given TeX packages with MathJax's official async API.\n *\n * 使用 MathJax 官方异步 API 加载指定的 TeX 包。\n *\n * @param packages - Packages to load / 需要加载的包\n * @returns Promise resolved when all packages are loaded / 所有包加载完成时 resolve 的 Promise\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) => Object.hasOwn(texLoaders, 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\";\n\ninterface TeXMacroMap {\n map: Map<string, unknown>;\n}\n\n// MathJax keeps user-defined macros, environments and delimiters in the internal `new-*` maps of\n// the `newcommand` package. Their names are unique across handler types, so they can be looked up\n// by name, which avoids importing the `HandlerType` enum: a value import would add a runtime import\n// of the optional `@mathjax/src` peer to the `worker` and `async/index` entries.\nconst USER_MAP_NAMES = [\"new-Command\", \"new-Environment\", \"new-Delimiter\"] as const;\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 name of USER_MAP_NAMES) {\n const userMap = InputJax.parseOptions.handlers.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, resolveTexPackages } from \"../tex/index.js\";\nimport { clearUserState } from \"../utils.js\";\n\ntype InputJax = DocumentOptions[\"InputJax\"];\n\ninterface InstanceTexState {\n /** Whether HTML-related TeX packages are enabled / 是否启用 HTML 相关 TeX 包 */\n enableHtml: boolean;\n\n /** Create a TeX input jax with the given HTML capability / 创建具有指定 HTML 能力的 TeX 输入 jax */\n createInputJax: (enableHtml: boolean) => InputJax;\n}\n\nconst instanceTexStates = new WeakMap<MathjaxInstance, InstanceTexState>();\n\n/**\n * MathJax instances that are already installed on a markdown-it instance.\n *\n * A MathJax instance owns shared TeX state, so it must not be shared by multiple markdown-it\n * instances with different trust levels.\n *\n * 已安装到 markdown-it 实例上的 MathJax 实例。\n *\n * MathJax 实例持有共享的 TeX 状态,因此同一个实例不能被多个信任级别不同的 markdown-it 实例共用。\n */\nconst installedInstances = new WeakSet<MathjaxInstance>();\n\n/**\n * Match the HTML-related TeX packages of an instance with the markdown-it `html` option.\n *\n * 让实例的 HTML 相关 TeX 包与 markdown-it 的 `html` 选项保持一致。\n *\n * @param instance - MathJax instance / MathJax 实例\n * @param enableHtml - Whether HTML is enabled / 是否启用 HTML\n */\nconst applyHtmlPackages = (instance: MathjaxInstance, enableHtml: boolean): void => {\n const state = instanceTexStates.get(instance);\n\n if (!state) {\n throw new Error(\n \"[@mdit/plugin-mathjax-slim] the given instance was not created by `createMathjaxInstance` from this package\",\n );\n }\n\n if (state.enableHtml === enableHtml) return;\n\n instance.documentOptions.InputJax = state.createInputJax(enableHtml);\n state.enableHtml = enableHtml;\n};\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 const userPackages = options.tex?.packages;\n\n // Load the HTML-related packages eagerly: `mathjax()` decides about them synchronously once the\n // markdown-it instance is available, so their configurations must already be registered.\n await loadTexPackages([...resolveTexPackages(userPackages), \"html\", \"texhtml\"]);\n\n return {\n InputJax: new TeX<LiteElement, string, HTMLElement>({\n ...options.tex,\n packages: resolveTexPackages(userPackages),\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 } = 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 documentOptions.InputJax.reset();\n OutputJax.reset();\n };\n\n const reset = (): void => {\n documentOptions.InputJax.reset();\n clearUserState(documentOptions.InputJax);\n };\n\n const render = (content: string, displayMode: boolean): string => {\n const mathDocument = mathjaxLib\n .document(content, documentOptions)\n .convert(content, { display: displayMode }) as LiteElement;\n\n return adaptor.outerHTML(mathDocument);\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 const instance: MathjaxInstance = {\n adaptor,\n documentOptions,\n allowInlineWithSpace: options.allowInlineWithSpace ?? false,\n delimiters: options.delimiters ?? \"dollars\",\n mathFence: options.mathFence ?? false,\n clearStyle,\n render,\n reset,\n outputStyle,\n transformer: options.transformer ?? null,\n };\n\n instanceTexStates.set(instance, {\n enableHtml: false,\n createInputJax: (enableHtml: boolean): InputJax =>\n new TeX<LiteElement, string, HTMLElement>({\n ...options.tex,\n packages: resolveTexPackages(options.tex?.packages, enableHtml),\n }),\n });\n\n return instance;\n};\n\nexport const mathjax = (md: MarkdownIt, instance: MathjaxInstance): void => {\n if (installedInstances.has(instance)) {\n throw new Error(\n \"[@mdit/plugin-mathjax-slim] the instance is already installed on a MarkdownIt instance. Create a separate MathJax instance with `createMathjaxInstance` for each `MarkdownIt` instance\",\n );\n }\n\n // The markdown-it `html` option is read when the plugin is installed; later changes through\n // `md.set()` are intentionally not observed, so a single MathJax instance always maps to a single\n // trust level.\n // markdown-it 的 `html` 选项在插件安装时读取;之后通过 `md.set()` 的修改不会生效,从而保证一个\n // MathJax 实例只对应一个信任级别。\n applyHtmlPackages(instance, md.options.html);\n\n installedInstances.add(instance);\n\n const {\n allowInlineWithSpace,\n delimiters,\n mathFence,\n render: renderMath,\n reset,\n transformer,\n } = instance;\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 result = renderMath(content, displayMode);\n\n return transformer?.(result, displayMode) ?? result;\n },\n });\n};\n"],"mappings":"A,uCAyBA,MAAaA,EAA4B,iTAkCzC,ECzDaC,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,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AC1BG,EAAeH,EAAG,aAAa,KAAKA,CAAE,EAE5C,EAAG,QAAU,EAAK,IAAgB,CAChC,GAAI,CACF,OAAOE,EAAOE,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,EAEAN,EAAG,IAAIO,EAAK,CACV,uBACA,aACA,YACA,QAAS,EAAS,IAAgB,CAChC,IAAMC,EAASP,EAAWL,EAASC,CAAW,EAE9C,OAAOY,IAAcD,EAAQX,CAAW,GAAKW,CAC/C,CACF,CAAC,CACH,E"}
1
+ {"version":3,"file":"index.js","names":["texPackages","texLoaders","HTML_PACKAGES","resolveTexPackages","packages","userPackages","pkg","enableHtml","loadTexPackages","USER_MAP_NAMES","clearUserState","name","InputJax","instanceTexStates","installedInstances","applyHtmlPackages","state","instance","AssistiveMmlHandler","CHTML","RegisterHTMLHandler","SVG","TeX","chtmlFont","liteAdaptor","mathjaxLib","svgFont","isMathJaxInstalled","isMathJaxNewcmFontInstalled","getDocumentOptions","isCHTML","options","userOptions","outputOptions","file","createMathjaxInstance","documentOptions","adaptor","handler","clearStyle","OutputJax","mathDocument","content","displayMode","style","mathjax","md","renderMath","render","renderInline","src","env","reset","tex","result","transformer"],"sources":["../../src/tex/packages.ts","../../src/tex/loader.ts","../../src/tex/utils.ts","../../src/utils.ts","../../src/async/plugin.ts"],"sourcesContent":["import type { TexPackage } from \"../mathjax.js\";\n\n/**\n * Default TeX packages.\n *\n * The HTML-related packages (`html`, which provides `\\href`, `\\class`, `\\style` and `\\cssId`, and\n * `texhtml`, which registers the `<tex-html>` handler) are intentionally excluded. They are added\n * to the default list when the markdown-it instance enables raw HTML (`new MarkdownIt({ html: true\n * })`), or can be enabled explicitly through `tex.packages`, see `resolveTexPackages` in\n * `./utils.ts`.\n *\n * The font-extension packages (`bbm`, `bboldx` and `dsfont`) are also excluded: the bundled\n * `@mathjax/mathjax-newcm-font` font does not ship their extension data, so loading them would\n * replace standard macros (e.g. `\\mathbb`) with missing font variants and fall back with an\n * `Invalid variant` warning. They can still be enabled explicitly through `tex.packages`.\n *\n * 默认 TeX 包。\n *\n * 提供 `\\href`、`\\class`、`\\style`、`\\cssId` 等能力的 HTML 相关包(`html`)与注册 `<tex-html>` 处理器的 `texhtml`\n * 默认不启用:仅在 markdown-it 实例开启 `html: true` 时加入默认列表,或通过 `tex.packages` 显式启用, 见 `./utils.ts` 的\n * `resolveTexPackages`。\n *\n * 依赖字体扩展数据的 `bbm`、`bboldx`、`dsfont` 同样默认不启用:随包的 `@mathjax/mathjax-newcm-font`\n * 字体不包含这些扩展数据,加载后会用缺失的字体变体替换标准宏(如 `\\mathbb`)并触发 `Invalid variant` 警告后回退。 仍可通过 `tex.packages` 显式启用。\n */\nexport const texPackages: TexPackage[] = [\n \"action\",\n \"ams\",\n \"amscd\",\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 \"empheq\",\n \"enclose\",\n \"extpfeil\",\n \"gensymb\",\n \"mathtools\",\n \"mhchem\",\n \"newcommand\",\n \"noerrors\",\n \"noundefined\",\n \"physics\",\n \"setoptions\",\n \"tagformat\",\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\n/**\n * TeX packages that provide HTML-related capabilities: `html` adds `\\href`, `\\class`, `\\style` and\n * `\\cssId`, and `texhtml` registers the `<tex-html>` handler (inert unless MathJax's `allowTexHTML`\n * option is enabled).\n *\n * 提供 HTML 相关能力的 TeX 包:`html` 提供 `\\href`、`\\class`、`\\style`、`\\cssId`;`texhtml` 注册 `<tex-html>`\n * 处理器(除非开启 MathJax 的 `allowTexHTML` 选项,否则不生效)。\n */\nconst HTML_PACKAGES: TexPackage[] = [\"html\", \"texhtml\"];\n\n/**\n * Resolve the TeX packages to load.\n *\n * The default package list never contains the HTML-related packages; they are only added to that\n * default list when the markdown-it instance enables raw HTML. An explicit `tex.packages` list is\n * treated as trusted developer configuration and used as-is, so enabling the HTML-related packages\n * is possible even when markdown-it itself has raw HTML disabled.\n *\n * 解析需要加载的 TeX 包。\n *\n * 默认包列表从不包含 HTML 相关包;仅当 markdown-it 实例开启原始 HTML 时才会把它们加入默认列表。 显式提供的 `tex.packages`\n * 视为可信的开发者配置并原样使用,因此即使 markdown-it 关闭原始 HTML,也可以启用 HTML 相关包。\n *\n * @param userPackages - User-defined packages / 用户定义的包\n * @param enableHtml - Whether markdown-it enables HTML / markdown-it 是否开启 HTML\n * @returns Resolved package list with `base` first / 解析后的包列表(`base` 在最前)\n */\nexport const resolveTexPackages = (\n userPackages?: TexPackage[],\n enableHtml = false,\n): TexPackage[] => {\n // `base` is always loaded and is not part of the public `TexPackage` union.\n // `base` 总会加载,且不在公开的 `TexPackage` 联合类型中。\n const packages = new Set<string>([\"base\"]);\n\n if (userPackages) {\n // Trusted developer configuration: use the list as-is.\n // 可信的开发者配置:原样使用该列表。\n for (const pkg of userPackages) packages.add(pkg);\n } else {\n for (const pkg of texPackages) packages.add(pkg);\n\n // The markdown-it `html` option only decides the default package list.\n // markdown-it 的 `html` 选项只决定默认包列表。\n if (enableHtml) for (const pkg of HTML_PACKAGES) packages.add(pkg);\n }\n\n return [...packages] as TexPackage[];\n};\n\n/**\n * Load the given TeX packages with MathJax's official async API.\n *\n * 使用 MathJax 官方异步 API 加载指定的 TeX 包。\n *\n * @param packages - Packages to load / 需要加载的包\n * @returns Promise resolved when all packages are loaded / 所有包加载完成时 resolve 的 Promise\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) => Object.hasOwn(texLoaders, 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\";\n\ninterface TeXMacroMap {\n map: Map<string, unknown>;\n}\n\n// MathJax keeps user-defined macros, environments and delimiters in the internal `new-*` maps of\n// the `newcommand` package. Their names are unique across handler types, so they can be looked up\n// by name, which avoids importing the `HandlerType` enum: a value import would add a runtime import\n// of the optional `@mathjax/src` peer to the `worker` and `async/index` entries.\nconst USER_MAP_NAMES = [\"new-Command\", \"new-Environment\", \"new-Delimiter\"] as const;\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 name of USER_MAP_NAMES) {\n const userMap = InputJax.parseOptions.handlers.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, resolveTexPackages } from \"../tex/index.js\";\nimport { clearUserState } from \"../utils.js\";\n\ntype InputJax = DocumentOptions[\"InputJax\"];\n\ninterface InstanceTexState {\n /** Whether HTML-related TeX packages are enabled / 是否启用 HTML 相关 TeX 包 */\n enableHtml: boolean;\n\n /** Create a TeX input jax with the given HTML capability / 创建具有指定 HTML 能力的 TeX 输入 jax */\n createInputJax: (enableHtml: boolean) => InputJax;\n}\n\nconst instanceTexStates = new WeakMap<MathjaxInstance, InstanceTexState>();\n\n/**\n * MathJax instances that are already installed on a markdown-it instance.\n *\n * A MathJax instance owns shared TeX state, so it must not be shared by multiple markdown-it\n * instances with different trust levels.\n *\n * 已安装到 markdown-it 实例上的 MathJax 实例。\n *\n * MathJax 实例持有共享的 TeX 状态,因此同一个实例不能被多个信任级别不同的 markdown-it 实例共用。\n */\nconst installedInstances = new WeakSet<MathjaxInstance>();\n\n/**\n * Match the HTML-related TeX packages of an instance with the markdown-it `html` option.\n *\n * 让实例的 HTML 相关 TeX 包与 markdown-it 的 `html` 选项保持一致。\n *\n * @param instance - MathJax instance / MathJax 实例\n * @param enableHtml - Whether HTML is enabled / 是否启用 HTML\n */\nconst applyHtmlPackages = (instance: MathjaxInstance, enableHtml: boolean): void => {\n const state = instanceTexStates.get(instance);\n\n if (!state) {\n throw new Error(\n \"[@mdit/plugin-mathjax-slim] the given instance was not created by `createMathjaxInstance` from this package\",\n );\n }\n\n if (state.enableHtml === enableHtml) return;\n\n instance.documentOptions.InputJax = state.createInputJax(enableHtml);\n state.enableHtml = enableHtml;\n};\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 const userPackages = options.tex?.packages;\n\n // Load the HTML-related packages eagerly: `mathjax()` decides about them synchronously once the\n // markdown-it instance is available, so their configurations must already be registered.\n await loadTexPackages([...resolveTexPackages(userPackages), \"html\", \"texhtml\"]);\n\n return {\n InputJax: new TeX<LiteElement, string, HTMLElement>({\n ...options.tex,\n packages: resolveTexPackages(userPackages),\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 } = documentOptions;\n\n const adaptor = liteAdaptor();\n // oxlint-disable-next-line new-cap\n const handler = RegisterHTMLHandler(adaptor);\n\n // Always mix in the a11y document: `enableAssistiveMml` is a document option that only exists\n // once the assistive-mml mixin is applied. The option itself decides whether assistive MathML is\n // produced. Applying the mixin conditionally would leak the first registered handler's choice to\n // later instances (MathJax uses the first global handler for an adaptor) and makes MathJax warn\n // about an unknown `enableAssistiveMml` option when a11y is disabled.\n // oxlint-disable-next-line new-cap\n 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 documentOptions.InputJax.reset();\n OutputJax.reset();\n };\n\n const reset = (): void => {\n documentOptions.InputJax.reset();\n clearUserState(documentOptions.InputJax);\n };\n\n const render = (content: string, displayMode: boolean): string => {\n const mathDocument = mathjaxLib\n .document(content, documentOptions)\n .convert(content, { display: displayMode }) as LiteElement;\n\n return adaptor.outerHTML(mathDocument);\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 const instance: MathjaxInstance = {\n adaptor,\n documentOptions,\n allowInlineWithSpace: options.allowInlineWithSpace ?? false,\n delimiters: options.delimiters ?? \"dollars\",\n mathFence: options.mathFence ?? false,\n clearStyle,\n render,\n reset,\n outputStyle,\n transformer: options.transformer ?? null,\n };\n\n instanceTexStates.set(instance, {\n enableHtml: false,\n createInputJax: (enableHtml: boolean): InputJax =>\n new TeX<LiteElement, string, HTMLElement>({\n ...options.tex,\n packages: resolveTexPackages(options.tex?.packages, enableHtml),\n }),\n });\n\n return instance;\n};\n\nexport const mathjax = (md: MarkdownIt, instance: MathjaxInstance): void => {\n if (installedInstances.has(instance)) {\n throw new Error(\n \"[@mdit/plugin-mathjax-slim] the instance is already installed on a MarkdownIt instance. Create a separate MathJax instance with `createMathjaxInstance` for each `MarkdownIt` instance\",\n );\n }\n\n // The markdown-it `html` option is read when the plugin is installed; later changes through\n // `md.set()` are intentionally not observed, so a single MathJax instance always maps to a single\n // trust level.\n // markdown-it 的 `html` 选项在插件安装时读取;之后通过 `md.set()` 的修改不会生效,从而保证一个\n // MathJax 实例只对应一个信任级别。\n applyHtmlPackages(instance, md.options.html);\n\n installedInstances.add(instance);\n\n const {\n allowInlineWithSpace,\n delimiters,\n mathFence,\n render: renderMath,\n reset,\n transformer,\n } = instance;\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 result = renderMath(content, displayMode);\n\n return transformer?.(result, displayMode) ?? result;\n },\n });\n};\n"],"mappings":"A,uCAyBA,MAAaA,EAA4B,iTAkCzC,ECzDaC,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,OA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AAE,EAE5C,EAAG,QAAU,EAAK,IAAgB,CAChC,GAAI,CACF,OAAOE,EAAOE,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,EAEAN,EAAG,IAAIO,EAAK,CACV,uBACA,aACA,YACA,QAAS,EAAS,IAAgB,CAChC,IAAMC,EAASP,EAAWL,EAASC,CAAW,EAE9C,OAAOY,IAAcD,EAAQX,CAAW,GAAKW,CAC/C,CACF,CAAC,CACH,E"}
package/dist/index.d.ts CHANGED
@@ -324,9 +324,10 @@ interface MarkdownItMathjaxOptions extends Pick<MarkdownItTexOptions, "allowInli
324
324
  */
325
325
  output?: "chtml" | "svg";
326
326
  /**
327
- * Enable A11y
327
+ * Whether to include assistive MathML for screen readers. When disabled, math is still rendered
328
+ * but the hidden `<mjx-assistive-mml>` output is omitted.
328
329
  *
329
- * 是否启用无障碍
330
+ * 是否包含供屏幕阅读器使用的辅助 MathML。关闭后数学公式仍会渲染,但不再输出隐藏的 `<mjx-assistive-mml>`。
330
331
  *
331
332
  * @default true
332
333
  */
@@ -514,5 +515,4 @@ export declare const installSyncMathjax: (md: MarkdownIt, options?: MarkdownItSy
514
515
  * @returns MathJax methods / MathJax 方法集合
515
516
  */
516
517
  export declare const getMathjax: (md: MarkdownIt) => MathjaxMethods;
517
- export { type DocumentOptions, type MarkdownItMathjaxOptions, type MathJaxTexInputOptions, type MathjaxCommonHTMLOutputOptions, type MathjaxCommonOutputOptions, type MathjaxFilter, type MathjaxFilterData, type MathjaxInstance, type MathjaxSVGOutputOptions, type TeXTransformer, type TexPackage, installSyncMathjax as mathjax };
518
- //# sourceMappingURL=index.d.ts.map
518
+ export { type DocumentOptions, type MarkdownItMathjaxOptions, type MathJaxTexInputOptions, type MathjaxCommonHTMLOutputOptions, type MathjaxCommonOutputOptions, type MathjaxFilter, type MathjaxFilterData, type MathjaxInstance, type MathjaxSVGOutputOptions, type TeXTransformer, type TexPackage, installSyncMathjax as mathjax };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mdit/plugin-mathjax-slim",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Mathjax plugin for MarkdownIt",
5
5
  "keywords": [
6
6
  "markdown-it",
@@ -46,7 +46,7 @@
46
46
  "clean": "rimraf ./dist"
47
47
  },
48
48
  "dependencies": {
49
- "@mdit/plugin-tex": "1.2.0",
49
+ "@mdit/plugin-tex": "1.3.0",
50
50
  "synckit": "^0.12.3"
51
51
  },
52
52
  "devDependencies": {
@@ -72,5 +72,5 @@
72
72
  "engines": {
73
73
  "node": ">=22"
74
74
  },
75
- "gitHead": "34cbd263c63502f4d2ef55ab9f9defe790e7bf88"
75
+ "gitHead": "9f02fe8110ff5ea45f89e24605f9abfba59aefeb"
76
76
  }