Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
A Mermaid diagram to image library.
A Mermaid diagram to image library.
Usage
Use the generate()
function to convert Mermaid diagram markdown to an SVG:
import { generate } from "@kitsonk/mdd2img"; const mdd = `graph TD; A-->B;`; const svg = await generate(mdd); await Deno.writeTextFile("output.svg", svg);
About
This library was inspired by Mermaid.ink and meant as a easy way to render Mermaid diagrams. While there has been an effort to "server side" render Mermaid diagrams, there is a huge amount of complexity as Mermaid diagrams leverage such a wide spectrum of the web platform that would have to be replicated in a pure server side limitation. All current solutions, including Mermaid.ink and the Mermaid CLI use some form of headless browser to actually render the diagrams.
This library uses Astral library to procedurally control a browser to render the diagram and return the resulting image.
Add Package
deno add jsr:@kitsonk/mdd2img
Import symbol
import * as mdd_img from "@kitsonk/mdd2img";
Import directly with a jsr specifier
import * as mdd_img from "jsr:@kitsonk/mdd2img";
Add Package
pnpm i jsr:@kitsonk/mdd2img
pnpm dlx jsr add @kitsonk/mdd2img
Import symbol
import * as mdd_img from "@kitsonk/mdd2img";
Add Package
yarn add jsr:@kitsonk/mdd2img
yarn dlx jsr add @kitsonk/mdd2img
Import symbol
import * as mdd_img from "@kitsonk/mdd2img";
Add Package
vlt install jsr:@kitsonk/mdd2img
Import symbol
import * as mdd_img from "@kitsonk/mdd2img";
Add Package
npx jsr add @kitsonk/mdd2img
Import symbol
import * as mdd_img from "@kitsonk/mdd2img";
Add Package
bunx jsr add @kitsonk/mdd2img
Import symbol
import * as mdd_img from "@kitsonk/mdd2img";