@bytemd/plugin-math
Advanced tools
| import remarkMath from 'remark-math'; | ||
| import rehypeKatex from 'rehype-katex'; | ||
| function math(options = {}) { | ||
| // @ts-ignore | ||
| function math({ inlineMathDouble, katex, } = {}) { | ||
| return { | ||
| remarkTransformer: (u) => u.use(remarkMath, options.math), | ||
| rehypeTransformer: (u) => u.use(rehypeKatex, options.katex), | ||
| markdownSanitizeSchema: { | ||
| attributes: { | ||
| div: ['className'], | ||
| span: ['className'], | ||
| }, | ||
| }, | ||
| remark: (u) => u.use(remarkMath, { inlineMathDouble }), | ||
| rehype: (u) => u.use(rehypeKatex, katex), | ||
| }; | ||
@@ -15,0 +10,0 @@ } |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.esm.js","sources":["../src/index.js"],"sourcesContent":["import remarkMath from 'remark-math';\nimport rehypeKatex from 'rehype-katex';\nexport default function math(options = {}) {\n return {\n remarkTransformer: (u) => u.use(remarkMath, options.math),\n rehypeTransformer: (u) => u.use(rehypeKatex, options.katex),\n markdownSanitizeSchema: {\n attributes: {\n div: ['className'],\n span: ['className'],\n },\n },\n };\n}\n"],"names":[],"mappings":";;;AAEe,SAAS,IAAI,CAAC,OAAO,GAAG,EAAE,EAAE;AAC3C,IAAI,OAAO;AACX,QAAQ,iBAAiB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC;AACjE,QAAQ,iBAAiB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC;AACnE,QAAQ,sBAAsB,EAAE;AAChC,YAAY,UAAU,EAAE;AACxB,gBAAgB,GAAG,EAAE,CAAC,WAAW,CAAC;AAClC,gBAAgB,IAAI,EAAE,CAAC,WAAW,CAAC;AACnC,aAAa;AACb,SAAS;AACT,KAAK,CAAC;AACN;;;;"} | ||
| {"version":3,"file":"index.esm.js","sources":["../src/index.js"],"sourcesContent":["// @ts-ignore\nimport remarkMath from 'remark-math';\n// @ts-ignore\nimport rehypeKatex from 'rehype-katex';\nexport default function math({ inlineMathDouble, katex, } = {}) {\n return {\n remark: (u) => u.use(remarkMath, { inlineMathDouble }),\n rehype: (u) => u.use(rehypeKatex, katex),\n };\n}\n"],"names":[],"mappings":";;;AAAA;AAIe,SAAS,IAAI,CAAC,EAAE,gBAAgB,EAAE,KAAK,GAAG,GAAG,EAAE,EAAE;AAChE,IAAI,OAAO;AACX,QAAQ,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,gBAAgB,EAAE,CAAC;AAC9D,QAAQ,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC;AAChD,KAAK,CAAC;AACN;;;;"} |
+4
-9
@@ -8,12 +8,7 @@ 'use strict'; | ||
| function math(options = {}) { | ||
| // @ts-ignore | ||
| function math({ inlineMathDouble, katex, } = {}) { | ||
| return { | ||
| remarkTransformer: (u) => u.use(remarkMath, options.math), | ||
| rehypeTransformer: (u) => u.use(rehypeKatex, options.katex), | ||
| markdownSanitizeSchema: { | ||
| attributes: { | ||
| div: ['className'], | ||
| span: ['className'], | ||
| }, | ||
| }, | ||
| remark: (u) => u.use(remarkMath, { inlineMathDouble }), | ||
| rehype: (u) => u.use(rehypeKatex, katex), | ||
| }; | ||
@@ -20,0 +15,0 @@ } |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../src/index.js"],"sourcesContent":["import remarkMath from 'remark-math';\nimport rehypeKatex from 'rehype-katex';\nexport default function math(options = {}) {\n return {\n remarkTransformer: (u) => u.use(remarkMath, options.math),\n rehypeTransformer: (u) => u.use(rehypeKatex, options.katex),\n markdownSanitizeSchema: {\n attributes: {\n div: ['className'],\n span: ['className'],\n },\n },\n };\n}\n"],"names":[],"mappings":";;;;;;;AAEe,SAAS,IAAI,CAAC,OAAO,GAAG,EAAE,EAAE;AAC3C,IAAI,OAAO;AACX,QAAQ,iBAAiB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC;AACjE,QAAQ,iBAAiB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC;AACnE,QAAQ,sBAAsB,EAAE;AAChC,YAAY,UAAU,EAAE;AACxB,gBAAgB,GAAG,EAAE,CAAC,WAAW,CAAC;AAClC,gBAAgB,IAAI,EAAE,CAAC,WAAW,CAAC;AACnC,aAAa;AACb,SAAS;AACT,KAAK,CAAC;AACN;;;;"} | ||
| {"version":3,"file":"index.js","sources":["../src/index.js"],"sourcesContent":["// @ts-ignore\nimport remarkMath from 'remark-math';\n// @ts-ignore\nimport rehypeKatex from 'rehype-katex';\nexport default function math({ inlineMathDouble, katex, } = {}) {\n return {\n remark: (u) => u.use(remarkMath, { inlineMathDouble }),\n rehype: (u) => u.use(rehypeKatex, katex),\n };\n}\n"],"names":[],"mappings":";;;;;;;AAAA;AAIe,SAAS,IAAI,CAAC,EAAE,gBAAgB,EAAE,KAAK,GAAG,GAAG,EAAE,EAAE;AAChE,IAAI,OAAO;AACX,QAAQ,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,gBAAgB,EAAE,CAAC;AAC9D,QAAQ,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC;AAChD,KAAK,CAAC;AACN;;;;"} |
+2
-2
| { | ||
| "name": "@bytemd/plugin-math", | ||
| "version": "0.0.3", | ||
| "description": "@bytemd/plugin-math", | ||
| "version": "0.1.0", | ||
| "description": "ByteMD plugin to support math equation", | ||
| "author": "Rongjian Zhang <pd4d10@gmail.com>", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
+1
-9
@@ -5,3 +5,3 @@ # @bytemd/plugin-math | ||
| [bytemd](https://github.com/bytedance/bytemd) plugin to support math equation | ||
| ByteMD plugin to support math equation | ||
@@ -25,12 +25,4 @@ ## Usage | ||
| ## Example | ||
| ```md | ||
| $$ | ||
| c = \pm\sqrt{a^2 + b^2} | ||
| $$ | ||
| ``` | ||
| ## License | ||
| MIT |
+3
-6
| import { BytemdPlugin } from 'bytemd'; | ||
| import { KatexOptions } from 'katex'; | ||
| interface Options { | ||
| math?: { | ||
| inlineMathDouble?: boolean; | ||
| }; | ||
| export interface MathOptions { | ||
| inlineMathDouble?: boolean; | ||
| katex?: Omit<KatexOptions, 'displayMode'>; | ||
| } | ||
| export default function math(options?: Options): BytemdPlugin; | ||
| export {}; | ||
| export default function math({ inlineMathDouble, katex, }?: MathOptions): BytemdPlugin; |
3442
-20.47%31
-29.55%27
-22.86%