mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-01 14:46:41 +02:00
docs: ESM import
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
# mermaid [](https://travis-ci.org/mermaid-js/mermaid) [](https://www.npmjs.com/package/mermaid) [](https://coveralls.io/github/mermaid-js/mermaid?branch=master) [](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE)
|
# mermaid
|
||||||
|
|
||||||
# Whoa, whats going on here?
|
[](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml) [](https://www.npmjs.com/package/mermaid) [](https://coveralls.io/github/mermaid-js/mermaid?branch=master) [](https://www.jsdelivr.com/package/npm/mermaid) [](https://www.npmjs.com/package/mermaid) [](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE)
|
||||||
|
|
||||||
|
# Whoa, what's going on here?
|
||||||
|
|
||||||
We are transforming the Mermaid repository to a so called mono-repo. This is a part of the effort to decouple the diagrams from the core of mermaid. This will:
|
We are transforming the Mermaid repository to a so called mono-repo. This is a part of the effort to decouple the diagrams from the core of mermaid. This will:
|
||||||
|
|
||||||
|
@@ -1,4 +1,6 @@
|
|||||||
# mermaid [](https://travis-ci.org/mermaid-js/mermaid) [](https://www.npmjs.com/package/mermaid) [](https://coveralls.io/github/mermaid-js/mermaid?branch=master) [](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE)
|
# mermaid
|
||||||
|
|
||||||
|
[](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml) [](https://www.npmjs.com/package/mermaid) [](https://coveralls.io/github/mermaid-js/mermaid?branch=master) [](https://www.jsdelivr.com/package/npm/mermaid) [](https://www.npmjs.com/package/mermaid) [](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE)
|
||||||
|
|
||||||
[English](./README.md) | 简体中文
|
[English](./README.md) | 简体中文
|
||||||
|
|
||||||
|
@@ -10,7 +10,7 @@ It is a JavaScript based diagramming and charting tool that renders Markdown-ins
|
|||||||
|
|
||||||
<img src="img/header.png" alt="" />
|
<img src="img/header.png" alt="" />
|
||||||
|
|
||||||
[](https://travis-ci.org/mermaid-js/mermaid) [](https://www.npmjs.com/package/mermaid) [](https://coveralls.io/github/mermaid-js/mermaid?branch=master) [](https://www.jsdelivr.com/package/npm/mermaid) [](https://www.npmjs.com/package/mermaid) [](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE)
|
[](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml) [](https://www.npmjs.com/package/mermaid) [](https://coveralls.io/github/mermaid-js/mermaid?branch=master) [](https://www.jsdelivr.com/package/npm/mermaid) [](https://www.npmjs.com/package/mermaid) [](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE)
|
||||||
|
|
||||||
<!-- Mermaid book banner -->
|
<!-- Mermaid book banner -->
|
||||||
|
|
||||||
@@ -271,11 +271,11 @@ To Deploy Mermaid:
|
|||||||
|
|
||||||
### [Mermaid API](./Setup.md):
|
### [Mermaid API](./Setup.md):
|
||||||
|
|
||||||
**To deploy mermaid without a bundler, one can insert a `script` tag with an absolute address and a `mermaidAPI` call into the HTML like so:**
|
**To deploy mermaid without a bundler, one can insert a `script` tag with an absolute address and a `mermaid.initialize` call into the HTML like so:**
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<script src="https://cdn.jsdelivr.net/npm/mermaid@9.2.0-rc2/dist/mermaid.min.js"></script>
|
<script type="module">
|
||||||
<script>
|
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@9/dist/mermaid.esm.min.mjs';
|
||||||
mermaid.initialize({ startOnLoad: true });
|
mermaid.initialize({ startOnLoad: true });
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
@@ -21,8 +21,6 @@
|
|||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/all.min.css"
|
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/all.min.css"
|
||||||
/>
|
/>
|
||||||
<script src="//cdn.jsdelivr.net/npm/mermaid@9.1.7/dist/mermaid.min.js"></script>
|
|
||||||
<!-- <script src="http://localhost:9000/mermaid.js"></script> -->
|
|
||||||
<script
|
<script
|
||||||
defer=""
|
defer=""
|
||||||
data-domain="mermaid-js.github.io"
|
data-domain="mermaid-js.github.io"
|
||||||
@@ -50,6 +48,10 @@
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
<script type="module">
|
||||||
|
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.esm.min.mjs';
|
||||||
|
window.mermaid = mermaid;
|
||||||
|
</script>
|
||||||
<script>
|
<script>
|
||||||
var initEditor = exports.default;
|
var initEditor = exports.default;
|
||||||
var parser = new DOMParser();
|
var parser = new DOMParser();
|
||||||
@@ -99,6 +101,7 @@
|
|||||||
colorize.push(currentCodeExample);
|
colorize.push(currentCodeExample);
|
||||||
return '<pre id="code' + currentCodeExample + '">' + escapeHTML(code) + '</pre>';
|
return '<pre id="code' + currentCodeExample + '">' + escapeHTML(code) + '</pre>';
|
||||||
} else if (lang === 'mermaid') {
|
} else if (lang === 'mermaid') {
|
||||||
|
// TODO: This will need to be updated when render is async.
|
||||||
return (
|
return (
|
||||||
'<pre class="mermaid">' + mermaid.render('mermaid-svg-' + num++, code) + '</pre>'
|
'<pre class="mermaid">' + mermaid.render('mermaid-svg-' + num++, code) + '</pre>'
|
||||||
);
|
);
|
||||||
|
@@ -75,23 +75,13 @@ The API works by pulling rendering instructions from the source `mermaid.js` in
|
|||||||
|
|
||||||
### Requirements for the Mermaid API.
|
### Requirements for the Mermaid API.
|
||||||
|
|
||||||
When writing the .html file, we give three instructions inside the html code to the web browser:
|
When writing the .html file, we give two instructions inside the html code to the web browser:
|
||||||
|
|
||||||
a. A reference for fetching the online mermaid renderer, through the `mermaid.js` or `mermaid.min.js`.
|
a. The mermaid code for the diagram we want to create.
|
||||||
|
|
||||||
b. The mermaid code for the diagram we want to create.
|
b. The importing of mermaid library through the `mermaid.esm.js` or `mermaid.esm.min.mjs` and the `mermaid.initialize()` call, which dictates the appearance of diagrams and also starts the rendering process .
|
||||||
|
|
||||||
c. The `mermaid.initialize()` call, which dictates the appearance of diagrams and also starts the rendering process .
|
**a. The embedded mermaid diagram definition inside a `<pre class="mermaid">`:**
|
||||||
|
|
||||||
**a. A reference to the external CDN in a `<script src>` tag, or a reference to mermaid.js as a separate file.:**
|
|
||||||
|
|
||||||
```html
|
|
||||||
<body>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/mermaid@9.2.0-rc2/dist/mermaid.min.js"></script>
|
|
||||||
</body>
|
|
||||||
```
|
|
||||||
|
|
||||||
**b. The embedded mermaid diagram definition inside a `<pre class="mermaid">`:**
|
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<body>
|
<body>
|
||||||
@@ -107,13 +97,14 @@ c. The `mermaid.initialize()` call, which dictates the appearance of diagrams an
|
|||||||
|
|
||||||
**Notes**: Every Mermaid chart/graph/diagram definition, should have separate `<pre>` tags.
|
**Notes**: Every Mermaid chart/graph/diagram definition, should have separate `<pre>` tags.
|
||||||
|
|
||||||
**c. The `mermaid.initialize()` call.**
|
**b. The import of mermaid and the `mermaid.initialize()` call.**
|
||||||
|
|
||||||
`mermaid.initialize()` call takes all the definitions contained in all the `<pre class="mermaid">` tags that it finds in the html body and renders them into diagrams. Example:
|
`mermaid.initialize()` call takes all the definitions contained in all the `<pre class="mermaid">` tags that it finds in the html body and renders them into diagrams. Example:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<body>
|
<body>
|
||||||
<script>
|
<script type="module">
|
||||||
|
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@9/dist/mermaid.esm.min.mjs';
|
||||||
mermaid.initialize({ startOnLoad: true });
|
mermaid.initialize({ startOnLoad: true });
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
@@ -135,11 +126,6 @@ Rendering in Mermaid is initialized by `mermaid.initialize()` call. You can plac
|
|||||||
```html
|
```html
|
||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/mermaid@9.2.0-rc2/dist/mermaid.min.js"></script>
|
|
||||||
<script>
|
|
||||||
mermaid.initialize({ startOnLoad: true });
|
|
||||||
</script>
|
|
||||||
|
|
||||||
Here is one mermaid diagram:
|
Here is one mermaid diagram:
|
||||||
<pre class="mermaid">
|
<pre class="mermaid">
|
||||||
graph TD
|
graph TD
|
||||||
@@ -156,6 +142,11 @@ Rendering in Mermaid is initialized by `mermaid.initialize()` call. You can plac
|
|||||||
B -->|tcp_456| C[Server1]
|
B -->|tcp_456| C[Server1]
|
||||||
B -->|tcp_456| D[Server2]
|
B -->|tcp_456| D[Server2]
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
<script type="module">
|
||||||
|
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@9/dist/mermaid.esm.min.mjs';
|
||||||
|
mermaid.initialize({ startOnLoad: true });
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
```
|
```
|
||||||
@@ -181,8 +172,8 @@ In this example mermaid.js is referenced in `src` as a separate JavaScript file,
|
|||||||
B --> C[Server1]
|
B --> C[Server1]
|
||||||
B --> D[Server2]
|
B --> D[Server2]
|
||||||
</pre>
|
</pre>
|
||||||
<script src="The\Path\In\Your\Package\mermaid.js"></script>
|
<script type="module">
|
||||||
<script>
|
import mermaid from 'The/Path/In/Your/Package/mermaid.ems.mjs';
|
||||||
mermaid.initialize({ startOnLoad: true });
|
mermaid.initialize({ startOnLoad: true });
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
@@ -206,4 +197,4 @@ In this example mermaid.js is referenced in `src` as a separate JavaScript file,
|
|||||||
|
|
||||||
**Comments from Knut Sveidqvist, creator of mermaid:**
|
**Comments from Knut Sveidqvist, creator of mermaid:**
|
||||||
|
|
||||||
- In early versions of mermaid, the `<script src>` tag was invoked in the `<head>` part of the web page. Nowadays we can place it in the `<body>` as seen above. Older parts of the documentation frequently reflects the previous way which still works.
|
- In early versions of mermaid, the `<script>` tag was invoked in the `<head>` part of the web page. Nowadays we can place it in the `<body>` as seen above. Older parts of the documentation frequently reflects the previous way which still works.
|
||||||
|
@@ -39,23 +39,9 @@ We have compiled some Video [Tutorials](./Tutorials.md) on how to use the mermai
|
|||||||
|
|
||||||
> Note:This topic explored in greater depth in the [User Guide for Beginners](./n00b-gettingStarted.md)
|
> Note:This topic explored in greater depth in the [User Guide for Beginners](./n00b-gettingStarted.md)
|
||||||
|
|
||||||
The easiest way to integrate mermaid on a web page requires three elements:
|
The easiest way to integrate mermaid on a web page requires two elements:
|
||||||
|
|
||||||
1. Inclusion of the mermaid address in the html page using a `script` tag, in the `src` section.Example:
|
- A graph definition, inside `<pre>` tags labeled `class=mermaid`. Example:
|
||||||
|
|
||||||
```html
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/mermaid@9.2.0-rc2/dist/mermaid.min.js"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
2. The `mermaidAPI` call, in a separate `script` tag. Example:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<script>
|
|
||||||
mermaid.initialize({ startOnLoad: true });
|
|
||||||
</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
3. A graph definition, inside `<div>` tags labeled `class=mermaid`. Example:
|
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<pre class="mermaid">
|
<pre class="mermaid">
|
||||||
@@ -66,8 +52,18 @@ The easiest way to integrate mermaid on a web page requires three elements:
|
|||||||
</pre>
|
</pre>
|
||||||
```
|
```
|
||||||
|
|
||||||
**Following these directions, mermaid starts at page load and (when the page has loaded) it will
|
- Inclusion of the mermaid address in the html page body using a `script` tag as an ESM import, and the `mermaidAPI` call.
|
||||||
locate the graph definitions inside the `div` tags with `class="mermaid"` and return diagrams in SVG form, following given definitions.**
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@9/dist/mermaid.esm.min.mjs';
|
||||||
|
mermaid.initialize({ startOnLoad: true });
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
**Following these directions, mermaid starts at page load and (when the page has loaded) it will locate the graph definitions inside the `pre` tags with `class="mermaid"` and return diagrams in SVG form, following given definitions.**
|
||||||
|
|
||||||
## Simple full example:
|
## Simple full example:
|
||||||
|
|
||||||
@@ -84,8 +80,8 @@ locate the graph definitions inside the `div` tags with `class="mermaid"` and re
|
|||||||
B-->C[fa:fa-ban forbidden]
|
B-->C[fa:fa-ban forbidden]
|
||||||
B-->D(fa:fa-spinner);
|
B-->D(fa:fa-spinner);
|
||||||
</pre>
|
</pre>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/mermaid@9.2.0-rc2/dist/mermaid.min.js"></script>
|
<script type="module">
|
||||||
<script>
|
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@9/dist/mermaid.esm.min.mjs';
|
||||||
mermaid.initialize({ startOnLoad: true });
|
mermaid.initialize({ startOnLoad: true });
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
@@ -41,7 +41,9 @@ import { remark } from 'remark';
|
|||||||
// @ts-ignore No typescript declaration file
|
// @ts-ignore No typescript declaration file
|
||||||
import flatmap from 'unist-util-flatmap';
|
import flatmap from 'unist-util-flatmap';
|
||||||
|
|
||||||
const version = JSON.parse(readFileSync('package.json', 'utf8')).version;
|
const version = (
|
||||||
|
JSON.parse(readFileSync('packages/mermaid/package.json', 'utf8')).version as string
|
||||||
|
).split('.')[0];
|
||||||
|
|
||||||
// These paths are from the root of the mono-repo, not from the
|
// These paths are from the root of the mono-repo, not from the
|
||||||
// mermaid sub-directory
|
// mermaid sub-directory
|
||||||
|
@@ -8,7 +8,7 @@ It is a JavaScript based diagramming and charting tool that renders Markdown-ins
|
|||||||
|
|
||||||
<img src="img/header.png" alt="" />
|
<img src="img/header.png" alt="" />
|
||||||
|
|
||||||
[](https://travis-ci.org/mermaid-js/mermaid) [](https://www.npmjs.com/package/mermaid) [](https://coveralls.io/github/mermaid-js/mermaid?branch=master) [](https://www.jsdelivr.com/package/npm/mermaid) [](https://www.npmjs.com/package/mermaid) [](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE)
|
[](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml) [](https://www.npmjs.com/package/mermaid) [](https://coveralls.io/github/mermaid-js/mermaid?branch=master) [](https://www.jsdelivr.com/package/npm/mermaid) [](https://www.npmjs.com/package/mermaid) [](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE)
|
||||||
|
|
||||||
<!-- Mermaid book banner -->
|
<!-- Mermaid book banner -->
|
||||||
|
|
||||||
@@ -187,11 +187,11 @@ To Deploy Mermaid:
|
|||||||
|
|
||||||
### [Mermaid API](./Setup.md):
|
### [Mermaid API](./Setup.md):
|
||||||
|
|
||||||
**To deploy mermaid without a bundler, one can insert a `script` tag with an absolute address and a `mermaidAPI` call into the HTML like so:**
|
**To deploy mermaid without a bundler, one can insert a `script` tag with an absolute address and a `mermaid.initialize` call into the HTML like so:**
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<script src="https://cdn.jsdelivr.net/npm/mermaid@<MERMAID_VERSION>/dist/mermaid.min.js"></script>
|
<script type="module">
|
||||||
<script>
|
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@<MERMAID_VERSION>/dist/mermaid.esm.min.mjs';
|
||||||
mermaid.initialize({ startOnLoad: true });
|
mermaid.initialize({ startOnLoad: true });
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
@@ -21,8 +21,6 @@
|
|||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/all.min.css"
|
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/all.min.css"
|
||||||
/>
|
/>
|
||||||
<script src="//cdn.jsdelivr.net/npm/mermaid@9.1.7/dist/mermaid.min.js"></script>
|
|
||||||
<!-- <script src="http://localhost:9000/mermaid.js"></script> -->
|
|
||||||
<script
|
<script
|
||||||
defer
|
defer
|
||||||
data-domain="mermaid-js.github.io"
|
data-domain="mermaid-js.github.io"
|
||||||
@@ -50,6 +48,10 @@
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
<script type="module">
|
||||||
|
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.esm.min.mjs';
|
||||||
|
window.mermaid = mermaid;
|
||||||
|
</script>
|
||||||
<script>
|
<script>
|
||||||
var initEditor = exports.default;
|
var initEditor = exports.default;
|
||||||
var parser = new DOMParser();
|
var parser = new DOMParser();
|
||||||
@@ -99,6 +101,7 @@
|
|||||||
colorize.push(currentCodeExample);
|
colorize.push(currentCodeExample);
|
||||||
return '<pre id="code' + currentCodeExample + '">' + escapeHTML(code) + '</pre>';
|
return '<pre id="code' + currentCodeExample + '">' + escapeHTML(code) + '</pre>';
|
||||||
} else if (lang === 'mermaid') {
|
} else if (lang === 'mermaid') {
|
||||||
|
// TODO: This will need to be updated when render is async.
|
||||||
return (
|
return (
|
||||||
'<pre class="mermaid">' + mermaid.render('mermaid-svg-' + num++, code) + '</pre>'
|
'<pre class="mermaid">' + mermaid.render('mermaid-svg-' + num++, code) + '</pre>'
|
||||||
);
|
);
|
||||||
|
@@ -73,23 +73,13 @@ The API works by pulling rendering instructions from the source `mermaid.js` in
|
|||||||
|
|
||||||
### Requirements for the Mermaid API.
|
### Requirements for the Mermaid API.
|
||||||
|
|
||||||
When writing the .html file, we give three instructions inside the html code to the web browser:
|
When writing the .html file, we give two instructions inside the html code to the web browser:
|
||||||
|
|
||||||
a. A reference for fetching the online mermaid renderer, through the `mermaid.js` or `mermaid.min.js`.
|
a. The mermaid code for the diagram we want to create.
|
||||||
|
|
||||||
b. The mermaid code for the diagram we want to create.
|
b. The importing of mermaid library through the `mermaid.esm.js` or `mermaid.esm.min.mjs` and the `mermaid.initialize()` call, which dictates the appearance of diagrams and also starts the rendering process .
|
||||||
|
|
||||||
c. The `mermaid.initialize()` call, which dictates the appearance of diagrams and also starts the rendering process .
|
**a. The embedded mermaid diagram definition inside a `<pre class="mermaid">`:**
|
||||||
|
|
||||||
**a. A reference to the external CDN in a `<script src>` tag, or a reference to mermaid.js as a separate file.:**
|
|
||||||
|
|
||||||
```html
|
|
||||||
<body>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/mermaid@<MERMAID_VERSION>/dist/mermaid.min.js"></script>
|
|
||||||
</body>
|
|
||||||
```
|
|
||||||
|
|
||||||
**b. The embedded mermaid diagram definition inside a `<pre class="mermaid">`:**
|
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<body>
|
<body>
|
||||||
@@ -105,13 +95,14 @@ c. The `mermaid.initialize()` call, which dictates the appearance of diagrams an
|
|||||||
|
|
||||||
**Notes**: Every Mermaid chart/graph/diagram definition, should have separate `<pre>` tags.
|
**Notes**: Every Mermaid chart/graph/diagram definition, should have separate `<pre>` tags.
|
||||||
|
|
||||||
**c. The `mermaid.initialize()` call.**
|
**b. The import of mermaid and the `mermaid.initialize()` call.**
|
||||||
|
|
||||||
`mermaid.initialize()` call takes all the definitions contained in all the `<pre class="mermaid">` tags that it finds in the html body and renders them into diagrams. Example:
|
`mermaid.initialize()` call takes all the definitions contained in all the `<pre class="mermaid">` tags that it finds in the html body and renders them into diagrams. Example:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<body>
|
<body>
|
||||||
<script>
|
<script type="module">
|
||||||
|
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@<MERMAID_VERSION>/dist/mermaid.esm.min.mjs';
|
||||||
mermaid.initialize({ startOnLoad: true });
|
mermaid.initialize({ startOnLoad: true });
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
@@ -133,11 +124,6 @@ Rendering in Mermaid is initialized by `mermaid.initialize()` call. You can plac
|
|||||||
```html
|
```html
|
||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/mermaid@<MERMAID_VERSION>/dist/mermaid.min.js"></script>
|
|
||||||
<script>
|
|
||||||
mermaid.initialize({ startOnLoad: true });
|
|
||||||
</script>
|
|
||||||
|
|
||||||
Here is one mermaid diagram:
|
Here is one mermaid diagram:
|
||||||
<pre class="mermaid">
|
<pre class="mermaid">
|
||||||
graph TD
|
graph TD
|
||||||
@@ -154,6 +140,11 @@ Rendering in Mermaid is initialized by `mermaid.initialize()` call. You can plac
|
|||||||
B -->|tcp_456| C[Server1]
|
B -->|tcp_456| C[Server1]
|
||||||
B -->|tcp_456| D[Server2]
|
B -->|tcp_456| D[Server2]
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
<script type="module">
|
||||||
|
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@<MERMAID_VERSION>/dist/mermaid.esm.min.mjs';
|
||||||
|
mermaid.initialize({ startOnLoad: true });
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
```
|
```
|
||||||
@@ -179,8 +170,8 @@ In this example mermaid.js is referenced in `src` as a separate JavaScript file,
|
|||||||
B --> C[Server1]
|
B --> C[Server1]
|
||||||
B --> D[Server2]
|
B --> D[Server2]
|
||||||
</pre>
|
</pre>
|
||||||
<script src="The\Path\In\Your\Package\mermaid.js"></script>
|
<script type="module">
|
||||||
<script>
|
import mermaid from 'The/Path/In/Your/Package/mermaid.ems.mjs';
|
||||||
mermaid.initialize({ startOnLoad: true });
|
mermaid.initialize({ startOnLoad: true });
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
@@ -204,4 +195,4 @@ In this example mermaid.js is referenced in `src` as a separate JavaScript file,
|
|||||||
|
|
||||||
**Comments from Knut Sveidqvist, creator of mermaid:**
|
**Comments from Knut Sveidqvist, creator of mermaid:**
|
||||||
|
|
||||||
- In early versions of mermaid, the `<script src>` tag was invoked in the `<head>` part of the web page. Nowadays we can place it in the `<body>` as seen above. Older parts of the documentation frequently reflects the previous way which still works.
|
- In early versions of mermaid, the `<script>` tag was invoked in the `<head>` part of the web page. Nowadays we can place it in the `<body>` as seen above. Older parts of the documentation frequently reflects the previous way which still works.
|
||||||
|
@@ -39,23 +39,9 @@ We have compiled some Video [Tutorials](./Tutorials.md) on how to use the mermai
|
|||||||
|
|
||||||
> Note:This topic explored in greater depth in the [User Guide for Beginners](./n00b-gettingStarted.md)
|
> Note:This topic explored in greater depth in the [User Guide for Beginners](./n00b-gettingStarted.md)
|
||||||
|
|
||||||
The easiest way to integrate mermaid on a web page requires three elements:
|
The easiest way to integrate mermaid on a web page requires two elements:
|
||||||
|
|
||||||
1. Inclusion of the mermaid address in the html page using a `script` tag, in the `src` section.Example:
|
- A graph definition, inside `<pre>` tags labeled `class=mermaid`. Example:
|
||||||
|
|
||||||
```html
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/mermaid@<MERMAID_VERSION>/dist/mermaid.min.js"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
2. The `mermaidAPI` call, in a separate `script` tag. Example:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<script>
|
|
||||||
mermaid.initialize({ startOnLoad: true });
|
|
||||||
</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
3. A graph definition, inside `<div>` tags labeled `class=mermaid`. Example:
|
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<pre class="mermaid">
|
<pre class="mermaid">
|
||||||
@@ -66,8 +52,18 @@ The easiest way to integrate mermaid on a web page requires three elements:
|
|||||||
</pre>
|
</pre>
|
||||||
```
|
```
|
||||||
|
|
||||||
**Following these directions, mermaid starts at page load and (when the page has loaded) it will
|
- Inclusion of the mermaid address in the html page body using a `script` tag as an ESM import, and the `mermaidAPI` call.
|
||||||
locate the graph definitions inside the `div` tags with `class="mermaid"` and return diagrams in SVG form, following given definitions.**
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@<MERMAID_VERSION>/dist/mermaid.esm.min.mjs';
|
||||||
|
mermaid.initialize({ startOnLoad: true });
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
**Following these directions, mermaid starts at page load and (when the page has loaded) it will locate the graph definitions inside the `pre` tags with `class="mermaid"` and return diagrams in SVG form, following given definitions.**
|
||||||
|
|
||||||
## Simple full example:
|
## Simple full example:
|
||||||
|
|
||||||
@@ -84,8 +80,8 @@ locate the graph definitions inside the `div` tags with `class="mermaid"` and re
|
|||||||
B-->C[fa:fa-ban forbidden]
|
B-->C[fa:fa-ban forbidden]
|
||||||
B-->D(fa:fa-spinner);
|
B-->D(fa:fa-spinner);
|
||||||
</pre>
|
</pre>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/mermaid@<MERMAID_VERSION>/dist/mermaid.min.js"></script>
|
<script type="module">
|
||||||
<script>
|
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@<MERMAID_VERSION>/dist/mermaid.esm.min.mjs';
|
||||||
mermaid.initialize({ startOnLoad: true });
|
mermaid.initialize({ startOnLoad: true });
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
@@ -39,23 +39,9 @@ We have compiled some Video [Tutorials](./Tutorials.md) on how to use the mermai
|
|||||||
|
|
||||||
> Note:This topic explored in greater depth in the [User Guide for Beginners](../intro/n00b-gettingStarted.md)
|
> Note:This topic explored in greater depth in the [User Guide for Beginners](../intro/n00b-gettingStarted.md)
|
||||||
|
|
||||||
The easiest way to integrate mermaid on a web page requires three elements:
|
The easiest way to integrate mermaid on a web page requires two elements:
|
||||||
|
|
||||||
1. Inclusion of the mermaid address in the html page using a `script` tag, in the `src` section.Example:
|
- A graph definition, inside `<pre>` tags labeled `class=mermaid`. Example:
|
||||||
|
|
||||||
```html
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/mermaid@<MERMAID_VERSION>/dist/mermaid.min.js"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
2. The `mermaidAPI` call, in a separate `script` tag. Example:
|
|
||||||
|
|
||||||
```html
|
|
||||||
<script>
|
|
||||||
mermaid.initialize({ startOnLoad: true });
|
|
||||||
</script>
|
|
||||||
```
|
|
||||||
|
|
||||||
3. A graph definition, inside `<div>` tags labeled `class=mermaid`. Example:
|
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<pre class="mermaid">
|
<pre class="mermaid">
|
||||||
@@ -66,8 +52,18 @@ The easiest way to integrate mermaid on a web page requires three elements:
|
|||||||
</pre>
|
</pre>
|
||||||
```
|
```
|
||||||
|
|
||||||
**Following these directions, mermaid starts at page load and (when the page has loaded) it will
|
- Inclusion of the mermaid address in the html page body using a `script` tag as an ESM import, and the `mermaidAPI` call.
|
||||||
locate the graph definitions inside the `div` tags with `class="mermaid"` and return diagrams in SVG form, following given definitions.**
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script type="module">
|
||||||
|
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@<MERMAID_VERSION>/dist/mermaid.esm.min.mjs';
|
||||||
|
mermaid.initialize({ startOnLoad: true });
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
**Following these directions, mermaid starts at page load and (when the page has loaded) it will locate the graph definitions inside the `pre` tags with `class="mermaid"` and return diagrams in SVG form, following given definitions.**
|
||||||
|
|
||||||
## Simple full example:
|
## Simple full example:
|
||||||
|
|
||||||
@@ -84,8 +80,8 @@ locate the graph definitions inside the `div` tags with `class="mermaid"` and re
|
|||||||
B-->C[fa:fa-ban forbidden]
|
B-->C[fa:fa-ban forbidden]
|
||||||
B-->D(fa:fa-spinner);
|
B-->D(fa:fa-spinner);
|
||||||
</pre>
|
</pre>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/mermaid@<MERMAID_VERSION>/dist/mermaid.min.js"></script>
|
<script type="module">
|
||||||
<script>
|
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@<MERMAID_VERSION>/dist/mermaid.esm.min.mjs';
|
||||||
mermaid.initialize({ startOnLoad: true });
|
mermaid.initialize({ startOnLoad: true });
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
@@ -8,7 +8,7 @@ It is a JavaScript based diagramming and charting tool that renders Markdown-ins
|
|||||||
|
|
||||||
<img src="/header.png" alt="" />
|
<img src="/header.png" alt="" />
|
||||||
|
|
||||||
[](https://travis-ci.org/mermaid-js/mermaid) [](https://www.npmjs.com/package/mermaid) [](https://coveralls.io/github/mermaid-js/mermaid?branch=master) [](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE)
|
[](https://github.com/mermaid-js/mermaid/actions/workflows/build.yml) [](https://www.npmjs.com/package/mermaid) [](https://coveralls.io/github/mermaid-js/mermaid?branch=master) [](https://www.jsdelivr.com/package/npm/mermaid) [](https://www.npmjs.com/package/mermaid) [](https://join.slack.com/t/mermaid-talk/shared_invite/enQtNzc4NDIyNzk4OTAyLWVhYjQxOTI2OTg4YmE1ZmJkY2Y4MTU3ODliYmIwOTY3NDJlYjA0YjIyZTdkMDMyZTUwOGI0NjEzYmEwODcwOTE)
|
||||||
|
|
||||||
<!-- Mermaid book banner -->
|
<!-- Mermaid book banner -->
|
||||||
|
|
||||||
@@ -262,16 +262,16 @@ To Deploy Mermaid:
|
|||||||
|
|
||||||
### [Mermaid API](../config/Setup.md):
|
### [Mermaid API](../config/Setup.md):
|
||||||
|
|
||||||
**To deploy mermaid without a bundler, one can insert a `script` tag with an absolute address and a `mermaidAPI` call into the HTML like so:**
|
**To deploy mermaid without a bundler, one can insert a `script` tag with an absolute address and a `mermaid.initialize` call into the HTML like so:**
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<script src="https://cdn.jsdelivr.net/npm/mermaid@<MERMAID_VERSION>/dist/mermaid.min.js"></script>
|
<script type="module">
|
||||||
<script>
|
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@<MERMAID_VERSION>/dist/mermaid.esm.min.mjs';
|
||||||
mermaid.initialize({ startOnLoad: true });
|
mermaid.initialize({ startOnLoad: true });
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
**Doing so will command the mermaid parser to look for the `<div>` tags with `class="mermaid"`. From these tags mermaid will try to read the diagram/chart definitions and render them into SVG charts.**
|
**Doing so will command the mermaid parser to look for the `<div>` or `<pre>` tags with `class="mermaid"`. From these tags mermaid will try to read the diagram/chart definitions and render them into SVG charts.**
|
||||||
|
|
||||||
**Examples can be found at** [Other examples](../syntax/examples)
|
**Examples can be found at** [Other examples](../syntax/examples)
|
||||||
|
|
||||||
|
@@ -82,23 +82,13 @@ The API works by pulling rendering instructions from the source `mermaid.js` in
|
|||||||
|
|
||||||
### Requirements for the Mermaid API.
|
### Requirements for the Mermaid API.
|
||||||
|
|
||||||
When writing the .html file, we give three instructions inside the html code to the web browser:
|
When writing the .html file, we give two instructions inside the html code to the web browser:
|
||||||
|
|
||||||
a. A reference for fetching the online mermaid renderer, through the `mermaid.js` or `mermaid.min.js`.
|
a. The mermaid code for the diagram we want to create.
|
||||||
|
|
||||||
b. The mermaid code for the diagram we want to create.
|
b. The importing of mermaid library through the `mermaid.esm.js` or `mermaid.esm.min.mjs` and the `mermaid.initialize()` call, which dictates the appearance of diagrams and also starts the rendering process .
|
||||||
|
|
||||||
c. The `mermaid.initialize()` call, which dictates the appearance of diagrams and also starts the rendering process .
|
**a. The embedded mermaid diagram definition inside a `<pre class="mermaid">`:**
|
||||||
|
|
||||||
**a. A reference to the external CDN in a `<script src>` tag, or a reference to mermaid.js as a separate file.:**
|
|
||||||
|
|
||||||
```html
|
|
||||||
<body>
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/mermaid@<MERMAID_VERSION>/dist/mermaid.min.js"></script>
|
|
||||||
</body>
|
|
||||||
```
|
|
||||||
|
|
||||||
**b. The embedded mermaid diagram definition inside a `<pre class="mermaid">`:**
|
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<body>
|
<body>
|
||||||
@@ -114,13 +104,14 @@ c. The `mermaid.initialize()` call, which dictates the appearance of diagrams an
|
|||||||
|
|
||||||
**Notes**: Every Mermaid chart/graph/diagram definition, should have separate `<pre>` tags.
|
**Notes**: Every Mermaid chart/graph/diagram definition, should have separate `<pre>` tags.
|
||||||
|
|
||||||
**c. The `mermaid.initialize()` call.**
|
**b. The import of mermaid and the `mermaid.initialize()` call.**
|
||||||
|
|
||||||
`mermaid.initialize()` call takes all the definitions contained in all the `<pre class="mermaid">` tags that it finds in the html body and renders them into diagrams. Example:
|
`mermaid.initialize()` call takes all the definitions contained in all the `<pre class="mermaid">` tags that it finds in the html body and renders them into diagrams. Example:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<body>
|
<body>
|
||||||
<script>
|
<script type="module">
|
||||||
|
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@<MERMAID_VERSION>/dist/mermaid.esm.min.mjs';
|
||||||
mermaid.initialize({ startOnLoad: true });
|
mermaid.initialize({ startOnLoad: true });
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
@@ -142,11 +133,6 @@ Rendering in Mermaid is initialized by `mermaid.initialize()` call. You can plac
|
|||||||
```html
|
```html
|
||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/mermaid@<MERMAID_VERSION>/dist/mermaid.min.js"></script>
|
|
||||||
<script>
|
|
||||||
mermaid.initialize({ startOnLoad: true });
|
|
||||||
</script>
|
|
||||||
|
|
||||||
Here is one mermaid diagram:
|
Here is one mermaid diagram:
|
||||||
<pre class="mermaid">
|
<pre class="mermaid">
|
||||||
graph TD
|
graph TD
|
||||||
@@ -163,6 +149,11 @@ Rendering in Mermaid is initialized by `mermaid.initialize()` call. You can plac
|
|||||||
B -->|tcp_456| C[Server1]
|
B -->|tcp_456| C[Server1]
|
||||||
B -->|tcp_456| D[Server2]
|
B -->|tcp_456| D[Server2]
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
<script type="module">
|
||||||
|
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@<MERMAID_VERSION>/dist/mermaid.esm.min.mjs';
|
||||||
|
mermaid.initialize({ startOnLoad: true });
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
```
|
```
|
||||||
@@ -188,8 +179,8 @@ In this example mermaid.js is referenced in `src` as a separate JavaScript file,
|
|||||||
B --> C[Server1]
|
B --> C[Server1]
|
||||||
B --> D[Server2]
|
B --> D[Server2]
|
||||||
</pre>
|
</pre>
|
||||||
<script src="The\Path\In\Your\Package\mermaid.js"></script>
|
<script type="module">
|
||||||
<script>
|
import mermaid from 'The/Path/In/Your/Package/mermaid.ems.mjs';
|
||||||
mermaid.initialize({ startOnLoad: true });
|
mermaid.initialize({ startOnLoad: true });
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
@@ -213,4 +204,4 @@ In this example mermaid.js is referenced in `src` as a separate JavaScript file,
|
|||||||
|
|
||||||
**Comments from Knut Sveidqvist, creator of mermaid:**
|
**Comments from Knut Sveidqvist, creator of mermaid:**
|
||||||
|
|
||||||
- In early versions of mermaid, the `<script src>` tag was invoked in the `<head>` part of the web page. Nowadays we can place it in the `<body>` as seen above. Older parts of the documentation frequently reflects the previous way which still works.
|
- In early versions of mermaid, the `<script>` tag was invoked in the `<head>` part of the web page. Nowadays we can place it in the `<body>` as seen above. Older parts of the documentation frequently reflects the previous way which still works.
|
||||||
|
Reference in New Issue
Block a user