Code Monkey home page Code Monkey logo

mermaid-cli's Introduction

mermaid-cli

This is a command-line interface (CLI) for mermaid. It takes a mermaid definition file as input and generates an svg/png/pdf file as output.

Join our Slack! This project is using Percy.io for visual regression testing. Build, test and deploy

Example Usage

Locate how to call the mmdc executable for your preferred method i.e. Docker, Yarn, NPM, global install, etc. Try these examples to get started quickly.

Convert Mermaid mmd Diagram File To SVG

mmdc -i input.mmd -o output.svg

Create A PNG With A Dark Theme And Transparent Background

mmdc -i input.mmd -o output.png -t dark -b transparent

Transform a markdown file with mermaid diagrams

mmdc -i readme.template.md -o readme.md

This command transforms a markdown file itself. The mermaid-cli will find the mermaid diagrams, create SVG files from them and refer to those in the markdown output.

This:

### Some markdown
```mermaid
graph
   [....]
```

### Some more markdown
```mermaid
sequenceDiagram
   [....]
```

Becomes:

### Some markdown
![diagram](./readme-1.svg)

### Some more markdown
![diagram](./readme-2.svg)

Piping from stdin

You can easily pipe input from stdin. This example shows how to use a heredoc to send a diagram as stdin to mermaid-cli (mmdc).

cat << EOF  | mmdc
    graph TD
    A[Client] --> B[Load Balancer]
EOF

See All Available Options

mmdc -h

Use Docker:

docker pull minlag/mermaid-cli

or pull from Github Container Registry

docker pull ghcr.io/mermaid-js/mermaid-cli/mermaid-cli

or e.g. version 8.8.0

docker pull minlag/mermaid-cli:8.8.0

The container looks for input files in /data. So for example, if you have a diagram defined on your system in /path/to/diagrams/diagram.mmd, you can use the container to generate an SVG file as follows:

docker run -it -v /path/to/diagrams:/data minlag/mermaid-cli -i /data/diagram.mmd

Install locally

Some people are having issues installing this tool globally. Installing it locally is an alternative solution:

yarn add @mermaid-js/mermaid-cli
./node_modules/.bin/mmdc -h

Or use NPM:

npm install @mermaid-js/mermaid-cli
./node_modules/.bin/mmdc -h

Install globally

โ—๏ธ We do NOT recommend installing it globally because both YARN and NPM could fail to install a command-line tool globally properly due to weird permission issues. yarn global add @mermaid-js/mermaid-cli or npm install -g @mermaid-js/mermaid-cli

Install with brew

brew install mermaid-cli

Run with npx

npx is installed by default with NPM. It downloads and runs commands at the same time. To use Mermaid CLI with npx, you need to use the -p flag because the package name is different than the command it installs (mmdc). npx -p @mermaid-js/mermaid-cli mmdc -h

Known issues

  1. Linux sandbox issue
  2. Docker permission denied issue

For contributors

Contributions are welcome. See the contribution guide.

mermaid-cli's People

Contributors

mindaugaslaganeckas avatar dependabot[bot] avatar tylerlong avatar github-actions[bot] avatar knsv avatar mmorel-35 avatar erikluo avatar bgschiller avatar daladim avatar agusmba avatar ghtyrant avatar capellini avatar mikeder avatar yash-singh1 avatar jg123 avatar fregante avatar bastianzim avatar aler9 avatar nicojs avatar neilcuzon avatar adeboyed avatar dwvisser avatar 0xflotus avatar alexkrolick avatar abitrolly avatar dominicdoty avatar larsw avatar melhindi avatar pshomov avatar combinatorist avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.