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

@datatraccorporation/markdown-it-mermaid

v0.5.0

Published

Plugin to render mermaid diagrams in markdown-it

Downloads

20

Readme

markdown-it-mermaid

Mermaid plugin for markdown-it. (Forked from iradb2000/markdown-it-mermaid)

  • Update Mermaid to 8.5!
  • Support all mermaid diagrams
  • Add external title support
  • Use stable id for mermaid (good for static sites)

This version uses a different syntax to support mermaid. The syntax uses the syntax highlighting notation by putting the word mermaid directly after the opening fence marker.

Installation

npm install @DatatracCorporation/markdown-it-mermaid

Usage

import markdownIt from "markdown-it";
import markdownItMermaid from "@DatatracCorporation/markdown-it-mermaid";
const mdi = markdownIt();
mdi.use(markdownItMermaid);
mdi.render(`~~~mermaid optional title goes here
  graph TD
    A[Christmas] -->|Get money| B(Go shopping)
    B --> C{Let me think}
    C -->|One| D[Laptop]
    C -->|Two| E[iPhone]
    C -->|Three| F[Car]
~~~`);

The word mermaid after the fence code block opening indicates that the rest of the fenced block should be passed to mermaid for processing. This example used the ~~~ fence marker since the multi-line string in javascript is the same character, but either ~~~ or ``` works.

Titles

Mermaid does not support titles on the diagrams today. We have added an external title that you can use. Include the title on the code fence line after the word mermaid and it will be rendered as a div inside the parent div as a sibling to the svg image. The title element has a class of mermaid-title so you can style the title to fit your app.

We use:

/* image container */
div.mermaid {
    width: fit-content;
}

/* image title */
.mermaid-title {
    width: fit-content;
    margin: auto;
    font-weight: 900;
    font-size: 2em;
    color: white;
    padding-bottom: 0.5em;
}

/* image itself */
.mermaid > svg {
    margin: auto;
    display: block;
}

Customize mermaid

import MarkdownIt from 'markdown-it';
import MarkdownItKatex from '@DatatracCorporation/markdown-it-mermaid';

var md = MarkdownIt({
        html: false,
        linkify: true,
        typographer: true,
        breaks: true,
        xhtmlOut: false,
    });

md.use(MarkdownItMermaid,{
  startOnLoad: false,
  securityLevel: true,
  theme: "default",
  flowchart:{
    htmlLabels: false,
    useMaxWidth: true,
  }
  ...or any options
})

Development

Test

At this time, there are no unit tests since mermaid has to run in a browser (uses document apis). At some point in the future, we might go with a headless browser.

Distribution

npm version <newver> && npm publish