@mdit/plugin-mathjax-slim 0.22.0 → 0.23.2-cjs.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +3 -3
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +7 -13
package/lib/index.d.ts
CHANGED
|
@@ -194,7 +194,7 @@ interface MathjaxSVGOutputOptions extends MathjaxCommonOutputOptions {
|
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
type TeXTransformer = (content: string, displayMode: boolean) => string;
|
|
197
|
-
interface MarkdownItMathjaxOptions extends Pick<MarkdownItTexOptions, "allowInlineWithSpace" | "mathFence"> {
|
|
197
|
+
interface MarkdownItMathjaxOptions extends Pick<MarkdownItTexOptions, "allowInlineWithSpace" | "delimiters" | "mathFence"> {
|
|
198
198
|
/**
|
|
199
199
|
* Output syntax
|
|
200
200
|
*
|
|
@@ -250,7 +250,7 @@ declare const getDocumentOptions: (options: MarkdownItMathjaxOptions) => Documen
|
|
|
250
250
|
/**
|
|
251
251
|
* Mathjax instance
|
|
252
252
|
*/
|
|
253
|
-
interface MathjaxInstance extends Required<Pick<MarkdownItMathjaxOptions, "allowInlineWithSpace" | "mathFence">> {
|
|
253
|
+
interface MathjaxInstance extends Required<Pick<MarkdownItMathjaxOptions, "allowInlineWithSpace" | "delimiters" | "mathFence">> {
|
|
254
254
|
/**
|
|
255
255
|
* Mathjax adaptor
|
|
256
256
|
*/
|
|
@@ -279,7 +279,7 @@ interface MathjaxInstance extends Required<Pick<MarkdownItMathjaxOptions, "allow
|
|
|
279
279
|
transformer: TeXTransformer | null;
|
|
280
280
|
}
|
|
281
281
|
declare const createMathjaxInstance: (options?: MarkdownItMathjaxOptions) => MathjaxInstance | null;
|
|
282
|
-
declare const mathjax: (md: MarkdownIt, { allowInlineWithSpace, adaptor, documentOptions, mathFence, transformer, }: MathjaxInstance) => void;
|
|
282
|
+
declare const mathjax: (md: MarkdownIt, { allowInlineWithSpace, adaptor, delimiters, documentOptions, mathFence, transformer, }: MathjaxInstance) => void;
|
|
283
283
|
|
|
284
284
|
export { createMathjaxInstance, getDocumentOptions, mathjax };
|
|
285
285
|
export type { DocumentOptions, MarkdownItMathjaxOptions, MathJaxTexInputOptions, MathjaxCommonHTMLOutputOptions, MathjaxCommonOutputOptions, MathjaxInstance, MathjaxSVGOutputOptions, TeXTransformer };
|
package/lib/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
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;
|
|
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":["/**\n * Forked from https://github.com/tani/markdown-it-mathjax3/blob/master/index.ts\n */\n\n/* eslint-disable @typescript-eslint/consistent-type-imports */\
|
|
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,IA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AAAC,EACA,YAAaV,EAAQ,aAAe,IACtC,CACF,EAEaY,EAAU,CACrBC,EACA,CACE,qBAAAC,EACA,QAAAR,EACA,WAAAS,EACA,gBAAAZ,EACA,UAAAa,EACA,YAAAC,CACF,IACS,CACTJ,EAAG,IAAIK,EAAAA,IAAK,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdit/plugin-mathjax-slim",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.2-cjs.0",
|
|
4
4
|
"description": "mathjax plugin for MarkdownIt",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown-it",
|
|
@@ -30,18 +30,15 @@
|
|
|
30
30
|
},
|
|
31
31
|
"./package.json": "./package.json"
|
|
32
32
|
},
|
|
33
|
-
"main": "lib/index.js",
|
|
34
|
-
"types": "lib/index.d.ts",
|
|
33
|
+
"main": "./lib/index.js",
|
|
34
|
+
"types": "./lib/index.d.ts",
|
|
35
35
|
"files": [
|
|
36
36
|
"lib"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
+
"@mdit/plugin-tex": "0.22.2-cjs.0",
|
|
39
40
|
"@types/markdown-it": "^14.1.2",
|
|
40
|
-
"upath": "^2.0.1"
|
|
41
|
-
"@mdit/plugin-tex": "0.22.0"
|
|
42
|
-
},
|
|
43
|
-
"devDependencies": {
|
|
44
|
-
"mathjax-full": "3.2.2"
|
|
41
|
+
"upath": "^2.0.1"
|
|
45
42
|
},
|
|
46
43
|
"peerDependencies": {
|
|
47
44
|
"markdown-it": "^14.1.0",
|
|
@@ -61,8 +58,5 @@
|
|
|
61
58
|
"publishConfig": {
|
|
62
59
|
"access": "public"
|
|
63
60
|
},
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
"clean": "rimraf ./lib"
|
|
67
|
-
}
|
|
68
|
-
}
|
|
61
|
+
"gitHead": "e28889367810a16d0426a836e639d12005fba5b4"
|
|
62
|
+
}
|