GithubHelp home page GithubHelp logo

mermaidjs / mermaid.cli Goto Github PK

View Code? Open in Web Editor NEW
1.1K 23.0 117.0 136 KB

Development has been moved to https://github.com/mermaid-js/mermaid-cli

License: MIT License

HTML 6.16% JavaScript 61.44% CSS 6.24% Shell 3.96% Mermaid 22.20%
mermaid

mermaid.cli's Introduction

THIS REPO IS NO LONGER BEING ACTIVELY DEVELOPED

Warning

Development has been moved to https://github.com/mermaid-js/mermaid-cli

The mermaid.cli NPM package is no longer being updated and is very out-of-date. Please use the @mermaid-js/mermaid-cli NPM package instead.


mermaid.cli

Command-line interface for mermaid.

This CLI tool takes a mermaid definition file as input and generates svg/png/pdf file as output.

Install locally

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

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

Or use NPM:

npm install 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.cli

Or

npm install -g mermaid.cli

Examples

mmdc -i input.mmd -o output.svg
mmdc -i input.mmd -o output.png
mmdc -i input.mmd -o output.pdf
mmdc -i input.mmd -o output.svg -w 1024 -H 768
mmdc -i input.mmd -t forest
mmdc -i input.mmd -o output.png -b '#FFF000'
mmdc -i input.mmd -o output.png -b transparent

Options

Please run the following command to see the latest options:

mmdc -h

The following is for your quick reference (may not be the latest version):

Usage: mmdc [options]


  Options:

    -V, --version                                   output the version number
    -t, --theme [theme]                             Theme of the chart, could be default, forest, dark or neutral. Optional. Default: default (default: default)
    -w, --width [width]                             Width of the page. Optional. Default: 800 (default: 800)
    -H, --height [height]                           Height of the page. Optional. Default: 600 (default: 600)
    -i, --input <input>                             Input mermaid file. Required.
    -o, --output [output]                           Output file. It should be either svg, png or pdf. Optional. Default: input + ".svg"
    -b, --backgroundColor [backgroundColor]         Background color. Example: transparent, red, '#F0F0F0'. Optional. Default: white
    -c, --configFile [configFile]                   JSON configuration file for mermaid. Optional
    -C, --cssFile [cssFile]                         CSS file for the page. Optional
    -p --puppeteerConfigFile [puppeteerConfigFile]  JSON configuration file for puppeteer. Optional
    -h, --help                                      output usage information

Linux sandbox issue

node:8281) UnhandledPromiseRejectionWarning: Error: Failed to launch chrome!
[0416/092218.828861:ERROR:zygote_host_impl_linux.cc(88)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
(node:8191) UnhandledPromiseRejectionWarning: Error: Failed to launch chrome!
[0416/091938.210735:FATAL:zygote_host_impl_linux.cc(124)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/master/docs/linux_suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.

First and foremost, you should not run as root and you should upgrade your Linux kernel to latest version.

But if you don't want to follow the advice above and just want to disable sandbox, here you go:

Create a puppeteer-config.json file:

{
  "args": ["--no-sandbox"]
}

And when you invoke mmdc:

mmdc -p puppeteer-config.json ...

For contributors

Setup

yarn install
source copy_modules.sh

Test

Use the fixtures in test/ to do manual testing after you change something.

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.