@mdit/plugin-katex 0.2.3 → 0.3.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.cjs.map +1 -1
- package/lib/index.mjs.map +1 -1
- package/package.json +2 -2
package/lib/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/utils.ts","../src/plugin.ts"],"sourcesContent":["export const escapeHtml = (unsafeHTML: string): string =>\n unsafeHTML\n .replace(/&/gu, \"&\")\n .replace(/</gu, \"<\")\n .replace(/>/gu, \">\")\n .replace(/\"/gu, \""\")\n .replace(/'/gu, \"'\");\n","import { createRequire } from \"node:module\";\nimport { tex } from \"@mdit/plugin-tex\";\nimport Katex
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/utils.ts","../src/plugin.ts"],"sourcesContent":["export const escapeHtml = (unsafeHTML: string): string =>\n unsafeHTML\n .replace(/&/gu, \"&\")\n .replace(/</gu, \"<\")\n .replace(/>/gu, \">\")\n .replace(/\"/gu, \""\")\n .replace(/'/gu, \"'\");\n","import { createRequire } from \"node:module\";\n\nimport { tex } from \"@mdit/plugin-tex\";\nimport Katex, { type KatexOptions as OriginalKatexOptions } from \"katex\";\nimport { type PluginWithOptions } from \"markdown-it\";\n\nimport { type MarkdownItKatexOptions } from \"./options.js\";\nimport { escapeHtml } from \"./utils.js\";\n\nconst require = createRequire(import.meta.url);\n\nconst katexInline = (tex: string, options: OriginalKatexOptions): string => {\n try {\n return Katex.renderToString(tex, { ...options, displayMode: false });\n } catch (error) {\n if (options.throwOnError) console.warn(error);\n\n return `<span class='katex-error' title='${escapeHtml(\n (error as Error).toString()\n )}'>${escapeHtml(tex)}</span>`;\n }\n};\n\nconst katexBlock = (tex: string, options: OriginalKatexOptions): string => {\n try {\n return `<p class='katex-block'>${Katex.renderToString(tex, {\n ...options,\n displayMode: true,\n strict: (errorCode: string): string =>\n errorCode === \"newLineInDisplayMode\" ? \"ignore\" : \"warn\",\n })}</p>\\n`;\n } catch (error) {\n if (options.throwOnError) console.warn(error);\n\n return `<p class='katex-block katex-error' title='${escapeHtml(\n (error as Error).toString()\n )}'>${escapeHtml(tex)}</p>\\n`;\n }\n};\n\nexport const katex: PluginWithOptions<MarkdownItKatexOptions> = (\n md,\n options = {}\n) => {\n const { mhchem = false, ...userOptions } = options;\n\n if (mhchem) require(\"katex/contrib/mhchem\");\n\n const katexOptions = {\n throwOnError: false,\n ...userOptions,\n };\n\n md.use(tex, {\n render: (content: string, displayMode: boolean) =>\n displayMode\n ? katexBlock(content, katexOptions)\n : katexInline(content, katexOptions),\n });\n};\n"],"names":["escapeHtml","unsafeHTML","require","createRequire","katexInline","tex","options","Katex","error","katexBlock","errorCode","katex","md","mhchem","userOptions","katexOptions","content","displayMode"],"mappings":"2FAAa,MAAAA,EAAcC,GACzBA,EACG,QAAQ,MAAO,OAAO,EACtB,QAAQ,MAAO,MAAM,EACrB,QAAQ,MAAO,MAAM,EACrB,QAAQ,MAAO,QAAQ,EACvB,QAAQ,MAAO,QAAQ,ECGtBC,EAAUC,EAAAA,cAAc,OAAA,SAAA,IAAA,GAAA,SAAA,KAAA,GAAA,IAAA,QAAA,UAAA,EAAA,KAAA,SAAA,eAAA,SAAA,cAAA,KAAA,IAAA,IAAA,YAAA,SAAA,OAAA,EAAA,IAAe,EAEvCC,EAAc,CAACC,EAAaC,IAA0C,CAC1E,GAAI,CACF,OAAOC,EAAM,eAAeF,EAAK,CAAE,GAAGC,EAAS,YAAa,EAAM,CAAC,CACrE,OAASE,GACP,OAAIF,EAAQ,cAAc,QAAQ,KAAKE,CAAK,EAErC,oCAAoCR,EACxCQ,EAAgB,SACnB,CAAA,MAAMR,EAAWK,CAAG,UACtB,CACF,EAEMI,EAAa,CAACJ,EAAaC,IAA0C,CACzE,GAAI,CACF,MAAO,0BAA0BC,EAAM,eAAeF,EAAK,CACzD,GAAGC,EACH,YAAa,GACb,OAASI,GACPA,IAAc,uBAAyB,SAAW,MACtD,CAAC;AAAA,CACH,OAASF,GACP,OAAIF,EAAQ,cAAc,QAAQ,KAAKE,CAAK,EAErC,6CAA6CR,EACjDQ,EAAgB,UACnB,MAAMR,EAAWK,CAAG;AAAA,CACtB,CACF,EAEaM,EAAmD,CAC9DC,EACAN,EAAU,CAAC,IACR,CACH,KAAM,CAAE,OAAAO,EAAS,GAAO,GAAGC,CAAY,EAAIR,EAEvCO,GAAQX,EAAQ,sBAAsB,EAE1C,MAAMa,EAAe,CACnB,aAAc,GACd,GAAGD,CACL,EAEAF,EAAG,IAAIP,EAAAA,IAAK,CACV,OAAQ,CAACW,EAAiBC,IACxBA,EACIR,EAAWO,EAASD,CAAY,EAChCX,EAAYY,EAASD,CAAY,CACzC,CAAC,CACH"}
|
package/lib/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/utils.ts","../src/plugin.ts"],"sourcesContent":["export const escapeHtml = (unsafeHTML: string): string =>\n unsafeHTML\n .replace(/&/gu, \"&\")\n .replace(/</gu, \"<\")\n .replace(/>/gu, \">\")\n .replace(/\"/gu, \""\")\n .replace(/'/gu, \"'\");\n","import { createRequire } from \"node:module\";\nimport { tex } from \"@mdit/plugin-tex\";\nimport Katex
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/utils.ts","../src/plugin.ts"],"sourcesContent":["export const escapeHtml = (unsafeHTML: string): string =>\n unsafeHTML\n .replace(/&/gu, \"&\")\n .replace(/</gu, \"<\")\n .replace(/>/gu, \">\")\n .replace(/\"/gu, \""\")\n .replace(/'/gu, \"'\");\n","import { createRequire } from \"node:module\";\n\nimport { tex } from \"@mdit/plugin-tex\";\nimport Katex, { type KatexOptions as OriginalKatexOptions } from \"katex\";\nimport { type PluginWithOptions } from \"markdown-it\";\n\nimport { type MarkdownItKatexOptions } from \"./options.js\";\nimport { escapeHtml } from \"./utils.js\";\n\nconst require = createRequire(import.meta.url);\n\nconst katexInline = (tex: string, options: OriginalKatexOptions): string => {\n try {\n return Katex.renderToString(tex, { ...options, displayMode: false });\n } catch (error) {\n if (options.throwOnError) console.warn(error);\n\n return `<span class='katex-error' title='${escapeHtml(\n (error as Error).toString()\n )}'>${escapeHtml(tex)}</span>`;\n }\n};\n\nconst katexBlock = (tex: string, options: OriginalKatexOptions): string => {\n try {\n return `<p class='katex-block'>${Katex.renderToString(tex, {\n ...options,\n displayMode: true,\n strict: (errorCode: string): string =>\n errorCode === \"newLineInDisplayMode\" ? \"ignore\" : \"warn\",\n })}</p>\\n`;\n } catch (error) {\n if (options.throwOnError) console.warn(error);\n\n return `<p class='katex-block katex-error' title='${escapeHtml(\n (error as Error).toString()\n )}'>${escapeHtml(tex)}</p>\\n`;\n }\n};\n\nexport const katex: PluginWithOptions<MarkdownItKatexOptions> = (\n md,\n options = {}\n) => {\n const { mhchem = false, ...userOptions } = options;\n\n if (mhchem) require(\"katex/contrib/mhchem\");\n\n const katexOptions = {\n throwOnError: false,\n ...userOptions,\n };\n\n md.use(tex, {\n render: (content: string, displayMode: boolean) =>\n displayMode\n ? katexBlock(content, katexOptions)\n : katexInline(content, katexOptions),\n });\n};\n"],"names":["escapeHtml","unsafeHTML","require","createRequire","katexInline","tex","options","Katex","error","katexBlock","errorCode","katex","md","mhchem","userOptions","katexOptions","content","displayMode"],"mappings":"wGAAa,MAAAA,EAAcC,GACzBA,EACG,QAAQ,MAAO,OAAO,EACtB,QAAQ,MAAO,MAAM,EACrB,QAAQ,MAAO,MAAM,EACrB,QAAQ,MAAO,QAAQ,EACvB,QAAQ,MAAO,QAAQ,ECGtBC,EAAUC,EAAc,YAAY,GAAG,EAEvCC,EAAc,CAACC,EAAaC,IAA0C,CAC1E,GAAI,CACF,OAAOC,EAAM,eAAeF,EAAK,CAAE,GAAGC,EAAS,YAAa,EAAM,CAAC,CACrE,OAASE,GACP,OAAIF,EAAQ,cAAc,QAAQ,KAAKE,CAAK,EAErC,oCAAoCR,EACxCQ,EAAgB,SACnB,CAAA,MAAMR,EAAWK,CAAG,UACtB,CACF,EAEMI,EAAa,CAACJ,EAAaC,IAA0C,CACzE,GAAI,CACF,MAAO,0BAA0BC,EAAM,eAAeF,EAAK,CACzD,GAAGC,EACH,YAAa,GACb,OAASI,GACPA,IAAc,uBAAyB,SAAW,MACtD,CAAC;AAAA,CACH,OAASF,GACP,OAAIF,EAAQ,cAAc,QAAQ,KAAKE,CAAK,EAErC,6CAA6CR,EACjDQ,EAAgB,UACnB,MAAMR,EAAWK,CAAG;AAAA,CACtB,CACF,EAEaM,EAAmD,CAC9DC,EACAN,EAAU,CAAC,IACR,CACH,KAAM,CAAE,OAAAO,EAAS,GAAO,GAAGC,CAAY,EAAIR,EAEvCO,GAAQX,EAAQ,sBAAsB,EAE1C,MAAMa,EAAe,CACnB,aAAc,GACd,GAAGD,CACL,EAEAF,EAAG,IAAIP,EAAK,CACV,OAAQ,CAACW,EAAiBC,IACxBA,EACIR,EAAWO,EAASD,CAAY,EAChCX,EAAYY,EAASD,CAAY,CACzC,CAAC,CACH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdit/plugin-katex",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "katex plugin for MarkdownIt",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdownit",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@types/markdown-it": "^12.2.3",
|
|
41
41
|
"katex": "^0.16.4",
|
|
42
42
|
"markdown-it": "^13.0.1",
|
|
43
|
-
"@mdit/plugin-tex": "0.
|
|
43
|
+
"@mdit/plugin-tex": "0.3.0"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|