Skip to content

Commit 38662dd

Browse files
committed
mermaid dark mode, docs
1 parent 629cf00 commit 38662dd

File tree

3 files changed

+53
-3
lines changed

3 files changed

+53
-3
lines changed

docs/dot.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# DOT
22

3-
[DOT](https://graphviz.org/doc/info/lang.html) is a language for rendering node-link diagrams using [Graphviz](https://graphviz.org). Observable Markdown’s implementation is powered by [Viz.js](https://github.com/mdaines/viz-js).
3+
[DOT](https://graphviz.org/doc/info/lang.html) is a language for expressing node-link diagrams using [Graphviz](https://graphviz.org). Observable Markdown’s implementation is powered by [Viz.js](https://github.com/mdaines/viz-js).
44

55
To use DOT, write a `dot` fenced code block:
66

docs/mermaid.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,58 @@
11
# Mermaid
22

3-
```mermaid show
3+
[Mermaid](https://mermaid.js.org/) is a language for expressing node-link diagrams, flowcharts, sequence diagrams, and many other types of visualizations. (See also [DOT](./dot).)
4+
5+
To use Mermaid, write a `mermaid` fenced code block:
6+
7+
````md
8+
```mermaid
9+
graph TD;
10+
A-->B;
11+
A-->C;
12+
B-->D;
13+
C-->D;
14+
```
15+
````
16+
17+
This produces:
18+
19+
```mermaid
420
graph TD;
521
A-->B;
622
A-->C;
723
B-->D;
824
C-->D;
925
```
26+
27+
Here are some more examples.
28+
29+
```mermaid show
30+
sequenceDiagram
31+
participant Alice
32+
participant Bob
33+
Alice->>John: Hello John, how are you?
34+
loop Healthcheck
35+
John->>John: Fight against hypochondria
36+
end
37+
Note right of John: Rational thoughts <br/>prevail!
38+
John-->>Alice: Great!
39+
John->>Bob: How about you?
40+
Bob-->>John: Jolly good!
41+
```
42+
43+
```mermaid show
44+
classDiagram
45+
Class01 <|-- AveryLongClass : Cool
46+
Class03 *-- Class04
47+
Class05 o-- Class06
48+
Class07 .. Class08
49+
Class09 --> C2 : Where am i?
50+
Class09 --* C3
51+
Class09 --|> Class07
52+
Class07 : equals()
53+
Class07 : Object[] elementData
54+
Class01 : size()
55+
Class01 : int chimp
56+
Class01 : int gorilla
57+
Class08 <--> C2: Cool label
58+
```

public/client.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ async function dot() {
150150
async function mermaid() {
151151
let nextId = 0;
152152
const {default: mer} = await import("https://cdn.jsdelivr.net/npm/mermaid/+esm");
153-
mer.initialize({startOnLoad: false, securityLevel: "loose", theme: "neutral"});
153+
const theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "neutral";
154+
mer.initialize({startOnLoad: false, securityLevel: "loose", theme});
154155
return async function mermaid() {
155156
const root = document.createElement("div");
156157
root.innerHTML = (await mer.render(`mermaid-${++nextId}`, String.raw.apply(String, arguments))).svg;

0 commit comments

Comments
 (0)