Skip to content

A simple markdown-it extension to add support for mermaid and svgbob diagrams.

Notifications You must be signed in to change notification settings

dmayle/markdown-it-diagrams

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

markdown-it-diagrams

Diagrams renderer for markdown-it, using svgbob, and mermaidjs.

Example code

An example svgbob diagram:

``` bob 
     .---.
    /-o-/--
 .-/ / /->
( *  \/
 '-.  \
    \ /
     '
```

And a mermaid diagram:

``` mermaid 
graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;
```

API

The svgbob-wasm dependency which provides svgbob support is a wasm module. In order to load the dependency asynchronously, this plugin exposes an async function awaitRenderAvailable which should be awaited prior to markdown rendering:

import {awaitRenderAvailable} from "markdown-it-diagrams"
import {diagramPlugin} from "markdown-it-diagrams";
import * as MarkdownIt from "markdown-it";


let md = new MarkdownIt({
  html: true,
}).use(diagramPlugin);

let someMarkdown = "``` bob \n" +
        "     .---.\n" +
        "    /-o-/--\n" +
        " .-/ / /->\n" +
        "( *  \\/\n" +
        " '-.  \\\n" +
        "    \\ /\n" +
        "     '\n" +
        "```";
await awaitRenderAvailable();
let html = md.render(someMarkdown);
console.log(html);

About

A simple markdown-it extension to add support for mermaid and svgbob diagrams.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%