prettier-plugin-mmd 0.8.0 → 0.9.1

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
@@ -152,16 +152,26 @@ flowchart LR
152
152
 
153
153
  - 次に記す空白の変更を除き、mermaid.js の読み取りを保ちます。
154
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-の版)に挙げています。
155
+ 整形した図は別の版でも描かれるので、フォーマッターは、印字するものを、
156
+ 図種ごとに多くて 5 つの版の mermaid.js で確かめています。
157
+ 書き方(キーワードの大文字小文字など)を変えるとき、
158
+ その図種で対象にする版のうち、書かれた形を読む版が、変えた後の形を読まないか、
159
+ 違う図として描く場合は、書かれたまま残します。
160
+ 図種ごとに対象にする版は
161
+ [対象にする mermaid.js の版](./docs/compatibility.ja.md#対象にする-mermaidjs-の版)
162
+ に挙げています。
163
+ 書かれたまま残す形は、
164
+ [対象にする版の mermaid.js のために残す形](./docs/compatibility.ja.md#対象にする版の-mermaidjs-のために残す形)
165
+ に 1 つずつ挙げています。
162
166
  - 整形した図をもう一度整形しても、何も変わりません。
163
- - `style`、`classDef`、`linkStyle` の行の末尾の空白を取り除きます。
164
- mermaid.js は、その空白を最後のスタイルの末尾に残します。
167
+ - `style`、`classDef`、`linkStyle` の行の末尾の空白とタブを取り除きます。
168
+ ただし、取り除くと mermaid.js が別の図を描く所では残します。
169
+ 図種の文書が名前を挙げている文がそれで、
170
+ 最後のスタイルの末尾にあるバックスラッシュの後の空白やタブと、
171
+ `linkStyle default stroke: ` の空の値のような、空白だけのスタイルです。
172
+ mermaid.js は、それらを最後のスタイルの末尾に残します。
173
+ ノーブレークスペースなど、ほかの種類の空白は、
174
+ 図が変わる所(class 図や flowchart など)では残します。
165
175
  - `eventmodeling` のデータとノートのブロックの中の行は、
166
176
  [Data blocks](./docs/eventmodeling.ja.md#data-blocks)
167
177
  の規則が許す場合に揃えます。
package/README.md CHANGED
@@ -137,16 +137,25 @@ The formatting rules of each diagram type are in its document:
137
137
  - Formatting preserves what mermaid.js reads, apart from the documented
138
138
  whitespace changes below.
139
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.
140
+ currently 12.3.0. A formatted text is also drawn by other versions, so the
141
+ formatter checks what it prints against up to five versions of mermaid.js for
142
+ each diagram type. When the formatter would change how something is written,
143
+ such as the case of a keyword, it keeps it as written if a version that counts
144
+ for the diagram type and reads the written form does not read the new form, or
145
+ draws it differently.
146
+ [Versions of mermaid.js that count](./docs/compatibility.md#versions-of-mermaidjs-that-count)
147
+ lists them for each diagram type, and
148
+ [Forms kept for versions of mermaid.js that count](./docs/compatibility.md#forms-kept-for-versions-of-mermaidjs-that-count)
149
+ lists each form that stays as written for them.
147
150
  - Formatting a formatted diagram again changes nothing.
148
- - Whitespace at the end of a `style`, `classDef`, or `linkStyle` line is
149
- removed. mermaid.js keeps it at the end of the last style.
151
+ - Spaces and tabs at the end of a `style`, `classDef`, or `linkStyle` line are
152
+ removed, except where mermaid.js draws another figure without them, in the
153
+ statements that the document of the diagram type names: a space or a tab after
154
+ a backslash that ends the last style, and a style of whitespace only, such as
155
+ the blank value in `linkStyle default stroke: `. mermaid.js keeps them at the
156
+ end of the last style. Whitespace of another kind there, such as a no-break
157
+ space, stays where it changes the figure, in a class diagram and a flowchart
158
+ for example.
150
159
  - The lines inside `eventmodeling` data and note blocks are aligned where the
151
160
  [Data blocks](./docs/eventmodeling.md#data-blocks) rule permits it. This can
152
161
  change the spaces in the text that mermaid.js keeps, while the rendered
package/lib/index.d.mts CHANGED
@@ -13,8 +13,8 @@ interface TriviaComment {
13
13
  }
14
14
  /**
15
15
  * A directive as the printers read it: its kind and its range, which takes
16
- * the whitespace after a directive that is not closed when that holds a
17
- * U+2028 or U+2029 (see `extendDirective`).
16
+ * the whitespace after a directive that is not closed, as the scan of
17
+ * mermaid.js does (see `extendDirective`).
18
18
  */
19
19
  interface TriviaDirective {
20
20
  readonly type: "Directive";
@@ -52,11 +52,30 @@ interface Source {
52
52
  * comment.
53
53
  */
54
54
  readonly ignoredSemicolons: ReadonlySet<number>;
55
+ /**
56
+ * The ranges that mermaid.js removes before the lexer of the diagram reads
57
+ * the text, in source order and disjoint: the directives, with the
58
+ * whitespace that a directive that is not closed takes, the comment
59
+ * regions, and the `;` that the line rule ignores. What is left is the
60
+ * diagram text (common.md, Reading a source). A decision about how
61
+ * mermaid.js reads a place reads the characters through `skipRemoved`,
62
+ * `previousRead`, and `textRead`, not from `text`.
63
+ */
64
+ readonly removed: readonly Range[];
65
+ /**
66
+ * The ranges that are removed before the line rule is applied: `removed`
67
+ * without the `;`. Diagram detection reads the text at this stage, so the
68
+ * header of the diagram is decided on it (docs/cynefin.md, Semicolons); see
69
+ * `skipRemovedBeforeLineRule` and `textReadBeforeLineRule`.
70
+ */
71
+ readonly removedBeforeLineRule: readonly Range[];
55
72
  /**
56
73
  * The comment regions that join lines (see `JoiningRegion`), in source
57
74
  * order.
58
75
  */
59
76
  readonly joiningRegions: readonly JoiningRegion[];
77
+ /** All removed comment regions, including their preceding whitespace (common.md, Comment lines). */
78
+ readonly commentRegions: readonly Range[];
60
79
  /**
61
80
  * The offsets of the line feeds that mermaid.js does not read as line
62
81
  * ends, so that the lines they end go on: the line feeds that the joining