diff --git a/lib/ast-processor.ts b/lib/ast-processor.ts index 90a72e174..2a09ec6d7 100644 --- a/lib/ast-processor.ts +++ b/lib/ast-processor.ts @@ -5,9 +5,11 @@ import remarkGfm from 'remark-gfm'; import transformers, { readmeComponentsTransformer, variablesTransformer } from '../processor/transform'; import rehypeSlug from 'rehype-slug'; +import { PluggableList } from 'unified'; export type MdastOpts = { components?: Record; + remarkPlugins?: PluggableList; }; export const remarkPlugins = [remarkFrontmatter, remarkGfm, ...transformers]; @@ -17,6 +19,7 @@ const astProcessor = (opts: MdastOpts = { components: {} }) => remark() .use(remarkMdx) .use(remarkPlugins) + .use(opts.remarkPlugins) .use(variablesTransformer, { asMdx: false }) .use(readmeComponentsTransformer({ components: opts.components })); diff --git a/lib/hast.ts b/lib/hast.ts index f8960f6ed..e61647d79 100644 --- a/lib/hast.ts +++ b/lib/hast.ts @@ -1,4 +1,4 @@ -import astProcessor, { rehypePlugins } from './ast-processor'; +import astProcessor, { rehypePlugins, MdastOpts } from './ast-processor'; import remarkRehype from 'remark-rehype'; import { injectComponents } from '../processor/transform'; import { MdastComponents } from '../types'; @@ -6,11 +6,7 @@ import mdast from './mdast'; import { unified } from 'unified'; import rehypeParse from 'rehype-parse'; -interface Options { - components?: Record; -} - -const hast = (text: string, opts: Options = {}) => { +const hast = (text: string, opts: MdastOpts = {}) => { const components: MdastComponents = Object.entries(opts.components || {}).reduce((memo, [name, doc]) => { memo[name] = mdast(doc); return memo;