prettier-plugin-mmd 0.4.1 → 0.6.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 CHANGED
@@ -2,14 +2,18 @@
2
2
 
3
3
  英語版: [README.md](./README.md)
4
4
 
5
- Mermaid の図を整形する [Prettier](https://prettier.io/) プラグインです。
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
  ブラウザーで、このプラグインによる整形結果を確認できます。
@@ -17,7 +21,8 @@ MultiMarkdown や MikuMikuDance ではありません。
17
21
  **Indent**と**Use tabs**で字下げを設定できます。
18
22
  **Apply to source**で、入力を整形結果に置き換えられます。
19
23
 
20
- 公開URL: [Playground](https://mmd-toolkit.github.io/mmd-toolkit/playground/)。
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
- ([statements-one-per-line/separated-by-semicolons-input.mmd](./tests/fixtures/flowchart/statements-one-per-line/separated-by-semicolons-input.mmd)):
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
- ([statements-one-per-line/separated-by-semicolons-output.mmd](./tests/fixtures/flowchart/statements-one-per-line/separated-by-semicolons-output.mmd)):
67
+ ([ファイル](./tests/fixtures/flowchart/statements-one-per-line/separated-by-semicolons-output.mmd)):
63
68
 
64
69
  ```mmd
65
70
  flowchart LR
@@ -78,107 +83,28 @@ flowchart LR
78
83
  - Markdown の、情報文字列の最初の語が `mermaid` か `mmd` のコードブロック。
79
84
  大文字と小文字を区別するので、`Mermaid` は整形しません。
80
85
  `mermaidx` も整形しません。
81
- - flowchart。
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` で字下げを決めます。
@@ -203,34 +129,45 @@ flowchart LR
203
129
  flowchart では、`click` は予約語です。
204
130
  `A-->|x""|B` のように、トークンの間に空の文字列がある場合もそうです。
205
131
  一覧は [docs/compatibility.ja.md](./docs/compatibility.ja.md) にあります。
206
- - mermaid.js の `error` 擬似図は変えません。
207
- `error` という語と、
208
- その周りのコメント・ディレクティブ・改行だけでできたテキストです。
132
+ - `error` という語と、
133
+ その周りのコメント・ディレクティブ・改行だけでできたテキストは変えません。
134
+ mermaid.js はこれを `error` 擬似図として読みます。
209
135
  ただし、改行コードは `endOfLine` に従います。
210
136
  Markdown では、Prettier に任せます。
211
137
 
212
138
  ## 保証と制限
213
139
 
214
140
  - 次に記す空白の変更を除き、mermaid.js の読み取りを保ちます。
141
+ - 基準は、仕様に記録した版の mermaid.js で、現在は 12.3.0 です。
142
+ フォーマッターは、トークンの綴り(キーワードの大文字小文字など)を変えるとき、
143
+ mermaid.js の履歴(変更履歴と、過去の版の文法)から、
144
+ 古い版が変えた後の綴りを読まないか、別に読むと分かる場合は、
145
+ 書かれたまま残します。
146
+ それ以外の整形は、12.3.0 だけで確かめています。
147
+ 綴りの種類ごとに何を読んだかは、
148
+ [mermaid.js の版](./docs/compatibility.ja.md#mermaidjs-の版)に挙げています。
149
+ - 整形した図をもう一度整形しても、何も変わりません。
215
150
  - `style`、`classDef`、`linkStyle` の行の末尾の空白を取り除きます。
216
151
  mermaid.js は、その空白を最後のスタイルの末尾に残します。
217
- - `eventmodeling` の block data と note は、
218
- [Data blocks](./docs/eventmodeling.ja.md#data-blocks) の規則で、
219
- ASCII 空白の margin を限定的に変更します。
220
- 描画を保ちながら、raw Db 値が変わる場合があります。
152
+ - `eventmodeling` のデータとノートのブロックの中の行は、
153
+ [Data blocks](./docs/eventmodeling.ja.md#data-blocks)
154
+ の規則が許す場合に揃えます。
155
+ mermaid.js が持つテキストの空白が変わることがありますが、描画は変わりません。
221
156
  - `end note` で閉じる state ノートの単一の段落は、
222
- [ノート](./docs/state.ja.md#ノート)の限定規則に従います。
157
+ [ノート](./docs/state.ja.md#ノート)の規則が許す場合に揃えます。
223
158
  行内の強調やコードの表記を含む行も対象です。
224
- 描画を保ちながら、
225
- `notes[].text` の行頭の ASCII 空白だけが変わる場合があります。
159
+ 変わるのは行頭の空白だけで、描画は変わりません。
226
160
  余白が表示に影響するほかの本文は、後続の余白を原文のまま保ちます。
227
- - 整形した図をもう一度整形しても、何も変わりません。
228
- - ディレクティブ、不透明な `@{ ... }` のデータブロック、
161
+ - ディレクティブ、`@{ ... }` のデータブロック、
229
162
  フロントマターの中身は検査しません。
230
163
  その中身のために mermaid.js が拒否する図も整形します。
231
- ディレクティブと不透明な `@{ ... }` データブロックは書かれたまま残し、
164
+ ディレクティブは書かれたまま残します。
165
+ `@{ ... }` のデータブロックも中身を残し、1 行のブロックは、
166
+ 両端の内側に空白を 1 つずつ置いて印字します。
167
+ 複数行のブロックだけ、条件を満たすときに全行を同じ数の空白で動かします。
168
+ 条件は[データブロック](./docs/flowchart.ja.md#データブロック)にあります。
232
169
  フロントマターは Prettier が YAML として読めるときだけ整形します。
233
- usecase の native metadata は構文として解析し、プロパティを検証します。
170
+ usecase のメタデータのプロパティは図の構文なので、読み取って検査します。
234
171
  - mermaid.js が許すより多くの辺を持つ flowchart は、mermaid.js は拒否しますが、
235
172
  ここでは整形します。
236
173
  許す数は、サイト設定の `maxEdges` で、既定で 500 本です。
@@ -247,42 +184,13 @@ flowchart LR
247
184
 
248
185
  ## 文書
249
186
 
250
- - [docs/flowchart.ja.md](./docs/flowchart.ja.md): flowchart の整形の規則。
251
- - [docs/agentflow.ja.md](./docs/agentflow.ja.md): agentflow の整形の規則。
252
- - [docs/sequence.ja.md](./docs/sequence.ja.md): sequence 図の整形の規則。
253
- - [docs/class.ja.md](./docs/class.ja.md): class 図の整形の規則。
254
- - [docs/state.ja.md](./docs/state.ja.md): state 図の整形の規則。
255
- - [docs/er.ja.md](./docs/er.ja.md): ER 図の整形の規則。
256
- - [docs/gantt.ja.md](./docs/gantt.ja.md): Gantt 図の整形の規則。
257
- - [docs/journey.ja.md](./docs/journey.ja.md): journey 図の整形の規則。
258
- - [docs/requirement.ja.md](./docs/requirement.ja.md): requirement
259
- 図の整形の規則。
260
- - [docs/mindmap.ja.md](./docs/mindmap.ja.md): mindmap の整形の規則。
261
- - [docs/timeline.ja.md](./docs/timeline.ja.md): timeline の整形の規則。
262
- - [docs/sankey.ja.md](./docs/sankey.ja.md): sankey 図の整形の規則。
263
- - [docs/xychart.ja.md](./docs/xychart.ja.md): XY チャートの整形の規則。
264
- - [docs/quadrant.ja.md](./docs/quadrant.ja.md): 象限チャートの整形の規則。
265
- - [docs/kanban.ja.md](./docs/kanban.ja.md): kanban の整形の規則。
266
- - [docs/c4.ja.md](./docs/c4.ja.md): C4 図の整形の規則。
267
- - [docs/venn.ja.md](./docs/venn.ja.md): Venn 図の整形の規則。
268
- - [docs/ishikawa.ja.md](./docs/ishikawa.ja.md): Ishikawa 図の整形の規則。
269
- - [docs/usecase.ja.md](./docs/usecase.ja.md): usecase 図の整形の規則。
270
- - [docs/pie.ja.md](./docs/pie.ja.md): pie 図の整形の規則。
271
- - [docs/info.ja.md](./docs/info.ja.md): info の整形の規則。
272
- - [docs/gitgraph.ja.md](./docs/gitgraph.ja.md): gitgraph の整形の規則。
273
- - [docs/architecture.ja.md](./docs/architecture.ja.md): architecture
274
- 図の整形の規則。
275
- - [docs/treemap.ja.md](./docs/treemap.ja.md): treemap 図の整形の規則。
276
- - [docs/treeview.ja.md](./docs/treeview.ja.md): treeview 図の整形の規則。
277
- - [docs/radar.ja.md](./docs/radar.ja.md): radar 図の整形の規則。
278
- - [docs/wardley.ja.md](./docs/wardley.ja.md): Wardley 図の整形の規則。
279
- - [docs/railroad.ja.md](./docs/railroad.ja.md): railroad 図の整形の規則。
280
- - [docs/cynefin.ja.md](./docs/cynefin.ja.md): cynefin 図の整形規則。
281
- - [docs/eventmodeling.ja.md](./docs/eventmodeling.ja.md): eventmodeling
282
- 図の整形規則。
283
- - [docs/packet.ja.md](./docs/packet.ja.md): packet 図の整形の規則。
284
- - [docs/block.ja.md](./docs/block.ja.md): ブロック図の整形の規則。
285
- - [docs/compatibility.ja.md](./docs/compatibility.ja.md): mermaid.js
286
- と違う箇所と、その理由。
187
+ - [フォーマッターの案内](https://mmd-toolkit.github.io/mmd-toolkit/ja/formatter/):
188
+ 導入、
189
+ [設定](https://mmd-toolkit.github.io/mmd-toolkit/ja/formatter/configuration.html)、
190
+ [オプション](https://mmd-toolkit.github.io/mmd-toolkit/ja/formatter/options.html)。
191
+ - [フォーマッターの互換性](https://mmd-toolkit.github.io/mmd-toolkit/ja/formatter/compatibility.html):
192
+ 構文エラーの扱い、mermaid.js との違い、保証の範囲。
193
+ - [docs/compatibility.ja.md](./docs/compatibility.ja.md): プラグインが
194
+ mermaid.js と違うすべての箇所と、その理由。
287
195
  - [docs/development.ja.md](./docs/development.ja.md): テストと fixture。
288
196
  プラグインを開発する人向けです。
package/README.md CHANGED
@@ -2,11 +2,16 @@
2
2
 
3
3
  Japanese version: [README.ja.md](./README.ja.md)
4
4
 
5
- A [Prettier](https://prettier.io/) plugin that formats Mermaid diagrams: `.mmd`
6
- and `.mermaid` files, and `mermaid` code blocks in Markdown.
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 mermaid-js. `mmd` here means
9
- the Mermaid diagram syntax, not MultiMarkdown or MikuMikuDance.
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
 
@@ -14,7 +19,7 @@ Preview this plugin's formatting in the browser. The **Formatted** tab updates
14
19
  as you edit, with **Indent** and **Use tabs** controls. Use **Apply to source**
15
20
  to replace the input with the result.
16
21
 
17
- Public URL: [Playground](https://mmd-toolkit.github.io/mmd-toolkit/playground/).
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
- ([statements-one-per-line/separated-by-semicolons-input.mmd](./tests/fixtures/flowchart/statements-one-per-line/separated-by-semicolons-input.mmd)):
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
- ([statements-one-per-line/separated-by-semicolons-output.mmd](./tests/fixtures/flowchart/statements-one-per-line/separated-by-semicolons-output.mmd)):
61
+ ([file](./tests/fixtures/flowchart/statements-one-per-line/separated-by-semicolons-output.mmd)):
57
62
 
58
63
  ```mmd
59
64
  flowchart LR
@@ -71,76 +76,28 @@ 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
- - Flowcharts: diagrams that start with `flowchart`, `graph`, `flowchart-elk`, or
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.
@@ -161,32 +118,44 @@ flowchart LR
161
118
  `subgraph Handle click events`: in flowchart, `click` is a reserved word. An
162
119
  empty string between tokens, as in `A-->|x""|B`, is reported too. The full
163
120
  list is in [docs/compatibility.md](./docs/compatibility.md).
164
- - The `error` pseudo-diagram of mermaid.js, a text of the word `error` with only
165
- comments, directives, and line breaks around it, is not changed, except that
166
- line endings follow `endOfLine`. In Markdown, it is left to Prettier.
121
+ - A text of only the word `error`, with comments, directives, and line breaks
122
+ around it, is not changed, except that line endings follow `endOfLine`:
123
+ mermaid.js reads it as its `error` pseudo-diagram. In Markdown, it is left to
124
+ Prettier.
167
125
 
168
126
  ## Guarantees and limitations
169
127
 
170
128
  - Formatting preserves what mermaid.js reads, apart from the documented
171
129
  whitespace changes below.
130
+ - mermaid.js is the reference, at the version recorded in the specification,
131
+ currently 12.3.0. When the formatter would change how a token is spelled, such
132
+ as the case of a keyword, it keeps the spelling as written if the history of
133
+ mermaid.js (its changelog and the grammars of earlier releases) shows that an
134
+ earlier version reads the new spelling differently or not at all. The rest of
135
+ its formatting is checked with 12.3.0 only.
136
+ [Versions of mermaid.js](./docs/compatibility.md#versions-of-mermaidjs) lists
137
+ what was read for each kind of spelling.
138
+ - Formatting a formatted diagram again changes nothing.
172
139
  - Whitespace at the end of a `style`, `classDef`, or `linkStyle` line is
173
140
  removed. mermaid.js keeps it at the end of the last style.
174
- - For `eventmodeling` block data and notes, the
175
- [Data blocks](./docs/eventmodeling.md#data-blocks) rule permits a restricted
176
- ASCII space margin adjustment. This can change raw Db values while preserving
177
- the rendered diagram.
178
- - Single paragraphs in state notes closed by `end note` follow the restricted
179
- [Notes](./docs/state.md#notes) rule, including lines with inline emphasis and
180
- code notation. Only leading ASCII spaces may change in `notes[].text`, while
181
- the rendered diagram stays the same. Other margin-sensitive bodies keep their
182
- later margins as written.
183
- - Formatting a formatted diagram again changes nothing.
184
- - The content of directives, of opaque `@{ ... }` data blocks, and of the
185
- frontmatter is not checked. A diagram that mermaid.js rejects because of that
186
- content is still formatted. Directives and opaque `@{ ... }` data blocks are
187
- kept as written; the frontmatter is formatted only when Prettier can read it
188
- as YAML. Native usecase metadata properties are parsed and validated as
189
- syntax.
141
+ - The lines inside `eventmodeling` data and note blocks are aligned where the
142
+ [Data blocks](./docs/eventmodeling.md#data-blocks) rule permits it. This can
143
+ change the spaces in the text that mermaid.js keeps, while the rendered
144
+ diagram stays the same.
145
+ - A single paragraph in a state note closed by `end note` is aligned where the
146
+ [Notes](./docs/state.md#notes) rule permits it, including lines with inline
147
+ emphasis and code notation. Only the whitespace at the start of its lines
148
+ changes, and the rendered diagram stays the same. Other bodies whose margins
149
+ affect the drawing keep the margins of their later lines as written.
150
+ - The content of directives, of `@{ ... }` data blocks, and of the frontmatter
151
+ is not checked. A diagram that mermaid.js rejects because of that content is
152
+ still formatted. Directives are kept as written. A `@{ ... }` data block keeps
153
+ its content too; a block on one line is printed with one space inside each
154
+ end, and only a multi-line block that meets the conditions in
155
+ [Data blocks](./docs/flowchart.md#data-blocks) has all its lines moved by the
156
+ same number of spaces. The frontmatter is formatted only when Prettier can
157
+ read it as YAML. The metadata properties of a usecase diagram are syntax of
158
+ the diagram, so they are read and checked.
190
159
  - A flowchart with more edges than mermaid.js allows, 500 by default (its
191
160
  `maxEdges` site setting), is rejected by mermaid.js but still formatted: the
192
161
  plugin does not know the site settings.
@@ -202,48 +171,14 @@ The reasons and the details are in
202
171
 
203
172
  ## Documentation
204
173
 
205
- - [docs/flowchart.md](./docs/flowchart.md): the formatting rules for flowcharts.
206
- - [docs/agentflow.md](./docs/agentflow.md): the formatting rules for Agentflow.
207
- - [docs/sequence.md](./docs/sequence.md): the formatting rules for sequence
208
- diagrams.
209
- - [docs/class.md](./docs/class.md): the formatting rules for class diagrams.
210
- - [docs/state.md](./docs/state.md): the formatting rules for state diagrams.
211
- - [docs/er.md](./docs/er.md): the formatting rules for ER diagrams.
212
- - [docs/gantt.md](./docs/gantt.md): the formatting rules for Gantt charts.
213
- - [docs/journey.md](./docs/journey.md): the formatting rules for user journeys.
214
- - [docs/requirement.md](./docs/requirement.md): the formatting rules for
215
- requirement diagrams.
216
- - [docs/mindmap.md](./docs/mindmap.md): the formatting rules for mindmaps.
217
- - [docs/timeline.md](./docs/timeline.md): the formatting rules for timelines.
218
- - [docs/sankey.md](./docs/sankey.md): the formatting rules for sankey diagrams.
219
- - [docs/xychart.md](./docs/xychart.md): the formatting rules for XY charts.
220
- - [docs/quadrant.md](./docs/quadrant.md): the formatting rules for quadrant
221
- charts.
222
- - [docs/kanban.md](./docs/kanban.md): the formatting rules for kanban boards.
223
- - [docs/c4.md](./docs/c4.md): the formatting rules for C4 diagrams.
224
- - [docs/venn.md](./docs/venn.md): the formatting rules for Venn diagrams.
225
- - [docs/ishikawa.md](./docs/ishikawa.md): the formatting rules for Ishikawa
226
- diagrams.
227
- - [docs/usecase.md](./docs/usecase.md): the formatting rules for usecase
228
- diagrams.
229
- - [docs/pie.md](./docs/pie.md): the formatting rules for pie charts.
230
- - [docs/info.md](./docs/info.md): the formatting rules for info diagrams.
231
- - [docs/gitgraph.md](./docs/gitgraph.md): the formatting rules for git graphs.
232
- - [docs/architecture.md](./docs/architecture.md): the formatting rules for
233
- architecture diagrams.
234
- - [docs/treemap.md](./docs/treemap.md): the formatting rules for treemaps.
235
- - [docs/treeview.md](./docs/treeview.md): the formatting rules for treeviews.
236
- - [docs/radar.md](./docs/radar.md): the formatting rules for radar diagrams.
237
- - [docs/wardley.md](./docs/wardley.md): the formatting rules for Wardley maps.
238
- - [docs/railroad.md](./docs/railroad.md): the formatting rules for railroad
239
- diagrams.
240
- - [docs/cynefin.md](./docs/cynefin.md): the formatting rules for cynefin
241
- diagrams.
242
- - [docs/eventmodeling.md](./docs/eventmodeling.md): Eventmodeling formatting
243
- rules.
244
- - [docs/packet.md](./docs/packet.md): the formatting rules for packet diagrams.
245
- - [docs/block.md](./docs/block.md): the formatting rules for block diagrams.
246
- - [docs/compatibility.md](./docs/compatibility.md): where the plugin differs
247
- from mermaid.js, and why.
174
+ - [Formatter guide](https://mmd-toolkit.github.io/mmd-toolkit/formatter/):
175
+ installation,
176
+ [configuration](https://mmd-toolkit.github.io/mmd-toolkit/formatter/configuration.html),
177
+ and
178
+ [options](https://mmd-toolkit.github.io/mmd-toolkit/formatter/options.html).
179
+ - [Formatter compatibility](https://mmd-toolkit.github.io/mmd-toolkit/formatter/compatibility.html):
180
+ syntax errors, differences from mermaid.js, and the limits of the guarantees.
181
+ - [docs/compatibility.md](./docs/compatibility.md): every place where the plugin
182
+ differs from mermaid.js, and why.
248
183
  - [docs/development.md](./docs/development.md): the tests and the fixtures, for
249
184
  people who work on the plugin.
package/lib/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { Comment, Node, Range, Root } from "@mmd-toolkit/parser";
2
1
  import { AstPath, Doc, Parser, ParserOptions, Plugin, Printer, SupportLanguage } from "prettier";
2
+ import { Comment, Node, Range, Root } from "@mmd-toolkit/ast";
3
3
  //#region src/printers/source.d.ts
4
4
  /**
5
5
  * A comment as the printers read it: its kind, its range, and its mark. A