@mdit/plugin-mathjax-slim 0.23.3-cjs.0 → 0.24.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
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Version](https://img.shields.io/npm/v/@mdit/plugin-mathjax-slim.svg?style=flat-square&logo=npm) ![Downloads](https://img.shields.io/npm/dm/@mdit/plugin-mathjax-slim.svg?style=flat-square&logo=npm) ![Size](https://img.shields.io/bundlephobia/min/@mdit/plugin-mathjax-slim?style=flat-square&logo=npm)](https://www.npmjs.com/package/@mdit/plugin-mathjax-slim)
4
4
 
5
- Mathjax plugin for MarkdownIt. `mathjax-full` is declared as an optional peer dependency here.
5
+ Mathjax plugin for MarkdownIt. `@mathjax/src` is declared as an optional peer dependency here.
6
6
 
7
7
  This package can only run in Node.js environment.
8
8
 
@@ -12,9 +12,9 @@ This package can only run in Node.js environment.
12
12
 
13
13
  ```bash
14
14
  # pnpm
15
- pnpm add -D @mdit/plugin-mathjax-slim mathjax-full
15
+ pnpm add -D @mdit/plugin-mathjax-slim @mathjax/src
16
16
  # npm
17
- npm i -D @mdit/plugin-mathjax-slim mathjax-full
17
+ npm i -D @mdit/plugin-mathjax-slim @mathjax/src
18
18
  # yarn
19
- yarn add -D @mdit/plugin-mathjax-slim mathjax-full
19
+ yarn add -D @mdit/plugin-mathjax-slim @mathjax/src
20
20
  ```
@@ -0,0 +1,2 @@
1
+ import"@mathjax/src/js/input/tex/action/ActionConfiguration.js";import"@mathjax/src/js/input/tex/ams/AmsConfiguration.js";import"@mathjax/src/js/input/tex/amscd/AmsCdConfiguration.js";import"@mathjax/src/js/input/tex/base/BaseConfiguration.js";import"@mathjax/src/js/input/tex/bbm/BbmConfiguration.js";import"@mathjax/src/js/input/tex/bboldx/BboldxConfiguration.js";import"@mathjax/src/js/input/tex/bbox/BboxConfiguration.js";import"@mathjax/src/js/input/tex/begingroup/BegingroupConfiguration.js";import"@mathjax/src/js/input/tex/boldsymbol/BoldsymbolConfiguration.js";import"@mathjax/src/js/input/tex/braket/BraketConfiguration.js";import"@mathjax/src/js/input/tex/bussproofs/BussproofsConfiguration.js";import"@mathjax/src/js/input/tex/cancel/CancelConfiguration.js";import"@mathjax/src/js/input/tex/cases/CasesConfiguration.js";import"@mathjax/src/js/input/tex/centernot/CenternotConfiguration.js";import"@mathjax/src/js/input/tex/color/ColorConfiguration.js";import"@mathjax/src/js/input/tex/colortbl/ColortblConfiguration.js";import"@mathjax/src/js/input/tex/colorv2/ColorV2Configuration.js";import"@mathjax/src/js/input/tex/configmacros/ConfigMacrosConfiguration.js";import"@mathjax/src/js/input/tex/dsfont/DsfontConfiguration.js";import"@mathjax/src/js/input/tex/empheq/EmpheqConfiguration.js";import"@mathjax/src/js/input/tex/enclose/EncloseConfiguration.js";import"@mathjax/src/js/input/tex/extpfeil/ExtpfeilConfiguration.js";import"@mathjax/src/js/input/tex/gensymb/GensymbConfiguration.js";import"@mathjax/src/js/input/tex/html/HtmlConfiguration.js";import"@mathjax/src/js/input/tex/mathtools/MathtoolsConfiguration.js";import"@mathjax/src/js/input/tex/mhchem/MhchemConfiguration.js";import"@mathjax/src/js/input/tex/newcommand/NewcommandConfiguration.js";import"@mathjax/src/js/input/tex/noerrors/NoErrorsConfiguration.js";import"@mathjax/src/js/input/tex/noundefined/NoUndefinedConfiguration.js";import"@mathjax/src/js/input/tex/physics/PhysicsConfiguration.js";import"@mathjax/src/js/input/tex/setoptions/SetOptionsConfiguration.js";import"@mathjax/src/js/input/tex/tagformat/TagFormatConfiguration.js";import"@mathjax/src/js/input/tex/texhtml/TexHtmlConfiguration.js";import"@mathjax/src/js/input/tex/textcomp/TextcompConfiguration.js";import"@mathjax/src/js/input/tex/textmacros/TextMacrosConfiguration.js";import"@mathjax/src/js/input/tex/unicode/UnicodeConfiguration.js";import"@mathjax/src/js/input/tex/units/UnitsConfiguration.js";import"@mathjax/src/js/input/tex/upgreek/UpgreekConfiguration.js";import"@mathjax/src/js/input/tex/verb/VerbConfiguration.js";
2
+ //# sourceMappingURL=importer-C5KF-eLj.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"importer-C5KF-eLj.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/lib/index.d.ts CHANGED
@@ -1,13 +1,14 @@
1
- import { MmlNode } from 'mathjax-full/js/core/MmlTree/MmlNode.js';
2
- import TexError from 'mathjax-full/js/input/tex/TexError.js';
3
- import { TeX } from 'mathjax-full/js/input/tex.js';
1
+ import { MmlNode } from '@mathjax/src/js/core/MmlTree/MmlNode.js';
2
+ import TexError from '@mathjax/src/js/input/tex/TexError.js';
3
+ import { TeX } from '@mathjax/src/js/input/tex.js';
4
4
  import { MarkdownItTexOptions } from '@mdit/plugin-tex';
5
+ import { LiteElement } from '@mathjax/src/js/adaptors/lite/Element.js';
6
+ import { LiteAdaptor } from '@mathjax/src/js/adaptors/liteAdaptor.js';
7
+ import { CHTML } from '@mathjax/src/js/output/chtml.js';
8
+ import { SVG } from '@mathjax/src/js/output/svg.js';
5
9
  import MarkdownIt from 'markdown-it';
6
- import { LiteElement } from 'mathjax-full/js/adaptors/lite/Element.js';
7
- import { LiteAdaptor } from 'mathjax-full/js/adaptors/liteAdaptor.js';
8
- import { CHTML } from 'mathjax-full/js/output/chtml.js';
9
- import { SVG } from 'mathjax-full/js/output/svg.js';
10
10
 
11
+ type TexPackage = "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";
11
12
  interface MathJaxTexInputOptions {
12
13
  /**
13
14
  * extensions to use
@@ -17,7 +18,10 @@ interface MathJaxTexInputOptions {
17
18
  * 'action',
18
19
  * 'ams',
19
20
  * 'amscd',
21
+ * 'bbm',
22
+ * 'bboldx',
20
23
  * 'bbox',
24
+ * 'begingroup',
21
25
  * 'boldsymbol',
22
26
  * 'braket',
23
27
  * 'bussproofs',
@@ -26,6 +30,9 @@ interface MathJaxTexInputOptions {
26
30
  * 'centernot',
27
31
  * 'color',
28
32
  * 'colortbl',
33
+ * 'colorv2',
34
+ * 'configmacros',
35
+ * 'dsfont',
29
36
  * 'empheq',
30
37
  * 'enclose',
31
38
  * 'extpfeil',
@@ -36,16 +43,20 @@ interface MathJaxTexInputOptions {
36
43
  * 'newcommand',
37
44
  * 'noerrors',
38
45
  * 'noundefined',
39
- * 'upgreek',
40
- * 'unicode',
41
- * 'verb',
42
- * 'configmacros',
46
+ * 'physics',
47
+ * 'require',
48
+ * 'setoptions',
43
49
  * 'tagformat',
50
+ * 'texhtml',
44
51
  * 'textcomp',
45
- * 'textmacros'
52
+ * 'textmacros',
53
+ * 'unicode',
54
+ * 'units',
55
+ * 'upgreek',
56
+ * 'verb',
46
57
  * ]
47
58
  */
48
- packages?: string[];
59
+ packages?: TexPackage[];
49
60
  /**
50
61
  * pattern for recognizing numbers
51
62
  *
@@ -162,7 +173,7 @@ interface MathjaxCommonHTMLOutputOptions extends MathjaxCommonOutputOptions {
162
173
  /**
163
174
  * The URL where the fonts are found
164
175
  *
165
- * @default local form mathjax-full
176
+ * @default local form @mathjax/src
166
177
  */
167
178
  fontURL?: string;
168
179
  /**
@@ -246,7 +257,7 @@ interface DocumentOptions {
246
257
  OutputJax: CHTML<LiteElement, string, HTMLElement> | SVG<LiteElement, string, HTMLElement>;
247
258
  enableAssistiveMml: boolean;
248
259
  }
249
- declare const getDocumentOptions: (options: MarkdownItMathjaxOptions) => DocumentOptions;
260
+ declare const getDocumentOptions: (options: MarkdownItMathjaxOptions) => Promise<DocumentOptions>;
250
261
  /**
251
262
  * Mathjax instance
252
263
  */
@@ -278,8 +289,8 @@ interface MathjaxInstance extends Required<Pick<MarkdownItMathjaxOptions, "allow
278
289
  */
279
290
  transformer: TeXTransformer | null;
280
291
  }
281
- declare const createMathjaxInstance: (options?: MarkdownItMathjaxOptions) => MathjaxInstance | null;
292
+ declare const createMathjaxInstance: (options?: MarkdownItMathjaxOptions) => Promise<MathjaxInstance | null>;
282
293
  declare const mathjax: (md: MarkdownIt, { allowInlineWithSpace, adaptor, delimiters, documentOptions, mathFence, transformer, }: MathjaxInstance) => void;
283
294
 
284
295
  export { createMathjaxInstance, getDocumentOptions, mathjax };
285
- export type { DocumentOptions, MarkdownItMathjaxOptions, MathJaxTexInputOptions, MathjaxCommonHTMLOutputOptions, MathjaxCommonOutputOptions, MathjaxInstance, MathjaxSVGOutputOptions, TeXTransformer };
296
+ export type { DocumentOptions, MarkdownItMathjaxOptions, MathJaxTexInputOptions, MathjaxCommonHTMLOutputOptions, MathjaxCommonOutputOptions, MathjaxInstance, MathjaxSVGOutputOptions, TeXTransformer, TexPackage };
package/lib/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var v=Object.create;var p=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,T=Object.prototype.hasOwnProperty;var H=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of I(t))!T.call(e,a)&&a!==r&&p(e,a,{get:()=>t[a],enumerable:!(n=y(t,a))||n.enumerable});return e};var O=(e,t,r)=>(r=e!=null?v(g(e)):{},H(t||!e||!e.__esModule?p(r,"default",{value:e,enumerable:!0}):r,e));var L=require("@mdit/plugin-tex"),A=require("upath");let d=!0,c,x,f,m,q,S,w,M;try{({mathjax:c}=require("mathjax-full/js/mathjax.js")),{AllPackages:x}=require("mathjax-full/js/input/tex/AllPackages.js"),{TeX:f}=require("mathjax-full/js/input/tex.js"),{CHTML:m}=require("mathjax-full/js/output/chtml.js"),{SVG:q}=require("mathjax-full/js/output/svg.js"),{liteAdaptor:S}=require("mathjax-full/js/adaptors/liteAdaptor.js"),{RegisterHTMLHandler:w}=require("mathjax-full/js/handlers/html.js"),{AssistiveMmlHandler:M}=require("mathjax-full/js/a11y/assistive-mml.js")}catch{/* istanbul ignore next -- @preserve */d=!1}const j=e=>{/* istanbul ignore if -- @preserve */if(!d)throw new Error('[@mdit/mathjax] "mathjax-full" is not installed!');return{InputJax:new f({packages:x,...e.tex}),OutputJax:e.output==="chtml"?new m({fontURL:A.dirname(require.resolve("mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_Zero.woff")),adaptiveCSS:!0,...e.chtml}):new q({fontCache:"none",...e.svg}),enableAssistiveMml:e.a11y!==!1}},C=(e={})=>{const t=j(e),{OutputJax:r,InputJax:n}=t,a=S(),u=w(a);e.a11y!==!1&&M(u);const i=()=>{r instanceof m&&r.clearCache()},l=()=>{n.reset()},s=()=>{const o=a.innerHTML(r.styleSheet(c.document("",t)));return i(),o};return{adaptor:a,documentOptions:t,allowInlineWithSpace:e.allowInlineWithSpace??!1,delimiters:e.delimiters??"dollars",mathFence:e.mathFence??!1,clearStyle:i,reset:l,outputStyle:s,transformer:e.transformer??null}},F=(e,{allowInlineWithSpace:t,adaptor:r,delimiters:n,documentOptions:a,mathFence:u,transformer:i})=>{e.use(L.tex,{allowInlineWithSpace:t,delimiters:n,mathFence:u,render:(l,s)=>{const o=c.document(l,a).convert(l,{display:s}),h=r.outerHTML(o);return i?.(h,s)??h}})};exports.createMathjaxInstance=C,exports.getDocumentOptions=j,exports.mathjax=F;
1
+ import{tex as S}from"@mdit/plugin-tex";const c=["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"],v={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")},k=async(t=c)=>{await import("@mathjax/src/js/input/tex/base/BaseConfiguration.js"),await Promise.all(t.filter(e=>c.includes(e)).map(e=>v[e]()))};let h=!0,l,b,d,x,f,w,g;try{({mathjax:l}=await import("@mathjax/src/js/mathjax.js")),{TeX:b}=await import("@mathjax/src/js/input/tex.js"),{CHTML:d}=await import("@mathjax/src/js/output/chtml.js"),{SVG:x}=await import("@mathjax/src/js/output/svg.js"),{liteAdaptor:f}=await import("@mathjax/src/js/adaptors/liteAdaptor.js"),{RegisterHTMLHandler:w}=await import("@mathjax/src/js/handlers/html.js"),{AssistiveMmlHandler:g}=await import("@mathjax/src/js/a11y/assistive-mml.js")}catch{/* istanbul ignore next -- @preserve */h=!1}const y=async t=>{/* istanbul ignore if -- @preserve */if(!h)throw new Error('[@mdit/plugin-mathjax-slim] "@mathjax/src" is not installed!');return await k(t.tex?.packages),{InputJax:new b({packages:["base",...c],...t.tex}),OutputJax:t.output==="chtml"?new d({adaptiveCSS:!0,...t.chtml}):new x({fontCache:"none",...t.svg}),enableAssistiveMml:t.a11y!==!1}},I=async(t={})=>{const e=await y(t),{OutputJax:o,InputJax:n}=e,r=f(),s=w(r);t.a11y!==!1&&g(s);const a=()=>{o instanceof d&&o.clearCache()},i=()=>{n.reset()},m=()=>{const p=r.innerHTML(o.styleSheet(l.document("",e)));return a(),p};return{adaptor:r,documentOptions:e,allowInlineWithSpace:t.allowInlineWithSpace??!1,delimiters:t.delimiters??"dollars",mathFence:t.mathFence??!1,clearStyle:a,reset:i,outputStyle:m,transformer:t.transformer??null}},M=(t,{allowInlineWithSpace:e,adaptor:o,delimiters:n,documentOptions:r,mathFence:s,transformer:a})=>{t.use(S,{allowInlineWithSpace:e,delimiters:n,mathFence:s,render:(i,m)=>{const p=l.document(i,r).convert(i,{display:m}),u=o.outerHTML(p);return a?.(u,m)??u}})};export{I as createMathjaxInstance,y as getDocumentOptions,M as mathjax};
2
2
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/plugin.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-require-imports */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/**\n * Forked from https://github.com/tani/markdown-it-mathjax3/blob/master/index.ts\n */\n\n/* eslint-disable @typescript-eslint/consistent-type-imports */\n\nimport { tex } from \"@mdit/plugin-tex\";\nimport type MarkdownIt from \"markdown-it\";\nimport type { LiteDocument } from \"mathjax-full/js/adaptors/lite/Document.js\";\nimport type {\n LiteElement,\n LiteNode,\n} from \"mathjax-full/js/adaptors/lite/Element.js\";\nimport type { LiteText } from \"mathjax-full/js/adaptors/lite/Text.js\";\nimport type { LiteAdaptor } from \"mathjax-full/js/adaptors/liteAdaptor.js\";\nimport type { MathDocument } from \"mathjax-full/js/core/MathDocument.js\";\nimport type { TeX as TeXType } from \"mathjax-full/js/input/tex.js\";\nimport type { CHTML as CHTMLType } from \"mathjax-full/js/output/chtml.js\";\nimport type { SVG as SVGType } from \"mathjax-full/js/output/svg.js\";\nimport path from \"upath\";\n\nimport type { MarkdownItMathjaxOptions, TeXTransformer } from \"./options.js\";\n\nlet isMathJaxFullInstalled = true;\nlet mathjaxLib: typeof import(\"mathjax-full/js/mathjax.js\").mathjax;\nlet AllPackages: typeof import(\"mathjax-full/js/input/tex/AllPackages.js\").AllPackages;\nlet TeX: typeof import(\"mathjax-full/js/input/tex.js\").TeX;\nlet CHTML: typeof import(\"mathjax-full/js/output/chtml.js\").CHTML;\nlet SVG: typeof import(\"mathjax-full/js/output/svg.js\").SVG;\nlet liteAdaptor: typeof import(\"mathjax-full/js/adaptors/liteAdaptor.js\").liteAdaptor;\nlet RegisterHTMLHandler: typeof import(\"mathjax-full/js/handlers/html.js\").RegisterHTMLHandler;\nlet AssistiveMmlHandler: typeof import(\"mathjax-full/js/a11y/assistive-mml.js\").AssistiveMmlHandler;\n\ntry {\n ({ mathjax: mathjaxLib } = require(\"mathjax-full/js/mathjax.js\"));\n ({ AllPackages } = require(\"mathjax-full/js/input/tex/AllPackages.js\"));\n ({ TeX } = require(\"mathjax-full/js/input/tex.js\"));\n ({ CHTML } = require(\"mathjax-full/js/output/chtml.js\"));\n ({ SVG } = require(\"mathjax-full/js/output/svg.js\"));\n ({ liteAdaptor } = require(\"mathjax-full/js/adaptors/liteAdaptor.js\"));\n ({ RegisterHTMLHandler } = require(\"mathjax-full/js/handlers/html.js\"));\n ({ AssistiveMmlHandler } = require(\"mathjax-full/js/a11y/assistive-mml.js\"));\n} catch {\n /* istanbul ignore next -- @preserve */\n isMathJaxFullInstalled = false;\n}\n\nexport interface DocumentOptions {\n InputJax: TeXType<LiteElement, string, HTMLElement>;\n OutputJax:\n | CHTMLType<LiteElement, string, HTMLElement>\n | SVGType<LiteElement, string, HTMLElement>;\n enableAssistiveMml: boolean;\n}\n\nexport const getDocumentOptions = (\n options: MarkdownItMathjaxOptions,\n): DocumentOptions => {\n /* istanbul ignore if -- @preserve */\n if (!isMathJaxFullInstalled)\n throw new Error('[@mdit/mathjax] \"mathjax-full\" is not installed!');\n\n return {\n InputJax: new TeX<LiteElement, string, HTMLElement>({\n packages: AllPackages,\n ...options.tex,\n }),\n OutputJax:\n options.output === \"chtml\"\n ? new CHTML<LiteElement, string, HTMLElement>({\n fontURL: path.dirname(\n require.resolve(\n \"mathjax-full/es5/output/chtml/fonts/woff-v2/MathJax_Zero.woff\",\n ),\n ),\n adaptiveCSS: true,\n ...options.chtml,\n })\n : new SVG<LiteElement, string, HTMLElement>({\n fontCache: \"none\",\n ...options.svg,\n }),\n enableAssistiveMml: options.a11y !== false,\n };\n};\n\n/**\n * Mathjax instance\n */\nexport interface MathjaxInstance\n extends Required<\n Pick<\n MarkdownItMathjaxOptions,\n \"allowInlineWithSpace\" | \"delimiters\" | \"mathFence\"\n >\n > {\n /**\n * Mathjax adaptor\n */\n adaptor: LiteAdaptor;\n\n /**\n * Mathjax document options\n */\n documentOptions: DocumentOptions;\n\n /**\n * Clear style cache\n */\n clearStyle: () => void;\n\n /**\n * Output style for rendered content and clears it\n *\n * @returns style\n */\n outputStyle: () => string;\n\n /**\n * Reset tex (including labels)\n */\n reset: () => void;\n\n /**\n * Output content transformer\n */\n transformer: TeXTransformer | null;\n}\n\nexport const createMathjaxInstance = (\n options: MarkdownItMathjaxOptions = {},\n): MathjaxInstance | null => {\n const documentOptions = getDocumentOptions(options);\n\n const { OutputJax, InputJax } = documentOptions;\n\n const adaptor = liteAdaptor();\n const handler = RegisterHTMLHandler(adaptor);\n\n if (options.a11y !== false)\n AssistiveMmlHandler<LiteNode, LiteText, LiteDocument>(handler);\n\n const clearStyle = (): void => {\n // clear style cache\n if (OutputJax instanceof CHTML) OutputJax.clearCache();\n };\n\n const reset = (): void => {\n InputJax.reset();\n };\n\n const outputStyle = (): string => {\n const style = adaptor.innerHTML(\n OutputJax.styleSheet(\n mathjaxLib.document(\"\", documentOptions) as MathDocument<\n LiteElement,\n string,\n HTMLElement\n >,\n ),\n );\n\n clearStyle();\n\n return style;\n };\n\n return {\n adaptor,\n documentOptions,\n allowInlineWithSpace: options.allowInlineWithSpace ?? false,\n delimiters: options.delimiters ?? \"dollars\",\n mathFence: options.mathFence ?? false,\n clearStyle,\n reset,\n outputStyle,\n transformer: options.transformer ?? null,\n };\n};\n\nexport const mathjax = (\n md: MarkdownIt,\n {\n allowInlineWithSpace,\n adaptor,\n delimiters,\n documentOptions,\n mathFence,\n transformer,\n }: MathjaxInstance,\n): void => {\n md.use(tex, {\n allowInlineWithSpace,\n delimiters,\n mathFence,\n render: (content, displayMode) => {\n const mathDocument = mathjaxLib\n .document(content, documentOptions)\n .convert(content, {\n display: displayMode,\n }) as LiteElement;\n\n const result = adaptor.outerHTML(mathDocument);\n\n return transformer?.(result, displayMode) ?? result;\n },\n });\n};\n"],"names":["isMathJaxFullInstalled","mathjaxLib","AllPackages","TeX","CHTML","SVG","liteAdaptor","RegisterHTMLHandler","AssistiveMmlHandler","getDocumentOptions","options","path","createMathjaxInstance","documentOptions","OutputJax","InputJax","adaptor","handler","clearStyle","reset","outputStyle","style","mathjax","md","allowInlineWithSpace","delimiters","mathFence","transformer","tex","content","displayMode","mathDocument","result"],"mappings":"6gBAyBA,IAAIA,EAAyB,GACzBC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAI,EACD,CAAE,QAASP,CAAW,EAAI,QAAQ,4BAA4B,GAC9D,CAAE,YAAAC,CAAY,EAAI,QAAQ,0CAA0C,EACpE,CAAE,IAAAC,CAAI,EAAI,QAAQ,8BAA8B,EAChD,CAAE,MAAAC,CAAM,EAAI,QAAQ,iCAAiC,EACrD,CAAE,IAAAC,CAAI,EAAI,QAAQ,+BAA+B,EACjD,CAAE,YAAAC,CAAY,EAAI,QAAQ,yCAAyC,EACnE,CAAE,oBAAAC,CAAoB,EAAI,QAAQ,kCAAkC,EACpE,CAAE,oBAAAC,CAAoB,EAAI,QAAQ,uCAAuC,CAC5E,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,CACV,qBAAAJ,EACA,WAAAC,EACA,UAAAC,EACA,OAAQ,CAACG,EAASC,IAAgB,CAChC,MAAMC,EAAe9B,EAClB,SAAS4B,EAAShB,CAAe,EACjC,QAAQgB,EAAS,CAChB,QAASC,CACX,CAAC,EAEGE,EAAShB,EAAQ,UAAUe,CAAY,EAE7C,OAAOJ,IAAcK,EAAQF,CAAW,GAAKE,CAC/C,CACF,CAAC,CACH"}
1
+ {"version":3,"file":"index.js","sources":["../src/tex/packages.ts","../src/tex/loader.ts","../src/tex/utils.ts","../src/plugin.ts"],"sourcesContent":["import type { TexPackage } from \"../mathjax.js\";\n\nexport const texPackages: TexPackage[] = [\n \"action\",\n \"ams\",\n \"amscd\",\n \"bbm\",\n \"bboldx\",\n \"bbox\",\n \"begingroup\",\n \"boldsymbol\",\n \"braket\",\n \"bussproofs\",\n \"cancel\",\n \"cases\",\n \"centernot\",\n \"color\",\n \"colortbl\",\n \"colorv2\",\n \"configmacros\",\n \"dsfont\",\n \"empheq\",\n \"enclose\",\n \"extpfeil\",\n \"gensymb\",\n \"html\",\n \"mathtools\",\n \"mhchem\",\n \"newcommand\",\n \"noerrors\",\n \"noundefined\",\n \"physics\",\n \"setoptions\",\n \"tagformat\",\n \"texhtml\",\n \"textcomp\",\n \"textmacros\",\n \"unicode\",\n \"units\",\n \"upgreek\",\n \"verb\",\n];\n","import type { TexPackage } from \"../mathjax.js\";\n\nexport const texLoaders: Record<TexPackage, () => Promise<unknown>> = {\n action: () =>\n 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: () =>\n import(\"@mathjax/src/js/input/tex/bboldx/BboldxConfiguration.js\"),\n bbox: () => import(\"@mathjax/src/js/input/tex/bbox/BboxConfiguration.js\"),\n begingroup: () =>\n import(\"@mathjax/src/js/input/tex/begingroup/BegingroupConfiguration.js\"),\n boldsymbol: () =>\n import(\"@mathjax/src/js/input/tex/boldsymbol/BoldsymbolConfiguration.js\"),\n braket: () =>\n import(\"@mathjax/src/js/input/tex/braket/BraketConfiguration.js\"),\n bussproofs: () =>\n import(\"@mathjax/src/js/input/tex/bussproofs/BussproofsConfiguration.js\"),\n cancel: () =>\n import(\"@mathjax/src/js/input/tex/cancel/CancelConfiguration.js\"),\n cases: () => import(\"@mathjax/src/js/input/tex/cases/CasesConfiguration.js\"),\n centernot: () =>\n import(\"@mathjax/src/js/input/tex/centernot/CenternotConfiguration.js\"),\n color: () => import(\"@mathjax/src/js/input/tex/color/ColorConfiguration.js\"),\n colortbl: () =>\n import(\"@mathjax/src/js/input/tex/colortbl/ColortblConfiguration.js\"),\n colorv2: () =>\n import(\"@mathjax/src/js/input/tex/colorv2/ColorV2Configuration.js\"),\n configmacros: () =>\n import(\n \"@mathjax/src/js/input/tex/configmacros/ConfigMacrosConfiguration.js\"\n ),\n dsfont: () =>\n import(\"@mathjax/src/js/input/tex/dsfont/DsfontConfiguration.js\"),\n empheq: () =>\n import(\"@mathjax/src/js/input/tex/empheq/EmpheqConfiguration.js\"),\n enclose: () =>\n import(\"@mathjax/src/js/input/tex/enclose/EncloseConfiguration.js\"),\n extpfeil: () =>\n import(\"@mathjax/src/js/input/tex/extpfeil/ExtpfeilConfiguration.js\"),\n gensymb: () =>\n import(\"@mathjax/src/js/input/tex/gensymb/GensymbConfiguration.js\"),\n html: () => import(\"@mathjax/src/js/input/tex/html/HtmlConfiguration.js\"),\n mathtools: () =>\n import(\"@mathjax/src/js/input/tex/mathtools/MathtoolsConfiguration.js\"),\n mhchem: () =>\n import(\"@mathjax/src/js/input/tex/mhchem/MhchemConfiguration.js\"),\n newcommand: () =>\n import(\"@mathjax/src/js/input/tex/newcommand/NewcommandConfiguration.js\"),\n noerrors: () =>\n import(\"@mathjax/src/js/input/tex/noerrors/NoErrorsConfiguration.js\"),\n noundefined: () =>\n import(\"@mathjax/src/js/input/tex/noundefined/NoUndefinedConfiguration.js\"),\n physics: () =>\n import(\"@mathjax/src/js/input/tex/physics/PhysicsConfiguration.js\"),\n setoptions: () =>\n import(\"@mathjax/src/js/input/tex/setoptions/SetOptionsConfiguration.js\"),\n tagformat: () =>\n import(\"@mathjax/src/js/input/tex/tagformat/TagFormatConfiguration.js\"),\n texhtml: () =>\n import(\"@mathjax/src/js/input/tex/texhtml/TexHtmlConfiguration.js\"),\n textcomp: () =>\n import(\"@mathjax/src/js/input/tex/textcomp/TextcompConfiguration.js\"),\n textmacros: () =>\n import(\"@mathjax/src/js/input/tex/textmacros/TextMacrosConfiguration.js\"),\n unicode: () =>\n import(\"@mathjax/src/js/input/tex/unicode/UnicodeConfiguration.js\"),\n units: () => import(\"@mathjax/src/js/input/tex/units/UnitsConfiguration.js\"),\n upgreek: () =>\n 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 (\n packages: TexPackage[] = texPackages,\n): Promise<void> => {\n await import(\"@mathjax/src/js/input/tex/base/BaseConfiguration.js\");\n\n await Promise.all(\n packages\n .filter((pkg) => texPackages.includes(pkg))\n .map((pkg) => texLoaders[pkg]()),\n );\n};\n","/**\n * Forked from https://github.com/tani/markdown-it-mathjax3/blob/master/index.ts\n */\n\nimport type { AssistiveMmlHandler as AssistiveMmlHandlerType } from \"@mathjax/src/js/a11y/assistive-mml.js\";\nimport type { LiteDocument } from \"@mathjax/src/js/adaptors/lite/Document.js\";\nimport type {\n LiteElement,\n LiteNode,\n} from \"@mathjax/src/js/adaptors/lite/Element.js\";\nimport type { LiteText } from \"@mathjax/src/js/adaptors/lite/Text.js\";\nimport type {\n LiteAdaptor,\n liteAdaptor as liteAdaptorType,\n} from \"@mathjax/src/js/adaptors/liteAdaptor.js\";\nimport type { MathDocument } from \"@mathjax/src/js/core/MathDocument.js\";\nimport type { RegisterHTMLHandler as RegisterHTMLHandlerType } from \"@mathjax/src/js/handlers/html.js\";\nimport type { TeX as TeXType } from \"@mathjax/src/js/input/tex.js\";\nimport type { mathjax as mathjaxType } from \"@mathjax/src/js/mathjax.js\";\nimport type { CHTML as CHTMLType } from \"@mathjax/src/js/output/chtml.js\";\nimport type { SVG as SVGType } from \"@mathjax/src/js/output/svg.js\";\nimport { tex } from \"@mdit/plugin-tex\";\nimport type MarkdownIt from \"markdown-it\";\n\nimport type { MarkdownItMathjaxOptions, TeXTransformer } from \"./options.js\";\nimport { loadTexPackages, texPackages } from \"./tex/index.js\";\n\nlet isMathJaxFullInstalled = true;\nlet mathjaxLib: typeof mathjaxType;\nlet TeX: typeof TeXType;\nlet CHTML: typeof CHTMLType;\nlet SVG: typeof SVGType;\nlet liteAdaptor: typeof liteAdaptorType;\n// move type import to front\nlet RegisterHTMLHandler: typeof RegisterHTMLHandlerType;\nlet AssistiveMmlHandler: typeof AssistiveMmlHandlerType;\n\ntry {\n ({ mathjax: mathjaxLib } = await import(\"@mathjax/src/js/mathjax.js\"));\n ({ TeX } = await import(\"@mathjax/src/js/input/tex.js\"));\n ({ CHTML } = await import(\"@mathjax/src/js/output/chtml.js\"));\n ({ SVG } = await import(\"@mathjax/src/js/output/svg.js\"));\n ({ liteAdaptor } = await import(\"@mathjax/src/js/adaptors/liteAdaptor.js\"));\n ({ RegisterHTMLHandler } = await import(\"@mathjax/src/js/handlers/html.js\"));\n ({ AssistiveMmlHandler } = await import(\n \"@mathjax/src/js/a11y/assistive-mml.js\"\n ));\n} catch {\n /* istanbul ignore next -- @preserve */\n isMathJaxFullInstalled = false;\n}\n\nexport interface DocumentOptions {\n InputJax: TeXType<LiteElement, string, HTMLElement>;\n OutputJax:\n | CHTMLType<LiteElement, string, HTMLElement>\n | SVGType<LiteElement, string, HTMLElement>;\n enableAssistiveMml: boolean;\n}\n\nexport const getDocumentOptions = async (\n options: MarkdownItMathjaxOptions,\n): Promise<DocumentOptions> => {\n /* istanbul ignore if -- @preserve */\n if (!isMathJaxFullInstalled)\n throw new Error(\n '[@mdit/plugin-mathjax-slim] \"@mathjax/src\" is not installed!',\n );\n\n 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:\n options.output === \"chtml\"\n ? new CHTML<LiteElement, string, HTMLElement>({\n adaptiveCSS: true,\n ...options.chtml,\n })\n : new SVG<LiteElement, string, HTMLElement>({\n fontCache: \"none\",\n ...options.svg,\n }),\n enableAssistiveMml: options.a11y !== false,\n };\n};\n\n/**\n * Mathjax instance\n */\nexport interface MathjaxInstance\n extends Required<\n Pick<\n MarkdownItMathjaxOptions,\n \"allowInlineWithSpace\" | \"delimiters\" | \"mathFence\"\n >\n > {\n /**\n * Mathjax adaptor\n */\n adaptor: LiteAdaptor;\n\n /**\n * Mathjax document options\n */\n documentOptions: DocumentOptions;\n\n /**\n * Clear style cache\n */\n clearStyle: () => void;\n\n /**\n * Output style for rendered content and clears it\n *\n * @returns style\n */\n outputStyle: () => string;\n\n /**\n * Reset tex (including labels)\n */\n reset: () => void;\n\n /**\n * Output content transformer\n */\n transformer: TeXTransformer | null;\n}\n\nexport const createMathjaxInstance = 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 const handler = RegisterHTMLHandler(adaptor);\n\n if (options.a11y !== false)\n AssistiveMmlHandler<LiteNode, LiteText, LiteDocument>(handler);\n\n const clearStyle = (): void => {\n // clear style cache\n if (OutputJax instanceof CHTML) OutputJax.clearCache();\n };\n\n const reset = (): void => {\n InputJax.reset();\n };\n\n const outputStyle = (): string => {\n const style = adaptor.innerHTML(\n OutputJax.styleSheet(\n mathjaxLib.document(\"\", documentOptions) as MathDocument<\n LiteElement,\n string,\n HTMLElement\n >,\n ),\n );\n\n clearStyle();\n\n return style;\n };\n\n return {\n adaptor,\n documentOptions,\n allowInlineWithSpace: options.allowInlineWithSpace ?? false,\n delimiters: options.delimiters ?? \"dollars\",\n mathFence: options.mathFence ?? false,\n clearStyle,\n reset,\n outputStyle,\n transformer: options.transformer ?? null,\n };\n};\n\nexport const mathjax = (\n md: MarkdownIt,\n {\n allowInlineWithSpace,\n adaptor,\n delimiters,\n documentOptions,\n mathFence,\n transformer,\n }: MathjaxInstance,\n): void => {\n md.use(tex, {\n allowInlineWithSpace,\n delimiters,\n mathFence,\n render: (content, displayMode) => {\n const mathDocument = mathjaxLib\n .document(content, documentOptions)\n .convert(content, {\n display: displayMode,\n }) as LiteElement;\n\n const result = adaptor.outerHTML(mathDocument);\n\n return transformer?.(result, displayMode) ?? result;\n },\n });\n};\n"],"names":["texPackages","texLoaders","loadTexPackages","packages","pkg","isMathJaxFullInstalled","mathjaxLib","TeX","CHTML","SVG","liteAdaptor","RegisterHTMLHandler","AssistiveMmlHandler","getDocumentOptions","options","createMathjaxInstance","documentOptions","OutputJax","InputJax","adaptor","handler","clearStyle","reset","outputStyle","style","mathjax","md","allowInlineWithSpace","delimiters","mathFence","transformer","tex","content","displayMode","mathDocument","result"],"mappings":"uCAEO,MAAMA,EAA4B,CACvC,SACA,MACA,QACA,MACA,SACA,OACA,aACA,aACA,SACA,aACA,SACA,QACA,YACA,QACA,WACA,UACA,eACA,SACA,SACA,UACA,WACA,UACA,OACA,YACA,SACA,aACA,WACA,cACA,UACA,aACA,YACA,UACA,WACA,aACA,UACA,QACA,UACA,MACF,ECvCaC,EAAyD,CACpE,OAAQ,IACN,OAAO,yDAAyD,EAClE,IAAK,IAAM,OAAO,mDAAmD,EACrE,MAAO,IAAM,OAAO,uDAAuD,EAC3E,IAAK,IAAM,OAAO,mDA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EMK,EAAQ,IAAY,CACxBJ,EAAS,MAAA,CACX,EAEMK,EAAc,IAAc,CAChC,MAAMC,EAAQL,EAAQ,UACpBF,EAAU,WACRX,EAAW,SAAS,GAAIU,CAAe,CAKzC,CACF,EAEA,OAAAK,EAAAA,EAEOG,CACT,EAEA,MAAO,CACL,QAAAL,EACA,gBAAAH,EACA,qBAAsBF,EAAQ,sBAAwB,GACtD,WAAYA,EAAQ,YAAc,UAClC,UAAWA,EAAQ,WAAa,GAChC,WAAAO,EACA,MAAAC,EACA,YAAAC,EACA,YAAaT,EAAQ,aAAe,IACtC,CACF,EAEaW,EAAU,CACrBC,EACA,CACE,qBAAAC,EACA,QAAAR,EACA,WAAAS,EACA,gBAAAZ,EACA,UAAAa,EACA,YAAAC,CACF,IACS,CACTJ,EAAG,IAAIK,EAAK,CACV,qBAAAJ,EACA,WAAAC,EACA,UAAAC,EACA,OAAQ,CAACG,EAASC,IAAgB,CAChC,MAAMC,EAAe5B,EAClB,SAAS0B,EAAShB,CAAe,EACjC,QAAQgB,EAAS,CAChB,QAASC,CACX,CAAC,EAEGE,EAAShB,EAAQ,UAAUe,CAAY,EAE7C,OAAOJ,IAAcK,EAAQF,CAAW,GAAKE,CAC/C,CACF,CAAC,CACH"}
package/lib/sync.d.ts ADDED
@@ -0,0 +1,296 @@
1
+ import { LiteElement } from '@mathjax/src/js/adaptors/lite/Element.js';
2
+ import { LiteAdaptor } from '@mathjax/src/js/adaptors/liteAdaptor.js';
3
+ import { TeX } from '@mathjax/src/js/input/tex.js';
4
+ import { CHTML } from '@mathjax/src/js/output/chtml.js';
5
+ import { SVG } from '@mathjax/src/js/output/svg.js';
6
+ import MarkdownIt from 'markdown-it';
7
+ import { MarkdownItTexOptions } from '@mdit/plugin-tex';
8
+ import { MmlNode } from '@mathjax/src/js/core/MmlTree/MmlNode.js';
9
+ import TexError from '@mathjax/src/js/input/tex/TexError.js';
10
+
11
+ type TexPackage = "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";
12
+ interface MathJaxTexInputOptions {
13
+ /**
14
+ * extensions to use
15
+ *
16
+ * @default [
17
+ * 'base',
18
+ * 'action',
19
+ * 'ams',
20
+ * 'amscd',
21
+ * 'bbm',
22
+ * 'bboldx',
23
+ * 'bbox',
24
+ * 'begingroup',
25
+ * 'boldsymbol',
26
+ * 'braket',
27
+ * 'bussproofs',
28
+ * 'cancel',
29
+ * 'cases',
30
+ * 'centernot',
31
+ * 'color',
32
+ * 'colortbl',
33
+ * 'colorv2',
34
+ * 'configmacros',
35
+ * 'dsfont',
36
+ * 'empheq',
37
+ * 'enclose',
38
+ * 'extpfeil',
39
+ * 'gensymb',
40
+ * 'html',
41
+ * 'mathtools',
42
+ * 'mhchem',
43
+ * 'newcommand',
44
+ * 'noerrors',
45
+ * 'noundefined',
46
+ * 'physics',
47
+ * 'require',
48
+ * 'setoptions',
49
+ * 'tagformat',
50
+ * 'texhtml',
51
+ * 'textcomp',
52
+ * 'textmacros',
53
+ * 'unicode',
54
+ * 'units',
55
+ * 'upgreek',
56
+ * 'verb',
57
+ * ]
58
+ */
59
+ packages?: TexPackage[];
60
+ /**
61
+ * pattern for recognizing numbers
62
+ *
63
+ * @default /^(?:[0-9]+(?:\{,\}[0-9]{3})*(?:\.[0-9]*)?|\.[0-9]+)/
64
+ */
65
+ digits?: RegExp;
66
+ tags?: "ams" | "all" | "none";
67
+ /**
68
+ * side for `\tag` macros
69
+ */
70
+ tagSide?: "left" | "right";
71
+ /**
72
+ * amount to indent tags
73
+ *
74
+ * @default "0.8em"
75
+ */
76
+ tagIndent?: "0.8em";
77
+ /**
78
+ * use label name rather than tag for ids
79
+ *
80
+ * @default true;
81
+ */
82
+ useLabelIds?: boolean;
83
+ /**
84
+ * maximum number of macro substitutions per expression
85
+ *
86
+ * @default 1000
87
+ */
88
+ maxMacros?: number;
89
+ /**
90
+ * maximum size for the internal TeX string (in bytes)
91
+ *
92
+ * @default 5120
93
+ */
94
+ maxBuffer?: number;
95
+ formatError?: (jax: TeX<unknown, unknown, unknown>, error: typeof TexError) => MmlNode;
96
+ }
97
+ interface MathjaxCommonOutputOptions {
98
+ /**
99
+ * Global scaling factor for all expressions
100
+ *
101
+ * @default 1
102
+ */
103
+ scale?: number;
104
+ /**
105
+ * smallest scaling factor to use
106
+ *
107
+ * @default 0.5
108
+ */
109
+ minScale?: number;
110
+ /**
111
+ * make mtext elements use surrounding font
112
+ *
113
+ * @default false
114
+ */
115
+ mtextInheritFont?: boolean;
116
+ /**
117
+ * make merror text use surrounding font
118
+ *
119
+ * @default true
120
+ */
121
+ merrorInheritFont?: boolean;
122
+ /**
123
+ * font to use for mtext, if not inheriting (empty means use MathJax fonts)
124
+ *
125
+ * @default ""
126
+ */
127
+ mtextFont?: string;
128
+ /**
129
+ * font to use for merror, if not inheriting (empty means use MathJax fonts)
130
+ *
131
+ * @default "serif"
132
+ */
133
+ merrorFont?: string;
134
+ /**
135
+ * font to use for character that aren’t in MathJax's fonts
136
+ *
137
+ * @default "serif"
138
+ */
139
+ unknownFamily?: string;
140
+ /**
141
+ * @default "center"
142
+ */
143
+ displayAlign?: "left" | "center" | "right";
144
+ /**
145
+ * @default 0
146
+ */
147
+ displayIndent?: string;
148
+ /**
149
+ * - `true` for MathML spacing rules
150
+ * - `false` for TeX rules
151
+ *
152
+ * @default false
153
+ */
154
+ mathmlSpacing?: boolean;
155
+ /**
156
+ * RFDa and other attributes NOT to copy to the output
157
+ */
158
+ skipAttributes?: Record<string, boolean>;
159
+ /**
160
+ * default size of ex in em units
161
+ *
162
+ * @default 0.5
163
+ */
164
+ exFactor?: number;
165
+ }
166
+ interface MathjaxCommonHTMLOutputOptions extends MathjaxCommonOutputOptions {
167
+ /**
168
+ * Whether match ex-height of surrounding font
169
+ *
170
+ * @default true
171
+ */
172
+ matchFontHeight?: boolean;
173
+ /**
174
+ * The URL where the fonts are found
175
+ *
176
+ * @default local form @mathjax/src
177
+ */
178
+ fontURL?: string;
179
+ /**
180
+ * Whether only produce CSS that is used in the processed equations
181
+ *
182
+ * @default true
183
+ */
184
+ adaptiveCSS?: boolean;
185
+ }
186
+ interface MathjaxSVGOutputOptions extends MathjaxCommonOutputOptions {
187
+ /**
188
+ * @default "none"
189
+ */
190
+ fontCache?: "local" | "global" | "none";
191
+ /**
192
+ * ID to use for local font cache (for single equation processing)
193
+ */
194
+ localID?: string | null;
195
+ /**
196
+ * insert <title> tags with speech content
197
+ *
198
+ * @default true
199
+ */
200
+ internalSpeechTitles?: boolean;
201
+ /**
202
+ * initial id number to use for aria-labeledby titles
203
+ */
204
+ titleID?: number;
205
+ }
206
+
207
+ type TeXTransformer = (content: string, displayMode: boolean) => string;
208
+ interface MarkdownItMathjaxOptions extends Pick<MarkdownItTexOptions, "allowInlineWithSpace" | "delimiters" | "mathFence"> {
209
+ /**
210
+ * Output syntax
211
+ *
212
+ * 输出格式
213
+ *
214
+ * @default 'svg'
215
+ */
216
+ output?: "chtml" | "svg";
217
+ /**
218
+ * Enable A11y
219
+ *
220
+ * 是否启用无障碍
221
+ *
222
+ * @default true
223
+ */
224
+ a11y?: boolean;
225
+ /**
226
+ * TeX input options
227
+ *
228
+ * TeX 输入选项
229
+ */
230
+ tex?: MathJaxTexInputOptions;
231
+ /**
232
+ * Common HTML output options
233
+ *
234
+ * 通用 HTML 输出选项
235
+ */
236
+ chtml?: MathjaxCommonHTMLOutputOptions;
237
+ /**
238
+ * SVG output options
239
+ *
240
+ * SVG 输出选项
241
+ */
242
+ svg?: MathjaxSVGOutputOptions;
243
+ /**
244
+ * transformer on output content
245
+ *
246
+ * 输出内容的转换器
247
+ */
248
+ transformer?: TeXTransformer;
249
+ }
250
+
251
+ /**
252
+ * Forked from https://github.com/tani/markdown-it-mathjax3/blob/master/index.ts
253
+ */
254
+
255
+ interface DocumentOptions {
256
+ InputJax: TeX<LiteElement, string, HTMLElement>;
257
+ OutputJax: CHTML<LiteElement, string, HTMLElement> | SVG<LiteElement, string, HTMLElement>;
258
+ enableAssistiveMml: boolean;
259
+ }
260
+ declare const getDocumentOptions: (options: MarkdownItMathjaxOptions) => DocumentOptions;
261
+ /**
262
+ * Mathjax instance
263
+ */
264
+ interface MathjaxInstance extends Required<Pick<MarkdownItMathjaxOptions, "allowInlineWithSpace" | "delimiters" | "mathFence">> {
265
+ /**
266
+ * Mathjax adaptor
267
+ */
268
+ adaptor: LiteAdaptor;
269
+ /**
270
+ * Mathjax document options
271
+ */
272
+ documentOptions: DocumentOptions;
273
+ /**
274
+ * Clear style cache
275
+ */
276
+ clearStyle: () => void;
277
+ /**
278
+ * Output style for rendered content and clears it
279
+ *
280
+ * @returns style
281
+ */
282
+ outputStyle: () => string;
283
+ /**
284
+ * Reset tex (including labels)
285
+ */
286
+ reset: () => void;
287
+ /**
288
+ * Output content transformer
289
+ */
290
+ transformer: TeXTransformer | null;
291
+ }
292
+ declare const createMathjaxInstance: (options?: MarkdownItMathjaxOptions) => MathjaxInstance | null;
293
+ declare const mathjax: (md: MarkdownIt, { allowInlineWithSpace, adaptor, delimiters, documentOptions, mathFence, transformer, }: MathjaxInstance) => void;
294
+
295
+ export { createMathjaxInstance, getDocumentOptions, mathjax };
296
+ export type { DocumentOptions, MathjaxInstance };
package/lib/sync.js ADDED
@@ -0,0 +1,2 @@
1
+ import{tex as y}from"@mdit/plugin-tex";const S=["action","ams","amscd","bbm","bboldx","bbox","begingroup","boldsymbol","braket","bussproofs","cancel","cases","centernot","color","colortbl","colorv2","configmacros","dsfont","empheq","enclose","extpfeil","gensymb","html","mathtools","mhchem","newcommand","noerrors","noundefined","physics","setoptions","tagformat","texhtml","textcomp","textmacros","unicode","units","upgreek","verb"];let d=!0,c,h,p,x,f,w,b;try{({mathjax:c}=await import("@mathjax/src/js/mathjax.js")),{TeX:h}=await import("@mathjax/src/js/input/tex.js"),{CHTML:p}=await import("@mathjax/src/js/output/chtml.js"),{SVG:x}=await import("@mathjax/src/js/output/svg.js"),{liteAdaptor:f}=await import("@mathjax/src/js/adaptors/liteAdaptor.js"),{RegisterHTMLHandler:w}=await import("@mathjax/src/js/handlers/html.js"),{AssistiveMmlHandler:b}=await import("@mathjax/src/js/a11y/assistive-mml.js"),await import("./importer-C5KF-eLj.js")}catch{/* istanbul ignore next -- @preserve */d=!1}const g=e=>{/* istanbul ignore if -- @preserve */if(!d)throw new Error('[@mdit/plugin-mathjax-slim] "@mathjax/src" is not installed!');return{InputJax:new h({packages:["base",...S],...e.tex}),OutputJax:e.output==="chtml"?new p({adaptiveCSS:!0,...e.chtml}):new x({fontCache:"none",...e.svg}),enableAssistiveMml:e.a11y!==!1}},v=(e={})=>{const t=g(e),{OutputJax:a,InputJax:i}=t,o=f(),l=w(o);e.a11y!==!1&&b(l);const n=()=>{a instanceof p&&a.clearCache()},r=()=>{i.reset()},s=()=>{const m=o.innerHTML(a.styleSheet(c.document("",t)));return n(),m};return{adaptor:o,documentOptions:t,allowInlineWithSpace:e.allowInlineWithSpace??!1,delimiters:e.delimiters??"dollars",mathFence:e.mathFence??!1,clearStyle:n,reset:r,outputStyle:s,transformer:e.transformer??null}},I=(e,{allowInlineWithSpace:t,adaptor:a,delimiters:i,documentOptions:o,mathFence:l,transformer:n})=>{e.use(y,{allowInlineWithSpace:t,delimiters:i,mathFence:l,render:(r,s)=>{const m=c.document(r,o).convert(r,{display:s}),u=a.outerHTML(m);return n?.(u,s)??u}})};export{v as createMathjaxInstance,g as getDocumentOptions,I as mathjax};
2
+ //# sourceMappingURL=sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.js","sources":["../src/tex/packages.ts","../src/sync.ts"],"sourcesContent":["import type { TexPackage } from \"../mathjax.js\";\n\nexport const texPackages: TexPackage[] = [\n \"action\",\n \"ams\",\n \"amscd\",\n \"bbm\",\n \"bboldx\",\n \"bbox\",\n \"begingroup\",\n \"boldsymbol\",\n \"braket\",\n \"bussproofs\",\n \"cancel\",\n \"cases\",\n \"centernot\",\n \"color\",\n \"colortbl\",\n \"colorv2\",\n \"configmacros\",\n \"dsfont\",\n \"empheq\",\n \"enclose\",\n \"extpfeil\",\n \"gensymb\",\n \"html\",\n \"mathtools\",\n \"mhchem\",\n \"newcommand\",\n \"noerrors\",\n \"noundefined\",\n \"physics\",\n \"setoptions\",\n \"tagformat\",\n \"texhtml\",\n \"textcomp\",\n \"textmacros\",\n \"unicode\",\n \"units\",\n \"upgreek\",\n \"verb\",\n];\n","/**\n * Forked from https://github.com/tani/markdown-it-mathjax3/blob/master/index.ts\n */\n\nimport type { AssistiveMmlHandler as AssistiveMmlHandlerType } from \"@mathjax/src/js/a11y/assistive-mml.js\";\nimport type { LiteDocument } from \"@mathjax/src/js/adaptors/lite/Document.js\";\nimport type {\n LiteElement,\n LiteNode,\n} from \"@mathjax/src/js/adaptors/lite/Element.js\";\nimport type { LiteText } from \"@mathjax/src/js/adaptors/lite/Text.js\";\nimport type {\n LiteAdaptor,\n liteAdaptor as liteAdaptorType,\n} from \"@mathjax/src/js/adaptors/liteAdaptor.js\";\nimport type { MathDocument } from \"@mathjax/src/js/core/MathDocument.js\";\nimport type { RegisterHTMLHandler as RegisterHTMLHandlerType } from \"@mathjax/src/js/handlers/html.js\";\nimport type { TeX as TeXType } from \"@mathjax/src/js/input/tex.js\";\nimport type { mathjax as mathjaxType } from \"@mathjax/src/js/mathjax.js\";\nimport type { CHTML as CHTMLType } from \"@mathjax/src/js/output/chtml.js\";\nimport type { SVG as SVGType } from \"@mathjax/src/js/output/svg.js\";\nimport { tex } from \"@mdit/plugin-tex\";\nimport type MarkdownIt from \"markdown-it\";\n\nimport type { MarkdownItMathjaxOptions, TeXTransformer } from \"./options.js\";\nimport { texPackages } from \"./tex/index.js\";\n\nlet isMathJaxFullInstalled = true;\nlet mathjaxLib: typeof mathjaxType;\nlet TeX: typeof TeXType;\nlet CHTML: typeof CHTMLType;\nlet SVG: typeof SVGType;\nlet liteAdaptor: typeof liteAdaptorType;\n// move type import to front\nlet RegisterHTMLHandler: typeof RegisterHTMLHandlerType;\nlet AssistiveMmlHandler: typeof AssistiveMmlHandlerType;\n\ntry {\n ({ mathjax: mathjaxLib } = await import(\"@mathjax/src/js/mathjax.js\"));\n ({ TeX } = await import(\"@mathjax/src/js/input/tex.js\"));\n ({ CHTML } = await import(\"@mathjax/src/js/output/chtml.js\"));\n ({ SVG } = await import(\"@mathjax/src/js/output/svg.js\"));\n ({ liteAdaptor } = await import(\"@mathjax/src/js/adaptors/liteAdaptor.js\"));\n ({ RegisterHTMLHandler } = await import(\"@mathjax/src/js/handlers/html.js\"));\n ({ AssistiveMmlHandler } = await import(\n \"@mathjax/src/js/a11y/assistive-mml.js\"\n ));\n await import(\"./tex/importer.js\");\n} catch {\n /* istanbul ignore next -- @preserve */\n isMathJaxFullInstalled = false;\n}\n\nexport interface DocumentOptions {\n InputJax: TeXType<LiteElement, string, HTMLElement>;\n OutputJax:\n | CHTMLType<LiteElement, string, HTMLElement>\n | SVGType<LiteElement, string, HTMLElement>;\n enableAssistiveMml: boolean;\n}\n\nexport const getDocumentOptions = (\n options: MarkdownItMathjaxOptions,\n): DocumentOptions => {\n /* istanbul ignore if -- @preserve */\n if (!isMathJaxFullInstalled)\n throw new Error(\n '[@mdit/plugin-mathjax-slim] \"@mathjax/src\" is not installed!',\n );\n\n return {\n InputJax: new TeX<LiteElement, string, HTMLElement>({\n packages: [\"base\", ...texPackages],\n ...options.tex,\n }),\n OutputJax:\n options.output === \"chtml\"\n ? new CHTML<LiteElement, string, HTMLElement>({\n adaptiveCSS: true,\n ...options.chtml,\n })\n : new SVG<LiteElement, string, HTMLElement>({\n fontCache: \"none\",\n ...options.svg,\n }),\n enableAssistiveMml: options.a11y !== false,\n };\n};\n\n/**\n * Mathjax instance\n */\nexport interface MathjaxInstance\n extends Required<\n Pick<\n MarkdownItMathjaxOptions,\n \"allowInlineWithSpace\" | \"delimiters\" | \"mathFence\"\n >\n > {\n /**\n * Mathjax adaptor\n */\n adaptor: LiteAdaptor;\n\n /**\n * Mathjax document options\n */\n documentOptions: DocumentOptions;\n\n /**\n * Clear style cache\n */\n clearStyle: () => void;\n\n /**\n * Output style for rendered content and clears it\n *\n * @returns style\n */\n outputStyle: () => string;\n\n /**\n * Reset tex (including labels)\n */\n reset: () => void;\n\n /**\n * Output content transformer\n */\n transformer: TeXTransformer | null;\n}\n\nexport const createMathjaxInstance = (\n options: MarkdownItMathjaxOptions = {},\n): MathjaxInstance | null => {\n const documentOptions = getDocumentOptions(options);\n\n const { OutputJax, InputJax } = documentOptions;\n\n const adaptor = liteAdaptor();\n const handler = RegisterHTMLHandler(adaptor);\n\n if (options.a11y !== false)\n AssistiveMmlHandler<LiteNode, LiteText, LiteDocument>(handler);\n\n const clearStyle = (): void => {\n // clear style cache\n if (OutputJax instanceof CHTML) OutputJax.clearCache();\n };\n\n const reset = (): void => {\n InputJax.reset();\n };\n\n const outputStyle = (): string => {\n const style = adaptor.innerHTML(\n OutputJax.styleSheet(\n mathjaxLib.document(\"\", documentOptions) as MathDocument<\n LiteElement,\n string,\n HTMLElement\n >,\n ),\n );\n\n clearStyle();\n\n return style;\n };\n\n return {\n adaptor,\n documentOptions,\n allowInlineWithSpace: options.allowInlineWithSpace ?? false,\n delimiters: options.delimiters ?? \"dollars\",\n mathFence: options.mathFence ?? false,\n clearStyle,\n reset,\n outputStyle,\n transformer: options.transformer ?? null,\n };\n};\n\nexport const mathjax = (\n md: MarkdownIt,\n {\n allowInlineWithSpace,\n adaptor,\n delimiters,\n documentOptions,\n mathFence,\n transformer,\n }: MathjaxInstance,\n): void => {\n md.use(tex, {\n allowInlineWithSpace,\n delimiters,\n mathFence,\n render: (content, displayMode) => {\n const mathDocument = mathjaxLib\n .document(content, documentOptions)\n .convert(content, {\n display: displayMode,\n }) as LiteElement;\n\n const result = adaptor.outerHTML(mathDocument);\n\n return transformer?.(result, displayMode) ?? result;\n },\n });\n};\n"],"names":["texPackages","isMathJaxFullInstalled","mathjaxLib","TeX","CHTML","SVG","liteAdaptor","RegisterHTMLHandler","AssistiveMmlHandler","getDocumentOptions","options","createMathjaxInstance","documentOptions","OutputJax","InputJax","adaptor","handler","clearStyle","reset","outputStyle","style","mathjax","md","allowInlineWithSpace","delimiters","mathFence","transformer","tex","content","displayMode","mathDocument","result"],"mappings":"uCAEO,MAAMA,EAA4B,CACvC,SACA,MACA,QACA,MACA,SACA,OACA,aACA,aACA,SACA,aACA,SACA,QACA,YACA,QACA,WACA,UACA,eACA,SACA,SACA,UACA,WACA,UACA,OACA,YACA,SACA,aACA,WACA,cACA,UACA,aACA,YACA,UACA,WACA,aACA,UACA,QACA,UACA,MACF,ECdA,IAAIC,EAAyB,GACzBC,EACAC,EACAC,EACAC,EACAC,EAEAC,EACAC,EAEJ,GAAI,EACD,CAAE,QAASN,CAAW,EAAI,KAAM,QAAO,4BAA4B,GACnE,CAAE,IAAAC,CAAI,EAAI,KAAM,QAAO,8BAA8B,EACrD,CAAE,MAAAC,CAAM,EAAI,KAAM,QAAO,iCAAiC,EAC1D,CAAE,IAAAC,CAAI,EAAI,KAAM,QAAO,+BAA+B,EACtD,CAAE,YAAAC,CAAY,EAAI,KAAM,QAAO,yCAAyC,EACxE,CAAE,oBAAAC,CAAoB,EAAI,KAAM,QAAO,kCAAkC,EACzE,CAAE,oBAAAC,CAAoB,EAAI,aACzB,uCACF,EACA,KAAM,QAAO,wBAAmB,CAClC,MAAQ,CAAA,uCAENP,EAAyB,EAC3B,CAUO,MAAMQ,EACXC,GACoB,CAAA,qCAEpB,GAAI,CAACT,EACH,MAAM,IAAI,MACR,8DACF,EAEF,MAAO,CACL,SAAU,IAAIE,EAAsC,CAClD,SAAU,CAAC,OAAQ,GAAGH,CAAW,EACjC,GAAGU,EAA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GAAKE,CAC/C,CACF,CAAC,CACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mdit/plugin-mathjax-slim",
3
- "version": "0.23.3-cjs.0",
3
+ "version": "0.24.0",
4
4
  "description": "mathjax plugin for MarkdownIt",
