Skip to content

@beoe/rehype-vizdom

Rehype plugin to generate Vizdom diagrams in place of code fences. Example:

Installation

Terminal window
npm i @beoe/rehype-vizdom

Usage

import rehypeVizdom from "@beoe/rehype-vizdom";
const html = await unified()
.use(remarkParse)
.use(remarkRehype)
.use(rehypeVizdom, {
/* options */
})
.use(rehypeStringify)
.process(`markdown`);

Check out other options.

Configuration

You probaly want to use inline strategy and implement dark scheme via CSS:

.vizdom {
:not([fill]) {
fill: var(--sl-color-white);
}
[fill="black"],
[fill="#000"] {
fill: var(--sl-color-white);
}
[stroke="black"],
[stroke="#000"] {
stroke: var(--sl-color-white);
}
[fill="white"],
[fill="#fff"] {
fill: var(--sl-color-black);
}
[stroke="white"],
[stroke="#fff"] {
stroke: var(--sl-color-black);
}
}

Tip

inline strategy allows to use interactivity.

graphFormat

graphFormat specifies format of a graph to pass to data-beoe attribute. If value is falsy no data is passed. Currently supports two formats: graphology and dagre.

data-beoe meant to be used on client side for interactivity. You can grab it parse as JSON and pass “graph” library, for example:

Issues