remark-mermaid-svg
v1.0.4
Published
A remark plugin that replaces Mermaid diagrams with SVGs (without Playwright!).
Downloads
21
Maintainers
Readme
remark-mermaid
A remark plugin to render mermaid diagrams. No playwright!
This plugin is heavily based on the original (now archived) remark-mermaidjs and is designed to work more easily with the latest versions of mermaid.
Table of Contents
Installation
npm install remark-mermaidUsage
This plugin takes all code blocks marked as mermaid and renders them as an inline SVG.
import { readFile } from "node:fs/promises";
import { remark } from "remark";
import remarkMermaid from "remark-mermaidjs";
const { value } = await remark()
.use(remarkMermaid, {
/* Options */
})
.process(await readFile("readme.md"));
console.log(value);API
This package has a default export remarkMermaid.
unified().use(remarkMermaid, options?)
errorFallback
Create a fallback node if processing of a mermaid diagram fails. If nothing is returned, the code block is removed. The function receives the following arguments:
node: The mdastcodenode that couldn't be rendered.error: The error message that was thrown.file: The file on which the error occurred.
mermaidConfig
The mermaid config to use.
prefix
A custom prefix to use for Mermaid IDs. (string, default: mermaid)
Related Projects
mermaidis the library that's used to render the diagrams.remark-mermaidjsis the original plugin that this project is based on.rehype-mermaidis a more powerful plugin that does the same as remark-mermaidjs, but as a rehype plugin. It also uses Playwright to render the diagrams.
