0.2.8 • Published 1 year ago

@gnomad-cloud/gridsome-plugin-remark-diagrams v0.2.8

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Draw diagrams in markdown

This gridsome plugin allows you to draw diagrams by sketching the symbols using markdown. We embed the mermaid libary to do the drawing itself.

Once installed, we can embed mermaid code blocks in our markdown.

To generate a simple diagram, we can write:

diagram
graph LR
  A --> B
  B --> C
graph LR
  A --> B
  B --> C

Install

Follow the generic instructions for gridsome first.

bash
npm install gridsome-plugin-remark-diagrams

Usage

Configure gridsome.config.js to use the plugin.

  transformers: {
    remark: {
      plugins: [
        'gridsome-plugin-remark-diagrams',
        // existing plugins //
      ]
    }
  }

Advanced Styling

The generated SVG is wrapped in <div class="mermaid"></div> to help you customize your styles.

When using the removeStyleTags attribute, you will need to import your Mermaid themes yourself.

Options

NameDefaultDescription
language"diagrams"The code block tag.
theme"default""dark""neutral""forest""default"
viewport.width200width of image
viewport.height200height of image
removeStyleTagsfalseRemove all style tags from the generated SVG. If you use this option you will have to import the mermaid css at some point
idmermaid-<currentTime>Sets the identifier of the SVG. Defaults to a unique ID based on the time of generation
mermaidOptions{}use custom mermaid configuration options to mermaid.initialize()

The default options are:

{
  language: "mermaid",
  theme: "default",
  viewport: {
    width: 200,
    height: 200
  },
  id: null,
  removeStyleTags: false,
  mermaidOptions: {}
}

Provenance / Credits

This plugin was forked, upgraded and adopted with gratitude to the original authors.

You can find the original versions here: