@bytemd/plugin-math
Advanced tools
+2
-2
| { | ||
| "name": "@bytemd/plugin-math", | ||
| "version": "0.1.7", | ||
| "version": "0.1.8", | ||
| "description": "ByteMD plugin to support math equation", | ||
@@ -26,3 +26,3 @@ "author": "Rongjian Zhang <pd4d10@gmail.com>", | ||
| }, | ||
| "gitHead": "fbc0ee1ebb4737493c15f1f9161bf832ae93219c" | ||
| "gitHead": "c423bb9a16142370ad2c4dc28510d5d8240e7bf3" | ||
| } |
| import remarkMath from 'remark-math'; | ||
| function mathLazy({ katexOptions, ...remarkMathOptions } = {}) { | ||
| return { | ||
| remark: (u) => u.use(remarkMath, remarkMathOptions), | ||
| viewerEffect(el) { | ||
| const renderInline = async () => { | ||
| const els = el.querySelectorAll('.math.math-inline:not(.math-display)' // for `inlineMathDouble === true` case | ||
| ); | ||
| if (els.length === 0) | ||
| return; | ||
| const { render } = await import('katex'); | ||
| els.forEach((el) => { | ||
| render(el.innerText, el, { | ||
| ...katexOptions, | ||
| throwOnError: false, | ||
| displayMode: false, | ||
| }); | ||
| }); | ||
| }; | ||
| const renderDisplay = async () => { | ||
| const els = el.querySelectorAll('.math.math-display'); | ||
| if (els.length === 0) | ||
| return; | ||
| const { render } = await import('katex'); | ||
| els.forEach((el) => { | ||
| render(el.innerText, el, { | ||
| ...katexOptions, | ||
| throwOnError: false, | ||
| displayMode: true, | ||
| }); | ||
| }); | ||
| }; | ||
| renderInline(); | ||
| renderDisplay(); | ||
| }, | ||
| }; | ||
| } | ||
| export default mathLazy; | ||
| //# sourceMappingURL=index.esm.js.map |
| {"version":3,"file":"index.esm.js","sources":["../lib/index.js"],"sourcesContent":["import remarkMath from 'remark-math';\nexport default function mathLazy({ katexOptions, ...remarkMathOptions } = {}) {\n return {\n remark: (u) => u.use(remarkMath, remarkMathOptions),\n viewerEffect(el) {\n const renderInline = async () => {\n const els = el.querySelectorAll('.math.math-inline:not(.math-display)' // for `inlineMathDouble === true` case\n );\n if (els.length === 0)\n return;\n const { render } = await import('katex');\n els.forEach((el) => {\n render(el.innerText, el, {\n ...katexOptions,\n throwOnError: false,\n displayMode: false,\n });\n });\n };\n const renderDisplay = async () => {\n const els = el.querySelectorAll('.math.math-display');\n if (els.length === 0)\n return;\n const { render } = await import('katex');\n els.forEach((el) => {\n render(el.innerText, el, {\n ...katexOptions,\n throwOnError: false,\n displayMode: true,\n });\n });\n };\n renderInline();\n renderDisplay();\n },\n };\n}\n"],"names":[],"mappings":";;AACe,SAAS,QAAQ,CAAC,EAAE,YAAY,EAAE,GAAG,iBAAiB,EAAE,GAAG,EAAE,EAAE;AAC9E,IAAI,OAAO;AACX,QAAQ,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,UAAU,EAAE,iBAAiB,CAAC;AAC3D,QAAQ,YAAY,CAAC,EAAE,EAAE;AACzB,YAAY,MAAM,YAAY,GAAG,YAAY;AAC7C,gBAAgB,MAAM,GAAG,GAAG,EAAE,CAAC,gBAAgB,CAAC,sCAAsC;AACtF,iBAAiB,CAAC;AAClB,gBAAgB,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;AACpC,oBAAoB,OAAO;AAC3B,gBAAgB,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,OAAO,OAAO,CAAC,CAAC;AACzD,gBAAgB,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK;AACpC,oBAAoB,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,EAAE;AAC7C,wBAAwB,GAAG,YAAY;AACvC,wBAAwB,YAAY,EAAE,KAAK;AAC3C,wBAAwB,WAAW,EAAE,KAAK;AAC1C,qBAAqB,CAAC,CAAC;AACvB,iBAAiB,CAAC,CAAC;AACnB,aAAa,CAAC;AACd,YAAY,MAAM,aAAa,GAAG,YAAY;AAC9C,gBAAgB,MAAM,GAAG,GAAG,EAAE,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;AACtE,gBAAgB,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;AACpC,oBAAoB,OAAO;AAC3B,gBAAgB,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,OAAO,OAAO,CAAC,CAAC;AACzD,gBAAgB,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK;AACpC,oBAAoB,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,EAAE;AAC7C,wBAAwB,GAAG,YAAY;AACvC,wBAAwB,YAAY,EAAE,KAAK;AAC3C,wBAAwB,WAAW,EAAE,IAAI;AACzC,qBAAqB,CAAC,CAAC;AACvB,iBAAiB,CAAC,CAAC;AACnB,aAAa,CAAC;AACd,YAAY,YAAY,EAAE,CAAC;AAC3B,YAAY,aAAa,EAAE,CAAC;AAC5B,SAAS;AACT,KAAK,CAAC;AACN;;;;"} |
| 'use strict'; | ||
| var remarkMath = require('remark-math'); | ||
| function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
| function _interopNamespace(e) { | ||
| if (e && e.__esModule) return e; | ||
| var n = Object.create(null); | ||
| if (e) { | ||
| Object.keys(e).forEach(function (k) { | ||
| if (k !== 'default') { | ||
| var d = Object.getOwnPropertyDescriptor(e, k); | ||
| Object.defineProperty(n, k, d.get ? d : { | ||
| enumerable: true, | ||
| get: function () { | ||
| return e[k]; | ||
| } | ||
| }); | ||
| } | ||
| }); | ||
| } | ||
| n['default'] = e; | ||
| return Object.freeze(n); | ||
| } | ||
| var remarkMath__default = /*#__PURE__*/_interopDefaultLegacy(remarkMath); | ||
| function mathLazy({ katexOptions, ...remarkMathOptions } = {}) { | ||
| return { | ||
| remark: (u) => u.use(remarkMath__default['default'], remarkMathOptions), | ||
| viewerEffect(el) { | ||
| const renderInline = async () => { | ||
| const els = el.querySelectorAll('.math.math-inline:not(.math-display)' // for `inlineMathDouble === true` case | ||
| ); | ||
| if (els.length === 0) | ||
| return; | ||
| const { render } = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('katex')); }); | ||
| els.forEach((el) => { | ||
| render(el.innerText, el, { | ||
| ...katexOptions, | ||
| throwOnError: false, | ||
| displayMode: false, | ||
| }); | ||
| }); | ||
| }; | ||
| const renderDisplay = async () => { | ||
| const els = el.querySelectorAll('.math.math-display'); | ||
| if (els.length === 0) | ||
| return; | ||
| const { render } = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('katex')); }); | ||
| els.forEach((el) => { | ||
| render(el.innerText, el, { | ||
| ...katexOptions, | ||
| throwOnError: false, | ||
| displayMode: true, | ||
| }); | ||
| }); | ||
| }; | ||
| renderInline(); | ||
| renderDisplay(); | ||
| }, | ||
| }; | ||
| } | ||
| module.exports = mathLazy; | ||
| //# sourceMappingURL=index.js.map |
| {"version":3,"file":"index.js","sources":["../lib/index.js"],"sourcesContent":["import remarkMath from 'remark-math';\nexport default function mathLazy({ katexOptions, ...remarkMathOptions } = {}) {\n return {\n remark: (u) => u.use(remarkMath, remarkMathOptions),\n viewerEffect(el) {\n const renderInline = async () => {\n const els = el.querySelectorAll('.math.math-inline:not(.math-display)' // for `inlineMathDouble === true` case\n );\n if (els.length === 0)\n return;\n const { render } = await import('katex');\n els.forEach((el) => {\n render(el.innerText, el, {\n ...katexOptions,\n throwOnError: false,\n displayMode: false,\n });\n });\n };\n const renderDisplay = async () => {\n const els = el.querySelectorAll('.math.math-display');\n if (els.length === 0)\n return;\n const { render } = await import('katex');\n els.forEach((el) => {\n render(el.innerText, el, {\n ...katexOptions,\n throwOnError: false,\n displayMode: true,\n });\n });\n };\n renderInline();\n renderDisplay();\n },\n };\n}\n"],"names":["remarkMath"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AACe,SAAS,QAAQ,CAAC,EAAE,YAAY,EAAE,GAAG,iBAAiB,EAAE,GAAG,EAAE,EAAE;AAC9E,IAAI,OAAO;AACX,QAAQ,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAACA,8BAAU,EAAE,iBAAiB,CAAC;AAC3D,QAAQ,YA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import type { BytemdPlugin } from 'bytemd'; | ||
| import type { KatexOptions } from 'katex'; | ||
| import { RemarkMathOptions } from 'remark-math'; | ||
| export interface MathLazyOptions extends RemarkMathOptions { | ||
| katexOptions?: Omit<KatexOptions, 'displayMode'>; | ||
| } | ||
| export default function mathLazy({ katexOptions, ...remarkMathOptions }?: MathLazyOptions): BytemdPlugin; |
-37
| import remarkMath from 'remark-math'; | ||
| export default function mathLazy({ katexOptions, ...remarkMathOptions } = {}) { | ||
| return { | ||
| remark: (u) => u.use(remarkMath, remarkMathOptions), | ||
| viewerEffect(el) { | ||
| const renderInline = async () => { | ||
| const els = el.querySelectorAll('.math.math-inline:not(.math-display)' // for `inlineMathDouble === true` case | ||
| ); | ||
| if (els.length === 0) | ||
| return; | ||
| const { render } = await import('katex'); | ||
| els.forEach((el) => { | ||
| render(el.innerText, el, { | ||
| ...katexOptions, | ||
| throwOnError: false, | ||
| displayMode: false, | ||
| }); | ||
| }); | ||
| }; | ||
| const renderDisplay = async () => { | ||
| const els = el.querySelectorAll('.math.math-display'); | ||
| if (els.length === 0) | ||
| return; | ||
| const { render } = await import('katex'); | ||
| els.forEach((el) => { | ||
| render(el.innerText, el, { | ||
| ...katexOptions, | ||
| throwOnError: false, | ||
| displayMode: true, | ||
| }); | ||
| }); | ||
| }; | ||
| renderInline(); | ||
| renderDisplay(); | ||
| }, | ||
| }; | ||
| } |
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
2074
-84.36%3
-66.67%0
-100%1
Infinity%