@@ -16,7 +16,7 @@ popular and flexible solution for drawing diagrams.
16
16
<!-- md:version 8.2.0 -->
17
17
18
18
This configuration enables native support for [ Mermaid.js] diagrams. Material
19
- for MkDocs will automatically initialize the JavaScript runtime when a page
19
+ for MkDocs will automatically initialize the JavaScript runtime when a page
20
20
includes a ` mermaid ` code block:
21
21
22
22
``` yaml
@@ -38,7 +38,7 @@ No further configuration is necessary. Advantages over a custom integration:
38
38
[^1] :
39
39
While all [Mermaid.js] features should work out-of-the-box, Material for
40
40
MkDocs will currently only adjust the fonts and colors for flowcharts,
41
- sequence diagrams, class diagrams, state diagrams and entity relationship
41
+ sequence diagrams, class diagrams, state diagrams and entity relationship
42
42
diagrams. See the section on [other diagrams] for more information why this
43
43
is currently not implemented for all diagrams.
44
44
@@ -82,7 +82,7 @@ graph LR
82
82
83
83
# ## Using sequence diagrams
84
84
85
- [Sequence diagrams] describe a specific scenario as sequential interactions
85
+ [Sequence diagrams] describe a specific scenario as sequential interactions
86
86
between multiple objects or actors, including the messages that are exchanged
87
87
between those actors :
88
88
@@ -194,7 +194,7 @@ classDiagram
194
194
+int postalCode
195
195
+String country
196
196
-validate()
197
- +outputAsLabel()
197
+ +outputAsLabel()
198
198
}
199
199
` ` `
200
200
````
@@ -226,7 +226,7 @@ classDiagram
226
226
+int postalCode
227
227
+String country
228
228
-validate()
229
- +outputAsLabel()
229
+ +outputAsLabel()
230
230
}
231
231
` ` `
232
232
@@ -283,3 +283,34 @@ we don't consider them a good choice, mostly as they don't work well on mobile.
283
283
[user journeys] : https://mermaid.js.org/syntax/userJourney.html
284
284
[git graphs] : https://mermaid.js.org/syntax/gitgraph.html
285
285
[requirement diagrams] : https://mermaid.js.org/syntax/requirementDiagram.html
286
+
287
+ # # Customization
288
+
289
+ If you want to customize Mermaid.js, e.g. to bring in support for [ELK layouts],
290
+ you can do so by adding a custom JavaScript file to your `mkdocs.yml` :
291
+
292
+ === ":octicons-file-code-16 : ` docs/javascripts/mermaid.mjs` "
293
+
294
+ ``` js
295
+ import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs';
296
+ import elkLayouts from 'https://cdn.jsdelivr.net/npm/@mermaid-js/layout-elk@0/dist/mermaid-layout-elk.esm.min.mjs';
297
+
298
+ mermaid.registerLayoutLoaders(elkLayouts);
299
+ mermaid.initialize({
300
+ startOnLoad: false,
301
+ securityLevel: " loose",
302
+ layout : " elk" ,
303
+ });
304
+
305
+ // Important : necessary to make it visible to Material for MkDocs
306
+ window.mermaid = mermaid;
307
+ ```
308
+
309
+ === ":octicons-file-code-16 : ` mkdocs.yml` "
310
+
311
+ ``` yaml
312
+ extra_javascript:
313
+ - javascripts/mermaid.mjs
314
+ ```
315
+
316
+ [ELK layouts]: https://www.npmjs.com/package/@mermaid-js/layout-elk
0 commit comments