5
5
  "keywords": [
6
6
  "markdown-it",
@@ -22,25 +22,39 @@
22
22
  "email": "mister-hope@outlook.com",
23
23
  "url": "https://mister-hope.com"
24
24
  },
25
+ "type": "module",
26
+ "exports": {
27
+ ".": {
28
+ "type": "./lib/index.d.ts",
29
+ "default": "./lib/index.js"
30
+ },
31
+ "./sync": {
32
+ "type": "./lib/sync.d.ts",
33
+ "default": "./lib/sync.js"
34
+ },
35
+ "./package.json": "./package.json"
36
+ },
25
37
  "main": "./lib/index.js",
26
38
  "types": "./lib/index.d.ts",
27
39
  "files": [
28
40
  "lib"
29
41
  ],
30
42
  "dependencies": {
31
- "@mdit/plugin-tex": "0.22.3-cjs.0",
32
43
  "@types/markdown-it": "^14.1.2",
33
- "upath": "^2.0.1"
44
+ "@mdit/plugin-tex": "0.22.2"
45
+ },
46
+ "devDependencies": {
47
+ "@mathjax/src": "4.0.0"
34
48
  },
35
49
  "peerDependencies": {
36
- "markdown-it": "^14.1.0",
37
- "mathjax-full": "^3.2.2"
50
+ "@mathjax/src": "^4.0.0",
51
+ "markdown-it": "^14.1.0"
38
52
  },
39
53
  "peerDependenciesMeta": {
40
- "markdown-it": {
54
+ "@mathjax/src": {
41
55
  "optional": true
42
56
  },
43
- "mathjax-full": {
57
+ "markdown-it": {
44
58
  "optional": true
45
59
  }
46
60
  },
@@ -50,5 +64,8 @@
50
64
  "publishConfig": {
51
65
  "access": "public"
52
66
  },
53
- "gitHead": "3576665a17077f50c9013f0df2cba92845d9e44d"
54
- }
67
+ "scripts": {
68
+ "build": "rollup -c rollup.config.ts --configPlugin esbuild",
69
+ "clean": "rimraf ./lib"
70
+ }
71
+ }