prettier-plugin-mmd 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +73 -156
- package/README.md +85 -144
- package/lib/index.d.mts +6 -2
- package/lib/index.mjs +4442 -725
- package/package.json +3 -3
package/README.ja.md
CHANGED
|
@@ -2,22 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
英語版: [README.md](./README.md)
|
|
4
4
|
|
|
5
|
-
Mermaid
|
|
5
|
+
[Mermaid](https://mermaid.js.org/) の図を整形する
|
|
6
|
+
[Prettier](https://prettier.io/) プラグインです。
|
|
6
7
|
`.mmd` と `.mermaid` のファイルと、
|
|
7
8
|
Markdown の中の `mermaid` のコードブロックを整形します。
|
|
8
9
|
|
|
9
|
-
mermaid-js とは関係のない第三者のプロジェクトです。
|
|
10
|
+
[mermaid-js](https://mermaid.js.org/) とは関係のない第三者のプロジェクトです。
|
|
10
11
|
ここでいう `mmd` は Mermaid の図の記法のことで、
|
|
11
12
|
MultiMarkdown や MikuMikuDance ではありません。
|
|
12
13
|
|
|
14
|
+
文書:
|
|
15
|
+
[フォーマッター](https://mmd-toolkit.github.io/mmd-toolkit/ja/formatter/)。
|
|
16
|
+
|
|
13
17
|
## Playground
|
|
14
18
|
|
|
15
19
|
ブラウザーで、このプラグインによる整形結果を確認できます。
|
|
16
|
-
**Formatted
|
|
20
|
+
**Formatted**タブは編集に合わせて更新され、**Print width**で行幅を、
|
|
17
21
|
**Indent**と**Use tabs**で字下げを設定できます。
|
|
18
22
|
**Apply to source**で、入力を整形結果に置き換えられます。
|
|
19
23
|
|
|
20
|
-
|
|
24
|
+
[Playground](https://mmd-toolkit.github.io/mmd-toolkit/playground/)
|
|
25
|
+
を開いて使えます。
|
|
21
26
|
|
|
22
27
|
操作方法は[Playgroundの使い方](../playground/README.ja.md)を参照してください。
|
|
23
28
|
|
|
@@ -50,7 +55,7 @@ npx prettier --write "**/*.{mmd,mermaid,md}"
|
|
|
50
55
|
## 例
|
|
51
56
|
|
|
52
57
|
入力
|
|
53
|
-
([
|
|
58
|
+
([ファイル](./tests/fixtures/flowchart/statements-one-per-line/separated-by-semicolons-input.mmd)):
|
|
54
59
|
|
|
55
60
|
```mmd
|
|
56
61
|
flowchart LR
|
|
@@ -59,7 +64,7 @@ flowchart LR
|
|
|
59
64
|
```
|
|
60
65
|
|
|
61
66
|
出力
|
|
62
|
-
([
|
|
67
|
+
([ファイル](./tests/fixtures/flowchart/statements-one-per-line/separated-by-semicolons-output.mmd)):
|
|
63
68
|
|
|
64
69
|
```mmd
|
|
65
70
|
flowchart LR
|
|
@@ -78,113 +83,47 @@ flowchart LR
|
|
|
78
83
|
- Markdown の、情報文字列の最初の語が `mermaid` か `mmd` のコードブロック。
|
|
79
84
|
大文字と小文字を区別するので、`Mermaid` は整形しません。
|
|
80
85
|
`mermaidx` も整形しません。
|
|
81
|
-
-
|
|
82
|
-
`flowchart`、`graph`、`flowchart-elk`、`swimlane-beta` で始まる図です。
|
|
83
|
-
整形の規則は、
|
|
84
|
-
例とともに [docs/flowchart.ja.md](./docs/flowchart.ja.md) にあります。
|
|
85
|
-
- agentflow。
|
|
86
|
-
`agentflow-beta`で始まる図です。
|
|
87
|
-
整形規則と例は[docs/agentflow.ja.md](./docs/agentflow.ja.md)にあります。
|
|
88
|
-
- sequence 図。
|
|
89
|
-
`sequenceDiagram` で始まる図です。
|
|
90
|
-
整形の規則は、
|
|
91
|
-
例とともに [docs/sequence.ja.md](./docs/sequence.ja.md) にあります。
|
|
92
|
-
- class 図。
|
|
93
|
-
`classDiagram` か `classDiagram-v2` で始まる図です。
|
|
94
|
-
整形の規則は、例とともに [docs/class.ja.md](./docs/class.ja.md) にあります。
|
|
95
|
-
- state 図。
|
|
96
|
-
`stateDiagram` か `stateDiagram-v2` で始まる図です。
|
|
97
|
-
整形の規則は、例とともに [docs/state.ja.md](./docs/state.ja.md) にあります。
|
|
98
|
-
- ER 図。
|
|
99
|
-
`erDiagram` で始まる図です。
|
|
100
|
-
整形の規則は、例とともに [docs/er.ja.md](./docs/er.ja.md) にあります。
|
|
101
|
-
- Gantt 図。
|
|
102
|
-
`gantt` で始まる図です。
|
|
103
|
-
整形の規則は、例とともに [docs/gantt.ja.md](./docs/gantt.ja.md) にあります。
|
|
104
|
-
- journey 図。
|
|
105
|
-
`journey` で始まる図です。
|
|
106
|
-
整形の規則は、
|
|
107
|
-
例とともに [docs/journey.ja.md](./docs/journey.ja.md) にあります。
|
|
108
|
-
- requirement 図。
|
|
109
|
-
`requirementDiagram` で始まる図です。
|
|
110
|
-
整形の規則は、
|
|
111
|
-
例とともに [docs/requirement.ja.md](./docs/requirement.ja.md) にあります。
|
|
112
|
-
- mindmap。
|
|
113
|
-
`mindmap` で始まる図です。
|
|
114
|
-
整形の規則は、
|
|
115
|
-
例とともに [docs/mindmap.ja.md](./docs/mindmap.ja.md) にあります。
|
|
116
|
-
- timeline。
|
|
117
|
-
`timeline` で始まる図です。
|
|
118
|
-
整形の規則は、
|
|
119
|
-
例とともに [docs/timeline.ja.md](./docs/timeline.ja.md) にあります。
|
|
120
|
-
- sankey 図。
|
|
121
|
-
`sankey` か `sankey-beta` で始まる図です。
|
|
122
|
-
整形の規則は、例とともに [docs/sankey.ja.md](./docs/sankey.ja.md) にあります。
|
|
123
|
-
- XY チャート。
|
|
124
|
-
`xychart` か `xychart-beta` で始まる図です。
|
|
125
|
-
整形の規則は、
|
|
126
|
-
例とともに [docs/xychart.ja.md](./docs/xychart.ja.md) にあります。
|
|
127
|
-
- 象限チャート。
|
|
128
|
-
`quadrantChart` で始まる図です。
|
|
129
|
-
整形の規則は、
|
|
130
|
-
例とともに [docs/quadrant.ja.md](./docs/quadrant.ja.md) にあります。
|
|
131
|
-
- kanban。
|
|
132
|
-
`kanban` で始まる図です。
|
|
133
|
-
整形の規則は、例とともに [docs/kanban.ja.md](./docs/kanban.ja.md) にあります。
|
|
134
|
-
- C4 図。
|
|
135
|
-
`C4Context`、`C4Container`、`C4Component`、`C4Dynamic`、
|
|
136
|
-
`C4Deployment` で始まる図です。
|
|
137
|
-
整形の規則は、例とともに [docs/c4.ja.md](./docs/c4.ja.md) にあります。
|
|
138
|
-
- Venn 図。
|
|
139
|
-
`venn-beta` で始まる図です。
|
|
140
|
-
整形の規則は、例とともに [docs/venn.ja.md](./docs/venn.ja.md) にあります。
|
|
141
|
-
- Ishikawa 図。
|
|
142
|
-
`ishikawa` と `ishikawa-beta` で始まる図で、
|
|
143
|
-
受理する大文字小文字の表記も扱います。
|
|
144
|
-
整形の規則は [docs/ishikawa.ja.md](./docs/ishikawa.ja.md) にあります。
|
|
145
|
-
- Usecase 図。
|
|
146
|
-
`usecase-beta` で始まる図です。
|
|
147
|
-
整形の規則は [docs/usecase.ja.md](./docs/usecase.ja.md) にあります。
|
|
148
|
-
- Pie 図。
|
|
149
|
-
`pie` で始まる図で、`showData` も扱います。
|
|
150
|
-
整形の規則は [docs/pie.ja.md](./docs/pie.ja.md) にあります。
|
|
151
|
-
- Info 図。
|
|
152
|
-
`info` で始まる図で、`showInfo` も扱います。
|
|
153
|
-
整形の規則は [docs/info.ja.md](./docs/info.ja.md) にあります。
|
|
154
|
-
- Git graph。
|
|
155
|
-
`gitGraph` で始まる図です。
|
|
156
|
-
整形の規則は [docs/gitgraph.ja.md](./docs/gitgraph.ja.md) にあります。
|
|
157
|
-
- architecture 図: `architecture-beta` で始まる図です。
|
|
158
|
-
整形の規則は [docs/architecture.ja.md](./docs/architecture.ja.md) にあります。
|
|
159
|
-
- treemap 図: `treemap` と `treemap-beta` で始まる図です。
|
|
160
|
-
整形の規則は [docs/treemap.ja.md](./docs/treemap.ja.md) にあります。
|
|
161
|
-
- treeview 図: `treeView-beta` で始まる図です。
|
|
162
|
-
整形の規則は [docs/treeview.ja.md](./docs/treeview.ja.md) にあります。
|
|
163
|
-
- radar 図: `radar-beta` で始まる図です。
|
|
164
|
-
整形の規則は [docs/radar.ja.md](./docs/radar.ja.md) にあります。
|
|
165
|
-
- Wardley 図: `wardley-beta` で始まる図です。
|
|
166
|
-
整形の規則は [docs/wardley.ja.md](./docs/wardley.ja.md) にあります。
|
|
167
|
-
- railroad 図: `railroad-beta`、`railroad-ebnf-beta`、 `railroad-abnf-beta`、
|
|
168
|
-
`railroad-peg-beta` で始まる図です。
|
|
169
|
-
整形の規則は [docs/railroad.ja.md](./docs/railroad.ja.md) にあります。
|
|
170
|
-
- cynefin 図: `cynefin-beta` と `cynefin-beta:` で始まる図です。
|
|
171
|
-
整形の規則は [docs/cynefin.ja.md](./docs/cynefin.ja.md) にあります。
|
|
172
|
-
- eventmodeling 図: `eventmodeling` で始まる図です。
|
|
173
|
-
規則は [docs/eventmodeling.ja.md](./docs/eventmodeling.ja.md) にあります。
|
|
174
|
-
- packet 図: `packet` と `packet-beta` で始まる図です。
|
|
175
|
-
整形の規則は [docs/packet.ja.md](./docs/packet.ja.md) にあります。
|
|
176
|
-
- ブロック図。
|
|
177
|
-
`block-beta` か `block` で始まる図です。
|
|
178
|
-
整形の規則は、例とともに [docs/block.ja.md](./docs/block.ja.md) にあります。
|
|
86
|
+
- mermaid.js のすべての図種。
|
|
179
87
|
- これらの図の YAML のフロントマター。
|
|
180
88
|
Prettier の YAML 整形で整形します。
|
|
181
89
|
|
|
90
|
+
図種ごとの整形の規則は、それぞれの文書にあります。
|
|
91
|
+
[flowchart](./docs/flowchart.ja.md)、[agentflow](./docs/agentflow.ja.md)、
|
|
92
|
+
[sequence](./docs/sequence.ja.md)、[class](./docs/class.ja.md)、
|
|
93
|
+
[state](./docs/state.ja.md)、[ER](./docs/er.ja.md)、
|
|
94
|
+
[Gantt](./docs/gantt.ja.md)、[journey](./docs/journey.ja.md)、
|
|
95
|
+
[requirement](./docs/requirement.ja.md)、[mindmap](./docs/mindmap.ja.md)、
|
|
96
|
+
[timeline](./docs/timeline.ja.md)、[sankey](./docs/sankey.ja.md)、
|
|
97
|
+
[xychart](./docs/xychart.ja.md)、[quadrant](./docs/quadrant.ja.md)、
|
|
98
|
+
[kanban](./docs/kanban.ja.md)、[C4](./docs/c4.ja.md)、
|
|
99
|
+
[Venn](./docs/venn.ja.md)、[Ishikawa](./docs/ishikawa.ja.md)、
|
|
100
|
+
[usecase](./docs/usecase.ja.md)、[pie](./docs/pie.ja.md)、
|
|
101
|
+
[info](./docs/info.ja.md)、[gitGraph](./docs/gitgraph.ja.md)、
|
|
102
|
+
[architecture](./docs/architecture.ja.md)、[treemap](./docs/treemap.ja.md)、
|
|
103
|
+
[treeview](./docs/treeview.ja.md)、[radar](./docs/radar.ja.md)、
|
|
104
|
+
[Wardley](./docs/wardley.ja.md)、[railroad](./docs/railroad.ja.md)、
|
|
105
|
+
[cynefin](./docs/cynefin.ja.md)、[eventmodeling](./docs/eventmodeling.ja.md)、
|
|
106
|
+
[packet](./docs/packet.ja.md)、[block](./docs/block.ja.md)。
|
|
107
|
+
|
|
182
108
|
## オプション
|
|
183
109
|
|
|
184
110
|
- `useTabs` と `tabWidth` で字下げを決めます。
|
|
185
111
|
既定は空白 2 つです。
|
|
186
112
|
- `endOfLine` で改行コードを決めます。
|
|
187
|
-
- `printWidth`
|
|
113
|
+
- `printWidth` は 2 つのことを決めます。
|
|
114
|
+
flowchart、agentflow、kanban で 1 行に書いたデータブロック `@{ … }` は、
|
|
115
|
+
その行が `printWidth` より広く、条件を満たすときに、複数行で印字します。
|
|
116
|
+
たとえば、項目が 1 つのブロックは 1 行のままです。
|
|
117
|
+
条件は、
|
|
118
|
+
[データブロック](./docs/flowchart.ja.md#データブロック)を参照してください。
|
|
119
|
+
Gantt のセクションのタスクの `:` は、行が `printWidth` より広くなり、
|
|
120
|
+
しかも今より広くなるときを除いて、そろえます。
|
|
121
|
+
詳しくは、
|
|
122
|
+
[タスクのデータ](./docs/gantt.ja.md#タスクのデータ)を参照してください。
|
|
123
|
+
幅は Prettier が測る幅で、全角文字は 2 桁、タブは 0 桁と数えます。
|
|
124
|
+
Gantt のセクションは、Markdown のリストや引用が行の前に置くものを数えず、
|
|
125
|
+
行だけの幅で数えます。
|
|
126
|
+
それ以外では、`printWidth` は図の改行位置を決めません。
|
|
188
127
|
`railroad-beta` の呼び出しは文法の構造に従います。
|
|
189
128
|
詳細は[長い行](./docs/railroad.ja.md#長い行)を参照してください。
|
|
190
129
|
Markdown と YAML frontmatter には、Prettier が使う場合があります。
|
|
@@ -203,38 +142,45 @@ flowchart LR
|
|
|
203
142
|
flowchart では、`click` は予約語です。
|
|
204
143
|
`A-->|x""|B` のように、トークンの間に空の文字列がある場合もそうです。
|
|
205
144
|
一覧は [docs/compatibility.ja.md](./docs/compatibility.ja.md) にあります。
|
|
206
|
-
-
|
|
207
|
-
|
|
208
|
-
|
|
145
|
+
- `error` という語と、
|
|
146
|
+
その周りのコメント・ディレクティブ・改行だけでできたテキストは変えません。
|
|
147
|
+
mermaid.js はこれを `error` 擬似図として読みます。
|
|
209
148
|
ただし、改行コードは `endOfLine` に従います。
|
|
210
149
|
Markdown では、Prettier に任せます。
|
|
211
150
|
|
|
212
151
|
## 保証と制限
|
|
213
152
|
|
|
214
153
|
- 次に記す空白の変更を除き、mermaid.js の読み取りを保ちます。
|
|
154
|
+
- 基準は、仕様に記録した版の mermaid.js で、現在は 12.3.0 です。
|
|
155
|
+
フォーマッターは、トークンの綴り(キーワードの大文字小文字など)を変えるとき、
|
|
156
|
+
mermaid.js の履歴(変更履歴と、過去の版の文法)から、
|
|
157
|
+
古い版が変えた後の綴りを読まないか、別に読むと分かる場合は、
|
|
158
|
+
書かれたまま残します。
|
|
159
|
+
それ以外の整形は、12.3.0 だけで確かめています。
|
|
160
|
+
綴りの種類ごとに何を読んだかは、
|
|
161
|
+
[mermaid.js の版](./docs/compatibility.ja.md#mermaidjs-の版)に挙げています。
|
|
162
|
+
- 整形した図をもう一度整形しても、何も変わりません。
|
|
215
163
|
- `style`、`classDef`、`linkStyle` の行の末尾の空白を取り除きます。
|
|
216
164
|
mermaid.js は、その空白を最後のスタイルの末尾に残します。
|
|
217
|
-
- `eventmodeling`
|
|
218
|
-
[Data blocks](./docs/eventmodeling.ja.md#data-blocks)
|
|
219
|
-
|
|
220
|
-
|
|
165
|
+
- `eventmodeling` のデータとノートのブロックの中の行は、
|
|
166
|
+
[Data blocks](./docs/eventmodeling.ja.md#data-blocks)
|
|
167
|
+
の規則が許す場合に揃えます。
|
|
168
|
+
mermaid.js が持つテキストの空白が変わることがありますが、描画は変わりません。
|
|
221
169
|
- `end note` で閉じる state ノートの単一の段落は、
|
|
222
|
-
[ノート](./docs/state.ja.md#ノート)
|
|
170
|
+
[ノート](./docs/state.ja.md#ノート)の規則が許す場合に揃えます。
|
|
223
171
|
行内の強調やコードの表記を含む行も対象です。
|
|
224
|
-
|
|
225
|
-
`notes[].text` の行頭の ASCII 空白だけが変わる場合があります。
|
|
172
|
+
変わるのは行頭の空白だけで、描画は変わりません。
|
|
226
173
|
余白が表示に影響するほかの本文は、後続の余白を原文のまま保ちます。
|
|
227
|
-
-
|
|
228
|
-
- ディレクティブ、不透明な `@{ ... }` のデータブロック、
|
|
174
|
+
- ディレクティブ、`@{ ... }` のデータブロック、
|
|
229
175
|
フロントマターの中身は検査しません。
|
|
230
176
|
その中身のために mermaid.js が拒否する図も整形します。
|
|
231
177
|
ディレクティブは書かれたまま残します。
|
|
232
|
-
|
|
178
|
+
`@{ ... }` のデータブロックも中身を残し、1 行のブロックは、
|
|
233
179
|
両端の内側に空白を 1 つずつ置いて印字します。
|
|
234
180
|
複数行のブロックだけ、条件を満たすときに全行を同じ数の空白で動かします。
|
|
235
181
|
条件は[データブロック](./docs/flowchart.ja.md#データブロック)にあります。
|
|
236
182
|
フロントマターは Prettier が YAML として読めるときだけ整形します。
|
|
237
|
-
usecase
|
|
183
|
+
usecase のメタデータのプロパティは図の構文なので、読み取って検査します。
|
|
238
184
|
- mermaid.js が許すより多くの辺を持つ flowchart は、mermaid.js は拒否しますが、
|
|
239
185
|
ここでは整形します。
|
|
240
186
|
許す数は、サイト設定の `maxEdges` で、既定で 500 本です。
|
|
@@ -251,42 +197,13 @@ flowchart LR
|
|
|
251
197
|
|
|
252
198
|
## 文書
|
|
253
199
|
|
|
254
|
-
- [
|
|
255
|
-
|
|
256
|
-
-
|
|
257
|
-
-
|
|
258
|
-
- [
|
|
259
|
-
|
|
260
|
-
- [docs/
|
|
261
|
-
|
|
262
|
-
- [docs/requirement.ja.md](./docs/requirement.ja.md): requirement
|
|
263
|
-
図の整形の規則。
|
|
264
|
-
- [docs/mindmap.ja.md](./docs/mindmap.ja.md): mindmap の整形の規則。
|
|
265
|
-
- [docs/timeline.ja.md](./docs/timeline.ja.md): timeline の整形の規則。
|
|
266
|
-
- [docs/sankey.ja.md](./docs/sankey.ja.md): sankey 図の整形の規則。
|
|
267
|
-
- [docs/xychart.ja.md](./docs/xychart.ja.md): XY チャートの整形の規則。
|
|
268
|
-
- [docs/quadrant.ja.md](./docs/quadrant.ja.md): 象限チャートの整形の規則。
|
|
269
|
-
- [docs/kanban.ja.md](./docs/kanban.ja.md): kanban の整形の規則。
|
|
270
|
-
- [docs/c4.ja.md](./docs/c4.ja.md): C4 図の整形の規則。
|
|
271
|
-
- [docs/venn.ja.md](./docs/venn.ja.md): Venn 図の整形の規則。
|
|
272
|
-
- [docs/ishikawa.ja.md](./docs/ishikawa.ja.md): Ishikawa 図の整形の規則。
|
|
273
|
-
- [docs/usecase.ja.md](./docs/usecase.ja.md): usecase 図の整形の規則。
|
|
274
|
-
- [docs/pie.ja.md](./docs/pie.ja.md): pie 図の整形の規則。
|
|
275
|
-
- [docs/info.ja.md](./docs/info.ja.md): info の整形の規則。
|
|
276
|
-
- [docs/gitgraph.ja.md](./docs/gitgraph.ja.md): gitgraph の整形の規則。
|
|
277
|
-
- [docs/architecture.ja.md](./docs/architecture.ja.md): architecture
|
|
278
|
-
図の整形の規則。
|
|
279
|
-
- [docs/treemap.ja.md](./docs/treemap.ja.md): treemap 図の整形の規則。
|
|
280
|
-
- [docs/treeview.ja.md](./docs/treeview.ja.md): treeview 図の整形の規則。
|
|
281
|
-
- [docs/radar.ja.md](./docs/radar.ja.md): radar 図の整形の規則。
|
|
282
|
-
- [docs/wardley.ja.md](./docs/wardley.ja.md): Wardley 図の整形の規則。
|
|
283
|
-
- [docs/railroad.ja.md](./docs/railroad.ja.md): railroad 図の整形の規則。
|
|
284
|
-
- [docs/cynefin.ja.md](./docs/cynefin.ja.md): cynefin 図の整形規則。
|
|
285
|
-
- [docs/eventmodeling.ja.md](./docs/eventmodeling.ja.md): eventmodeling
|
|
286
|
-
図の整形規則。
|
|
287
|
-
- [docs/packet.ja.md](./docs/packet.ja.md): packet 図の整形の規則。
|
|
288
|
-
- [docs/block.ja.md](./docs/block.ja.md): ブロック図の整形の規則。
|
|
289
|
-
- [docs/compatibility.ja.md](./docs/compatibility.ja.md): mermaid.js
|
|
290
|
-
と違う箇所と、その理由。
|
|
200
|
+
- [フォーマッターの案内](https://mmd-toolkit.github.io/mmd-toolkit/ja/formatter/):
|
|
201
|
+
導入、
|
|
202
|
+
[設定](https://mmd-toolkit.github.io/mmd-toolkit/ja/formatter/configuration.html)、
|
|
203
|
+
[オプション](https://mmd-toolkit.github.io/mmd-toolkit/ja/formatter/options.html)。
|
|
204
|
+
- [フォーマッターの互換性](https://mmd-toolkit.github.io/mmd-toolkit/ja/formatter/compatibility.html):
|
|
205
|
+
構文エラーの扱い、mermaid.js との違い、保証の範囲。
|
|
206
|
+
- [docs/compatibility.ja.md](./docs/compatibility.ja.md): プラグインが
|
|
207
|
+
mermaid.js と違うすべての箇所と、その理由。
|
|
291
208
|
- [docs/development.ja.md](./docs/development.ja.md): テストと fixture。
|
|
292
209
|
プラグインを開発する人向けです。
|
package/README.md
CHANGED
|
@@ -2,19 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
Japanese version: [README.ja.md](./README.ja.md)
|
|
4
4
|
|
|
5
|
-
A [Prettier](https://prettier.io/) plugin that formats
|
|
6
|
-
and `.mermaid` files, and
|
|
5
|
+
A [Prettier](https://prettier.io/) plugin that formats
|
|
6
|
+
[Mermaid](https://mermaid.js.org/) diagrams: `.mmd` and `.mermaid` files, and
|
|
7
|
+
`mermaid` code blocks in Markdown.
|
|
7
8
|
|
|
8
|
-
This is a third-party project, not affiliated with
|
|
9
|
-
|
|
9
|
+
This is a third-party project, not affiliated with
|
|
10
|
+
[mermaid-js](https://mermaid.js.org/). `mmd` here means the Mermaid diagram
|
|
11
|
+
syntax, not MultiMarkdown or MikuMikuDance.
|
|
12
|
+
|
|
13
|
+
Documentation:
|
|
14
|
+
[Formatter](https://mmd-toolkit.github.io/mmd-toolkit/formatter/).
|
|
10
15
|
|
|
11
16
|
## Playground
|
|
12
17
|
|
|
13
18
|
Preview this plugin's formatting in the browser. The **Formatted** tab updates
|
|
14
|
-
as you edit, with **Indent
|
|
15
|
-
to replace the input with the result.
|
|
19
|
+
as you edit, with **Print width**, **Indent**, and **Use tabs** controls. Use
|
|
20
|
+
**Apply to source** to replace the input with the result.
|
|
16
21
|
|
|
17
|
-
|
|
22
|
+
Open the [Playground](https://mmd-toolkit.github.io/mmd-toolkit/playground/).
|
|
18
23
|
|
|
19
24
|
For usage, see the [Playground guide](../playground/README.md).
|
|
20
25
|
|
|
@@ -44,7 +49,7 @@ npx prettier --write "**/*.{mmd,mermaid,md}"
|
|
|
44
49
|
## Example
|
|
45
50
|
|
|
46
51
|
Input
|
|
47
|
-
([
|
|
52
|
+
([file](./tests/fixtures/flowchart/statements-one-per-line/separated-by-semicolons-input.mmd)):
|
|
48
53
|
|
|
49
54
|
```mmd
|
|
50
55
|
flowchart LR
|
|
@@ -53,7 +58,7 @@ flowchart LR
|
|
|
53
58
|
```
|
|
54
59
|
|
|
55
60
|
Output
|
|
56
|
-
([
|
|
61
|
+
([file](./tests/fixtures/flowchart/statements-one-per-line/separated-by-semicolons-output.mmd)):
|
|
57
62
|
|
|
58
63
|
```mmd
|
|
59
64
|
flowchart LR
|
|
@@ -71,82 +76,43 @@ flowchart LR
|
|
|
71
76
|
- Files ending in `.mmd` or `.mermaid`.
|
|
72
77
|
- Markdown code blocks whose info string has `mermaid` or `mmd` as its first
|
|
73
78
|
word. The match is case-sensitive: `Mermaid` and `mermaidx` are not formatted.
|
|
74
|
-
-
|
|
75
|
-
`swimlane-beta`. The formatting rules, with examples, are in
|
|
76
|
-
[docs/flowchart.md](./docs/flowchart.md).
|
|
77
|
-
- Agentflow: diagrams that start with `agentflow-beta`. The formatting rules,
|
|
78
|
-
with examples, are in [docs/agentflow.md](./docs/agentflow.md).
|
|
79
|
-
- Sequence diagrams: diagrams that start with `sequenceDiagram`. The formatting
|
|
80
|
-
rules, with examples, are in [docs/sequence.md](./docs/sequence.md).
|
|
81
|
-
- Class diagrams: diagrams that start with `classDiagram` or `classDiagram-v2`.
|
|
82
|
-
The formatting rules, with examples, are in [docs/class.md](./docs/class.md).
|
|
83
|
-
- State diagrams: diagrams that start with `stateDiagram` or `stateDiagram-v2`.
|
|
84
|
-
The formatting rules, with examples, are in [docs/state.md](./docs/state.md).
|
|
85
|
-
- ER diagrams: diagrams that start with `erDiagram`. The formatting rules, with
|
|
86
|
-
examples, are in [docs/er.md](./docs/er.md).
|
|
87
|
-
- Gantt charts: diagrams that start with `gantt`. The formatting rules, with
|
|
88
|
-
examples, are in [docs/gantt.md](./docs/gantt.md).
|
|
89
|
-
- User journeys: diagrams that start with `journey`. The formatting rules, with
|
|
90
|
-
examples, are in [docs/journey.md](./docs/journey.md).
|
|
91
|
-
- Requirement diagrams: diagrams that start with `requirementDiagram`. The
|
|
92
|
-
formatting rules, with examples, are in
|
|
93
|
-
[docs/requirement.md](./docs/requirement.md).
|
|
94
|
-
- Mindmaps: diagrams that start with `mindmap`. The formatting rules, with
|
|
95
|
-
examples, are in [docs/mindmap.md](./docs/mindmap.md).
|
|
96
|
-
- Timelines: diagrams that start with `timeline`. The formatting rules, with
|
|
97
|
-
examples, are in [docs/timeline.md](./docs/timeline.md).
|
|
98
|
-
- Sankey diagrams: diagrams that start with `sankey` or `sankey-beta`. The
|
|
99
|
-
formatting rules, with examples, are in [docs/sankey.md](./docs/sankey.md).
|
|
100
|
-
- XY charts: diagrams that start with `xychart` or `xychart-beta`. The
|
|
101
|
-
formatting rules, with examples, are in [docs/xychart.md](./docs/xychart.md).
|
|
102
|
-
- Quadrant charts: diagrams that start with `quadrantChart`. The formatting
|
|
103
|
-
rules, with examples, are in [docs/quadrant.md](./docs/quadrant.md).
|
|
104
|
-
- Kanban boards: diagrams that start with `kanban`. The formatting rules, with
|
|
105
|
-
examples, are in [docs/kanban.md](./docs/kanban.md).
|
|
106
|
-
- C4 diagrams: `C4Context`, `C4Container`, `C4Component`, `C4Dynamic`, and
|
|
107
|
-
`C4Deployment`. The formatting rules, with examples, are in
|
|
108
|
-
[docs/c4.md](./docs/c4.md).
|
|
109
|
-
- Venn diagrams: diagrams that start with `venn-beta`. The formatting rules,
|
|
110
|
-
with examples, are in [docs/venn.md](./docs/venn.md).
|
|
111
|
-
- Ishikawa diagrams: `ishikawa` and `ishikawa-beta`, including accepted case
|
|
112
|
-
variants. The formatting rules are in [docs/ishikawa.md](./docs/ishikawa.md).
|
|
113
|
-
- Usecase diagrams: diagrams that start with `usecase-beta`. The formatting
|
|
114
|
-
rules are in [docs/usecase.md](./docs/usecase.md).
|
|
115
|
-
- Pie charts: diagrams that start with `pie`, including `showData`. The
|
|
116
|
-
formatting rules are in [docs/pie.md](./docs/pie.md).
|
|
117
|
-
- Info diagrams: diagrams that start with `info`, including `showInfo`. The
|
|
118
|
-
formatting rules are in [docs/info.md](./docs/info.md).
|
|
119
|
-
- Git graphs: diagrams that start with `gitGraph`. The formatting rules are in
|
|
120
|
-
[docs/gitgraph.md](./docs/gitgraph.md).
|
|
121
|
-
- Architecture diagrams: `architecture-beta`. The formatting rules are in
|
|
122
|
-
[docs/architecture.md](./docs/architecture.md).
|
|
123
|
-
- Treemap diagrams: `treemap` and `treemap-beta`. The formatting rules are in
|
|
124
|
-
[docs/treemap.md](./docs/treemap.md).
|
|
125
|
-
- Treeview diagrams: `treeView-beta`. The formatting rules are in
|
|
126
|
-
[docs/treeview.md](./docs/treeview.md).
|
|
127
|
-
- Radar diagrams: `radar-beta`. The formatting rules are in
|
|
128
|
-
[docs/radar.md](./docs/radar.md).
|
|
129
|
-
- Wardley maps: `wardley-beta`. The formatting rules are in
|
|
130
|
-
[docs/wardley.md](./docs/wardley.md).
|
|
131
|
-
- Railroad diagrams: `railroad-beta`, `railroad-ebnf-beta`, `railroad-abnf-beta`
|
|
132
|
-
and `railroad-peg-beta`. The formatting rules are in
|
|
133
|
-
[docs/railroad.md](./docs/railroad.md).
|
|
134
|
-
- Cynefin diagrams: `cynefin-beta` and `cynefin-beta:`. The formatting rules are
|
|
135
|
-
in [docs/cynefin.md](./docs/cynefin.md).
|
|
136
|
-
- Eventmodeling diagrams: `eventmodeling`. The formatting rules are in
|
|
137
|
-
[docs/eventmodeling.md](./docs/eventmodeling.md).
|
|
138
|
-
- Packet diagrams: `packet` and `packet-beta`. The formatting rules are in
|
|
139
|
-
[docs/packet.md](./docs/packet.md).
|
|
140
|
-
- Block diagrams: diagrams that start with `block-beta` or `block`. The
|
|
141
|
-
formatting rules, with examples, are in [docs/block.md](./docs/block.md).
|
|
79
|
+
- Every diagram type of mermaid.js.
|
|
142
80
|
- The YAML frontmatter of these diagrams, with Prettier's YAML formatter.
|
|
143
81
|
|
|
82
|
+
The formatting rules of each diagram type are in its document:
|
|
83
|
+
[flowcharts](./docs/flowchart.md), [Agentflow](./docs/agentflow.md),
|
|
84
|
+
[sequence diagrams](./docs/sequence.md), [class diagrams](./docs/class.md),
|
|
85
|
+
[state diagrams](./docs/state.md), [ER diagrams](./docs/er.md),
|
|
86
|
+
[Gantt charts](./docs/gantt.md), [user journeys](./docs/journey.md),
|
|
87
|
+
[requirement diagrams](./docs/requirement.md), [mindmaps](./docs/mindmap.md),
|
|
88
|
+
[timelines](./docs/timeline.md), [sankey diagrams](./docs/sankey.md),
|
|
89
|
+
[XY charts](./docs/xychart.md), [quadrant charts](./docs/quadrant.md),
|
|
90
|
+
[kanban boards](./docs/kanban.md), [C4 diagrams](./docs/c4.md),
|
|
91
|
+
[Venn diagrams](./docs/venn.md), [Ishikawa diagrams](./docs/ishikawa.md),
|
|
92
|
+
[usecase diagrams](./docs/usecase.md), [pie charts](./docs/pie.md),
|
|
93
|
+
[info diagrams](./docs/info.md), [git graphs](./docs/gitgraph.md),
|
|
94
|
+
[architecture diagrams](./docs/architecture.md), [treemaps](./docs/treemap.md),
|
|
95
|
+
[treeviews](./docs/treeview.md), [radar diagrams](./docs/radar.md),
|
|
96
|
+
[Wardley maps](./docs/wardley.md), [railroad diagrams](./docs/railroad.md),
|
|
97
|
+
[cynefin diagrams](./docs/cynefin.md),
|
|
98
|
+
[eventmodeling diagrams](./docs/eventmodeling.md),
|
|
99
|
+
[packet diagrams](./docs/packet.md), and [block diagrams](./docs/block.md).
|
|
100
|
+
|
|
144
101
|
## Options
|
|
145
102
|
|
|
146
103
|
- `useTabs` and `tabWidth` set the indentation. The default is two spaces.
|
|
147
104
|
- `endOfLine` sets the line endings.
|
|
148
|
-
- `printWidth`
|
|
149
|
-
|
|
105
|
+
- `printWidth` decides two things. A data block `@{ … }` on one line in a
|
|
106
|
+
flowchart, an agentflow, or a kanban board is printed on several lines when
|
|
107
|
+
its line is wider than `printWidth` and the conditions of
|
|
108
|
+
[Data blocks](./docs/flowchart.md#data-blocks) hold; a block of one entry, for
|
|
109
|
+
example, stays on its line. The colons of the tasks of a Gantt section are
|
|
110
|
+
lined up unless that would make a line wider than `printWidth` and wider than
|
|
111
|
+
it is (see [Task data](./docs/gantt.md#task-data)). The width is the one
|
|
112
|
+
Prettier measures: a full-width character counts as two columns and a tab as
|
|
113
|
+
none. A Gantt section counts its lines alone, without what a Markdown list or
|
|
114
|
+
block quote puts before them. Everywhere else `printWidth` does not control
|
|
115
|
+
diagram line breaks. `railroad-beta` calls follow their grammar structure; see
|
|
150
116
|
[Long lines](./docs/railroad.md#long-lines). Prettier can still use it for
|
|
151
117
|
Markdown and YAML frontmatter.
|
|
152
118
|
|
|
@@ -161,35 +127,44 @@ flowchart LR
|
|
|
161
127
|
`subgraph Handle click events`: in flowchart, `click` is a reserved word. An
|
|
162
128
|
empty string between tokens, as in `A-->|x""|B`, is reported too. The full
|
|
163
129
|
list is in [docs/compatibility.md](./docs/compatibility.md).
|
|
164
|
-
-
|
|
165
|
-
|
|
166
|
-
|
|
130
|
+
- A text of only the word `error`, with comments, directives, and line breaks
|
|
131
|
+
around it, is not changed, except that line endings follow `endOfLine`:
|
|
132
|
+
mermaid.js reads it as its `error` pseudo-diagram. In Markdown, it is left to
|
|
133
|
+
Prettier.
|
|
167
134
|
|
|
168
135
|
## Guarantees and limitations
|
|
169
136
|
|
|
170
137
|
- Formatting preserves what mermaid.js reads, apart from the documented
|
|
171
138
|
whitespace changes below.
|
|
139
|
+
- mermaid.js is the reference, at the version recorded in the specification,
|
|
140
|
+
currently 12.3.0. When the formatter would change how a token is spelled, such
|
|
141
|
+
as the case of a keyword, it keeps the spelling as written if the history of
|
|
142
|
+
mermaid.js (its changelog and the grammars of earlier releases) shows that an
|
|
143
|
+
earlier version reads the new spelling differently or not at all. The rest of
|
|
144
|
+
its formatting is checked with 12.3.0 only.
|
|
145
|
+
[Versions of mermaid.js](./docs/compatibility.md#versions-of-mermaidjs) lists
|
|
146
|
+
what was read for each kind of spelling.
|
|
147
|
+
- Formatting a formatted diagram again changes nothing.
|
|
172
148
|
- Whitespace at the end of a `style`, `classDef`, or `linkStyle` line is
|
|
173
149
|
removed. mermaid.js keeps it at the end of the last style.
|
|
174
|
-
-
|
|
175
|
-
[Data blocks](./docs/eventmodeling.md#data-blocks) rule permits
|
|
176
|
-
|
|
177
|
-
the
|
|
178
|
-
-
|
|
179
|
-
[Notes](./docs/state.md#notes) rule, including lines with inline
|
|
180
|
-
code notation. Only
|
|
181
|
-
the rendered diagram stays the same. Other
|
|
182
|
-
|
|
183
|
-
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
content
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
and validated as syntax.
|
|
150
|
+
- The lines inside `eventmodeling` data and note blocks are aligned where the
|
|
151
|
+
[Data blocks](./docs/eventmodeling.md#data-blocks) rule permits it. This can
|
|
152
|
+
change the spaces in the text that mermaid.js keeps, while the rendered
|
|
153
|
+
diagram stays the same.
|
|
154
|
+
- A single paragraph in a state note closed by `end note` is aligned where the
|
|
155
|
+
[Notes](./docs/state.md#notes) rule permits it, including lines with inline
|
|
156
|
+
emphasis and code notation. Only the whitespace at the start of its lines
|
|
157
|
+
changes, and the rendered diagram stays the same. Other bodies whose margins
|
|
158
|
+
affect the drawing keep the margins of their later lines as written.
|
|
159
|
+
- The content of directives, of `@{ ... }` data blocks, and of the frontmatter
|
|
160
|
+
is not checked. A diagram that mermaid.js rejects because of that content is
|
|
161
|
+
still formatted. Directives are kept as written. A `@{ ... }` data block keeps
|
|
162
|
+
its content too; a block on one line is printed with one space inside each
|
|
163
|
+
end, and only a multi-line block that meets the conditions in
|
|
164
|
+
[Data blocks](./docs/flowchart.md#data-blocks) has all its lines moved by the
|
|
165
|
+
same number of spaces. The frontmatter is formatted only when Prettier can
|
|
166
|
+
read it as YAML. The metadata properties of a usecase diagram are syntax of
|
|
167
|
+
the diagram, so they are read and checked.
|
|
193
168
|
- A flowchart with more edges than mermaid.js allows, 500 by default (its
|
|
194
169
|
`maxEdges` site setting), is rejected by mermaid.js but still formatted: the
|
|
195
170
|
plugin does not know the site settings.
|
|
@@ -205,48 +180,14 @@ The reasons and the details are in
|
|
|
205
180
|
|
|
206
181
|
## Documentation
|
|
207
182
|
|
|
208
|
-
- [
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
- [
|
|
214
|
-
|
|
215
|
-
- [docs/
|
|
216
|
-
|
|
217
|
-
- [docs/requirement.md](./docs/requirement.md): the formatting rules for
|
|
218
|
-
requirement diagrams.
|
|
219
|
-
- [docs/mindmap.md](./docs/mindmap.md): the formatting rules for mindmaps.
|
|
220
|
-
- [docs/timeline.md](./docs/timeline.md): the formatting rules for timelines.
|
|
221
|
-
- [docs/sankey.md](./docs/sankey.md): the formatting rules for sankey diagrams.
|
|
222
|
-
- [docs/xychart.md](./docs/xychart.md): the formatting rules for XY charts.
|
|
223
|
-
- [docs/quadrant.md](./docs/quadrant.md): the formatting rules for quadrant
|
|
224
|
-
charts.
|
|
225
|
-
- [docs/kanban.md](./docs/kanban.md): the formatting rules for kanban boards.
|
|
226
|
-
- [docs/c4.md](./docs/c4.md): the formatting rules for C4 diagrams.
|
|
227
|
-
- [docs/venn.md](./docs/venn.md): the formatting rules for Venn diagrams.
|
|
228
|
-
- [docs/ishikawa.md](./docs/ishikawa.md): the formatting rules for Ishikawa
|
|
229
|
-
diagrams.
|
|
230
|
-
- [docs/usecase.md](./docs/usecase.md): the formatting rules for usecase
|
|
231
|
-
diagrams.
|
|
232
|
-
- [docs/pie.md](./docs/pie.md): the formatting rules for pie charts.
|
|
233
|
-
- [docs/info.md](./docs/info.md): the formatting rules for info diagrams.
|
|
234
|
-
- [docs/gitgraph.md](./docs/gitgraph.md): the formatting rules for git graphs.
|
|
235
|
-
- [docs/architecture.md](./docs/architecture.md): the formatting rules for
|
|
236
|
-
architecture diagrams.
|
|
237
|
-
- [docs/treemap.md](./docs/treemap.md): the formatting rules for treemaps.
|
|
238
|
-
- [docs/treeview.md](./docs/treeview.md): the formatting rules for treeviews.
|
|
239
|
-
- [docs/radar.md](./docs/radar.md): the formatting rules for radar diagrams.
|
|
240
|
-
- [docs/wardley.md](./docs/wardley.md): the formatting rules for Wardley maps.
|
|
241
|
-
- [docs/railroad.md](./docs/railroad.md): the formatting rules for railroad
|
|
242
|
-
diagrams.
|
|
243
|
-
- [docs/cynefin.md](./docs/cynefin.md): the formatting rules for cynefin
|
|
244
|
-
diagrams.
|
|
245
|
-
- [docs/eventmodeling.md](./docs/eventmodeling.md): Eventmodeling formatting
|
|
246
|
-
rules.
|
|
247
|
-
- [docs/packet.md](./docs/packet.md): the formatting rules for packet diagrams.
|
|
248
|
-
- [docs/block.md](./docs/block.md): the formatting rules for block diagrams.
|
|
249
|
-
- [docs/compatibility.md](./docs/compatibility.md): where the plugin differs
|
|
250
|
-
from mermaid.js, and why.
|
|
183
|
+
- [Formatter guide](https://mmd-toolkit.github.io/mmd-toolkit/formatter/):
|
|
184
|
+
installation,
|
|
185
|
+
[configuration](https://mmd-toolkit.github.io/mmd-toolkit/formatter/configuration.html),
|
|
186
|
+
and
|
|
187
|
+
[options](https://mmd-toolkit.github.io/mmd-toolkit/formatter/options.html).
|
|
188
|
+
- [Formatter compatibility](https://mmd-toolkit.github.io/mmd-toolkit/formatter/compatibility.html):
|
|
189
|
+
syntax errors, differences from mermaid.js, and the limits of the guarantees.
|
|
190
|
+
- [docs/compatibility.md](./docs/compatibility.md): every place where the plugin
|
|
191
|
+
differs from mermaid.js, and why.
|
|
251
192
|
- [docs/development.md](./docs/development.md): the tests and the fixtures, for
|
|
252
193
|
people who work on the plugin.
|
package/lib/index.d.mts
CHANGED
|
@@ -165,8 +165,12 @@ type MermaidAst = FormattedDocument | Node;
|
|
|
165
165
|
//#endregion
|
|
166
166
|
//#region src/index.d.ts
|
|
167
167
|
export declare const languages: SupportLanguage[];
|
|
168
|
-
export declare const parsers:
|
|
169
|
-
|
|
168
|
+
export declare const parsers: {
|
|
169
|
+
mermaid: Parser<MermaidAst>;
|
|
170
|
+
};
|
|
171
|
+
export declare const printers: {
|
|
172
|
+
mermaid: Printer<MermaidAst>;
|
|
173
|
+
};
|
|
170
174
|
declare const plugin: Plugin<MermaidAst>;
|
|
171
175
|
//#endregion
|
|
172
176
|
export { type FormattedDocument, type MermaidAst, plugin as default };
|