@mdast2docx/mermaid
Version:
Enhance Markdown-to-DOCX conversion with Mermaid and mindmap diagram support using this plugin for @m2d/core. Converts code blocks into SVG images with customizable Mermaid config.
33 lines (32 loc) • 1.31 kB
TypeScript
import { IPlugin } from "@m2d/core";
import { MermaidConfig, RenderResult } from "mermaid";
import { type CacheConfigType } from "@m2d/core/cache";
interface IMermaidPluginOptions {
/**
* Options for configuring Mermaid rendering.
*
* Pass a partial MermaidConfig object to customize behavior.
* Refer to the Mermaid documentation for full configuration options:
* @see https://mermaid.js.org/configuration.html
*/
mermaidConfig?: MermaidConfig;
/**
* Optional fixer function to repair invalid Mermaid code before retrying render.
*/
fixMermaid?: (mermaidCode: string, error: Error) => string;
/**
* In-memory cache object, useful for cache sharing across plugins/tabs.
*/
cache?: Record<string, Promise<unknown>>;
/** Configure caching */
cacheConfig?: CacheConfigType<RenderResult | undefined>;
/** Clean up the entries that are not used for following minutes. @default 30 * 24 * 60 -- that is 30 days */
maxAgeMinutes?: number;
}
/**
* Mermaid plugin for @m2d/core.
* Detects `mermaid`, `mmd`, and `mindmap` code blocks and converts them to SVG.
* The resulting SVGs are later rendered as images in DOCX exports.
*/
export declare const mermaidPlugin: (options?: IMermaidPluginOptions) => IPlugin;
export {};