npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gatsby-remark-draw

v1.0.16

Published

A wrapper around popular graphing tools (GraphViz, SvgBobRus, Mermaid) to convert text based diagrams in Markdown to SVG.

Downloads

400

Readme

gatsby-remark-draw

npm version Build Status Maintainability Dependencies

A wrapper around some popular graph tools to generate diagrams from embedded code blocks in Markdown with Gatsby.js and Remark.

This package currently supports:

TODO:

  • ~~Enable options to be passed to executables~~
  • ~~Mermaid support~~
  • ~~Other GraphViz layout engines like neato~~
  • ~~Embed as img tag option~~
  • Tranform links to graph files

This package uses a simple (naive) mechanism - by default, read the code block, pass it the selected process and replace the current code block with the generated SVG wrapped in a div. For styling purposes the class names are the following:

  • remark-draw
  • remark-draw-dot (for GraphViz graphs)
  • remark-draw-svgbob (for SvgBobRus graphs)

In order to avoid conflicts with syntax highligters the language is postfixed with "-svg".

To rather write the files to disk and replace the code block with an <img> tag you can specify the strategy: img option inside options. The generated SVG files will be written to the public directory and linked from there. For styling purposes the generated image title starts with remark-draw.

Usage

npm install gatsby-remark-draw --save

In your gatsby-config.js add this plugin under the gatsby-transformer-remark plugin:

resolve: "gatsby-transformer-remark",
      options: {
		"strategy": "img",
        "plugins": [
          "gatsby-remark-draw"
        ]
      }
// ...

It's important to add this plugin before any other plugin that processes code blocks like gatsby-remark-prismjs.

Since v1.0.8 options can now be passed through to the rendering engine to change default settings. For example,

resolve: 'gatsby-remark-draw',
	options: {
		dot: {
			edgeAttributes: {
				'arrowtail': 'empty',
				'arrowhead': 'empty'
			}
		},
		bob: {
			fontFamily: 'verdana'
		},
		mermaid: {
			theme: 'forest'
		}
	}
}

Please see the Skyrta documentation for details on the options available.

Diagrams

SvgBobRus diagrams

This package expects svgbob_cli to available in the system path. Installation:

cargo install svgbob_cli

You can find specific instructions on the repo page.

In Markdown you can use a normal code-block with language set to "bob-svg":

Bob markup

Which will provide the following (rendered) inline SVG diagram:

Bob diagram

Graphviz

Graphviz can be installed in most cases via your package manager. See the download page for manual downloads and installation instruction instructions.

In Markdown you can use a normal code-block with language set to "dot-svg" which will use the dot engine to produce the image:

Graphviz markup

will provide the following (rendered) inline SVG diagram:

Graphviz output

Mermaid

To render Mermaid graphs you need to install both the mermaid and the cli packages:

npm install mermaid mermaid.cli --save

Note the . in the cli package name - the package with a - that shall not be named here has been deprecated.

A sample flowchart from the main Mermaid repository:

Graphviz markup

will provide the following (rendered) SVG diagram:

Mermaid output

Demo

Demos can be found here.