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

gitbook-plugin-mermaid-cli

v1.0.15

Published

Pipe wrapper for mermaid.cli

Downloads

24

Readme

Render flowcharts in markdown with mermaid.cli.

version download

Features

  • Based on mermaid.cli/puppeteer, generate svg with base64 encode at compile time, no external css and js required.
  • Same API like gitbook-plugin-mermaid/Typora
  • Support ebook(pdf/mobi/epub) exporting

How Does it work

1. Your mermaid string quote with mermaid
2. Puppeteer/Chrome Runtime
3. SVG(XML)
4. <img src='data:image/svg+xml;base64,xxxx'>

Pre Installation

Puppeteer is a tool to control Chrome via javascript, and mermaid.cli is a wrapper for mermaid on top of Chrome runtime.The installation of puppeteer may be hard on private network, so I created a plugin to skip download the Chrome.

You need to install the Chrome anywhere(yum, brew, or install.exe). Chrome 68+ is preferred. If you're running on CentOS6, latest Chrome is not supported.

Install

in the book.json:

config your chrome exec file

On Mac/Linux

{
  "plugins": ["mermaid-cli"],
  "pluginsConfig": {
    "mermaid-cli": {
      "chromeDir": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
      "chromeArgs": []
    }
  }
}

On Windows

{
  "plugins": ["mermaid-cli"],
  "pluginsConfig": {
    "mermaid-cli": {
      "chromeDir": "C:\\xxx\\Google Chrome\\chrome.exe",
      "chromeArgs": []
    }
  }
}

If you are running as root, you may pass "chromeArgs": ["--no-sandbox"] to fix the error. If you are running on Windows, make sure to add escape character like C:\\xx\\xx.exe.

then

# see https://github.com/GoogleChrome/puppeteer/blob/v1.8.0/docs/api.md#environment-variables
# on Mac/Linux
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
# on Windows(PowerShell)
# $Env:PUPPETEER_SKIP_CHROMIUM_DOWNLOAD = "true"

# then install plugin
gitbook install
# run the gitbook
gitbook serve

Now we can use a local Chrome Runtime without download the slowly large file from npm.

If "Error: spawn E2BIG", please run gitbook install again.

How to use it?

It's the same API as JozoVilcek/piranna's gitbook-plugin-mermaid

There are two options how can be graph put into the gitbook. To use ~~embedded~~ graph, put in your book block as:

{% mermaid %}
graph TD;
  A-->B;
  A-->C;
  B-->D;
  C-->D;
{% endmermaid %}

or

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

Plugin will pick up block body and replace it with generated base64 svg diagram. To load graph ~~from file~~, put in your book block as:

{% mermaid src="./diagram.mermaid" %}
{% endmermaid %}

If not absolute, plugin will resolve path given in src attribute relative to the current book page, load its content and generate svg diagram.

TODO

  • remove unnecessary style from svg