@@ -123,9 +123,11 @@ Everything under the `global` key applies to every generator:
123123 a URL or path to parse, or a pre-parsed array. ** Default:** ` [] `
124124 (single-version output).
125125- ` index ` {string|URL|Array} Index URL.
126+ - ` markdown ` {Object} [ Markdown plugins] ( #markdown-plugins ) for every
127+ generator processing Markdown.
126128
127129A generator's own section (e.g., ` html ` , ` legacy-json ` ) can override any of
128- these for that generator alone.
130+ these for that generator alone, except ` markdown ` , which it adds to .
129131
130132## Execution options
131133
@@ -155,6 +157,96 @@ export default {
155157};
156158```
157159
160+ ## Markdown plugins
161+
162+ ` doc-kit ` processes Markdown with [ unified] ( https://unifiedjs.com/ ) .
163+ ` global.markdown ` adds plugins to every generator processing Markdown, and a
164+ generator's own ` markdown ` adds plugins to it alone, after the global ones.
165+
166+ ``` mjs displayName="doc-kit.config.mjs"
167+ export default {
168+ global: {
169+ markdown: {
170+ remarkPlugins: [' remark-math' ],
171+ },
172+ },
173+
174+ // The generator rendering the site's pages
175+ ' jsx-ast' : {
176+ markdown: {
177+ rehypePlugins: [
178+ ' rehype-katex' ,
179+ [' ./plugins/rehype-diagrams.mjs' , { theme: ' neutral' }],
180+ ],
181+ },
182+ },
183+ };
184+ ```
185+
186+ Each plugin is a module specifier (a package name, or a path relative to the
187+ configuration file), alone or in a ` [specifier, options] ` pair. The module
188+ default-exports the plugin, a list of plugins, or a unified preset. Markdown is
189+ processed in worker threads, which import the plugins themselves, so options
190+ must be serializable: configure a plugin taking functions in a module of your
191+ own.
192+
193+ - ` remarkPlugins ` {Array} The global ones run on each document once the ` ast `
194+ generator parses it, so every output sees their changes. A generator
195+ rendering Markdown, such as ` jsx-ast ` , runs its own on what it renders.
196+ - ` rehypePlugins ` {Array} Run on the HTML of the generators rendering
197+ Markdown, such as ` jsx-ast ` , before code is highlighted.
198+ - ` recmaPlugins ` {Array} Run on the JavaScript ` jsx-ast ` compiles the pages to.
199+
200+ A generator only takes the plugins its pipeline has a place for: ` jsx-ast `
201+ takes all three kinds, ` ast ` , ` metadata ` , and ` json ` take remark plugins, and
202+ generators such as ` html ` take none. Plugins listed for a generator that
203+ doesn't take them are ignored with a warning.
204+
205+ A generator runs each plugin once: listing one it already has, its own or a
206+ global one, configures it instead, merging the options (arrays add up, and
207+ objects merge).
208+
209+ The plugins configured for ` jsx-ast ` don't apply to the fragments it renders
210+ on their own: types, parameter descriptions, and change history notes.
211+
212+ ### Code highlighting
213+
214+ ` jsx-ast ` highlights code with the ` @doc-kit/core/plugins/shiki/rehype.mjs `
215+ plugin, which runs [ Shiki] ( https://shiki.style/ ) with every language it
216+ bundles. To configure it, list it with options in
217+ ` jsx-ast.markdown.rehypePlugins ` (with pnpm, add ` @doc-kit/core ` to your
218+ dependencies, so your configuration file can resolve it):
219+
220+ - ` langs ` {Array} More languages: grammars, or modules default-exporting them.
221+ - ` langAlias ` {Object} Aliases of languages, such as ` { conf: 'ini' } ` .
222+ - ` themes ` {Object} The ` light ` and ` dark ` themes: names of themes Shiki
223+ bundles, modules default-exporting themes, or themes.
224+ - ` transformers ` {Array} Modules default-exporting
225+ [ Shiki transformers] ( https://shiki.style/guide/transformers ) , or lists of
226+ them.
227+
228+ These modules are paths relative to the working directory, or URLs, such as
229+ the ones ` import.meta.resolve() ` gives:
230+
231+ ``` mjs displayName="doc-kit.config.mjs"
232+ export default {
233+ ' jsx-ast' : {
234+ markdown: {
235+ rehypePlugins: [
236+ [
237+ ' @doc-kit/core/plugins/shiki/rehype.mjs' ,
238+ {
239+ langAlias: { conf: ' ini' },
240+ themes: { light: ' github-light' , dark: ' github-dark' },
241+ transformers: [import .meta.resolve(' ./shiki-transformers.mjs' )],
242+ },
243+ ],
244+ ],
245+ },
246+ },
247+ };
248+ ```
249+
158250## Configuration Merging
159251
160252Configurations are merged in the following order (higher sources take
0 commit comments