Comments (3)
This workaround worked for me: #59
from mermaid.cli.
My workaround is making an executable file at bin/mmd
in my project:
package.json
:
{
"dependencies": {
"mermaid": "^8.4.4",
"puppeteer": "^2.0.0"
}
}
bin/mmd
:
#!/usr/bin/env node
const puppeteer = require("puppeteer");
const fs = require("fs");
const input = fs.readFileSync(process.argv[2], "utf8");
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.addScriptTag({ path: "node_modules/mermaid/dist/mermaid.min.js" });
const result = await page.evaluate(
async ({ input }) => {
const element = document.createElement("div");
element.id = "root";
document.body.appendChild(element);
return await new Promise(resolve =>
mermaid.mermaidAPI.render("root", input, resolve)
);
},
{ input }
);
console.log(result);
await browser.close();
})();
chmod +x bin/mmd
Usage
bin/mmd UML.mmd > UML.svg
from mermaid.cli.
Development has moved to the https://github.com/mermaid-js/mermaid-cli repo, please re-open your issue there if it's still relevant.
The package has also been renamed on NPM to @mermaid-js/mermaid-cli
, so you may need to run npm uninstall mermaid.cli && npm install @mermaid-js/mermaid-cli
to get the latest version of this package.
Instead of copying in a static version of mermaid is it not possible to move mermaid to a normal (non-dev) dependency and have the JS code pull in the package version? Or perhaps better yet make it a peer dependency and then the installer can pick the version they want?
FYI, since Mermaid v10.0.0 this isn't very easy to do. Now that Mermaid is ESM only, you need https://
to import ESM scripts, and that doesn't work without running a local server and getting certificates set up. The way @mermaid-js/mermaid-cli
currently works is by bundling and transpiling the ESM code into one massive HTML file, which does work, but it can take a few minutes on a weak computer.
If you do want to use your own version of mermaid, you can do something like npm install git+https://github.com/mermaid-js/mermaid-cli.git
and then your package manager will automatically pick a suitable version of mermaid
to use with @mermaid-js/mermaid-cli
!
from mermaid.cli.
Related Issues (20)
- How customize tick class HOT 1
- Actually customize a theme HOT 1
- Cannot export erDiagram HOT 1
- Error not found: mmdc
- No output file generated HOT 1
- Cannot export mermaid script with "autonumber" tag HOT 1
- Error Incorrect usage of "merge". HOT 2
- Pipe to stdout ? HOT 1
- How to include native mermaid files into an html template HOT 1
- Idea: export to xml (mxGraphModel) HOT 1
- Pie Chart not supported? HOT 4
- How to generate png with transparent background? HOT 1
- Having issues with building .mmd with rect HOT 1
- Deterministic SVGs? HOT 3
- Gantt can't set date if DateFormat set HOT 1
- No arrowheads showing under v8.4.8, svg has bad marker-end url HOT 1
- Open an existing diagram in live editor HOT 1
- Custom css not working HOT 3
- Issues in an Apple Silicon Mac
- Support verbatim multiline text in node labels HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mermaid.cli.