@riebeckite/plugin-plantuml 0.0.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/LICENSE +201 -0
- package/README.md +99 -0
- package/README_ja.md +81 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +299 -0
- package/dist/src/hast.d.ts +7 -0
- package/dist/src/plantuml-encoder.d.ts +40 -0
- package/dist/src/rehype.d.ts +2 -0
- package/dist/src/types.d.ts +46 -0
- package/package.json +55 -0
- package/style.css +77 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright Rerurate_514
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# @riebeckite/plugin-plantuml
|
|
2
|
+
|
|
3
|
+
PlantUML diagram rendering for ` ```plantuml ` code blocks. Diagrams are turned into
|
|
4
|
+
a PlantUML server image URL at build time; the build itself never talks to the
|
|
5
|
+
network and no client JavaScript is shipped.
|
|
6
|
+
|
|
7
|
+
[日本語](./README_ja.md)
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { defineConfig } from "@riebeckite/core";
|
|
13
|
+
import { plantuml } from "@riebeckite/plugin-plantuml";
|
|
14
|
+
|
|
15
|
+
export default defineConfig({
|
|
16
|
+
// ...
|
|
17
|
+
plugins: [plantuml()],
|
|
18
|
+
});
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`plantuml` is also exported under the alias `plantumlPlugin`.
|
|
22
|
+
|
|
23
|
+
## Behavior
|
|
24
|
+
|
|
25
|
+
Each ` ```plantuml ` code block is replaced with a `figure.rb-plantuml` whose
|
|
26
|
+
diagram is an `<img>` pointing at the PlantUML server.
|
|
27
|
+
|
|
28
|
+
```html
|
|
29
|
+
<figure class="rb-plantuml" data-plantuml data-plantuml-marker="..." data-plantuml-source="...">
|
|
30
|
+
<div class="rb-plantuml__frame">
|
|
31
|
+
<img class="rb-plantuml__image" src="https://www.plantuml.com/plantuml/svg/..." alt="..." loading="lazy" />
|
|
32
|
+
</div>
|
|
33
|
+
<details class="rb-plantuml__fallback">
|
|
34
|
+
<summary>Diagram source</summary>
|
|
35
|
+
<pre><code>...</code></pre>
|
|
36
|
+
</details>
|
|
37
|
+
<figcaption class="rb-plantuml__caption">...</figcaption>
|
|
38
|
+
</figure>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The caption comes from the code block `title` or from a `%% caption: ...` line in
|
|
42
|
+
the source. Because `%%` is not PlantUML comment syntax, the `%% caption:` line is
|
|
43
|
+
removed from the diagram source before it is encoded. When there is no caption,
|
|
44
|
+
the `<img>` alternative text is `PlantUML diagram`. With `fallback` enabled the
|
|
45
|
+
original PlantUML source is kept in a collapsible `<details>` element.
|
|
46
|
+
|
|
47
|
+
## URL encoding
|
|
48
|
+
|
|
49
|
+
The image URL is built at build time with PlantUML's *text encoding*:
|
|
50
|
+
|
|
51
|
+
1. Encode the source as UTF-8 bytes.
|
|
52
|
+
2. Compress them with raw DEFLATE (RFC 1951 — no zlib header or Adler-32).
|
|
53
|
+
3. Re-encode the bytes with PlantUML's custom base64 variant (alphabet
|
|
54
|
+
`0-9A-Za-z-_`, packing 3 bytes into four 6-bit characters).
|
|
55
|
+
|
|
56
|
+
The algorithm lives in `src/plantuml-encoder.ts`. It loads `node:zlib` through a
|
|
57
|
+
dynamic `import` so a client bundle never pulls in a Node builtin. Encoding is
|
|
58
|
+
fully build-time; no request is made to the PlantUML server.
|
|
59
|
+
|
|
60
|
+
## Options
|
|
61
|
+
|
|
62
|
+
| Option | Type | Default | Description |
|
|
63
|
+
| ------ | ---- | ------- | ----------- |
|
|
64
|
+
| `server` | `string` | `"https://www.plantuml.com/plantuml"` | Base URL of the PlantUML server. `http(s)` only |
|
|
65
|
+
| `format` | `"svg" \| "png"` | `"svg"` | Requested image format |
|
|
66
|
+
| `caption` | `boolean` | `true` | Show `title` / `%% caption:` as `figcaption` |
|
|
67
|
+
| `fallback` | `boolean` | `true` | Keep the diagram source in `<details>` |
|
|
68
|
+
|
|
69
|
+
## Output HTML / CSS
|
|
70
|
+
|
|
71
|
+
The plugin ships `style.css` and emits stable class names: `rb-plantuml`,
|
|
72
|
+
`rb-plantuml__frame`, `rb-plantuml__image`, `rb-plantuml__caption`, and
|
|
73
|
+
`rb-plantuml__fallback`. Styling follows the `--rb-color-*` custom properties
|
|
74
|
+
when present and switches to dark colors under `html[data-theme="dark"]` /
|
|
75
|
+
`html.dark`.
|
|
76
|
+
|
|
77
|
+
## Diagnostics
|
|
78
|
+
|
|
79
|
+
Encoding failures are reported with `file.message(...)`. Diagnostics use
|
|
80
|
+
`source: "@riebeckite/plugin-plantuml"` and `ruleId` either `encoder-error`
|
|
81
|
+
(encoding failed) or `empty-source` (no diagram source).
|
|
82
|
+
|
|
83
|
+
## Limitations
|
|
84
|
+
|
|
85
|
+
- The configured PlantUML server must be reachable when a reader views the
|
|
86
|
+
page. Offline readers see no diagram.
|
|
87
|
+
- To self-host, point `server` at your own PlantUML base URL.
|
|
88
|
+
- Because the build never contacts the server, diagram syntax is not validated
|
|
89
|
+
at build time.
|
|
90
|
+
|
|
91
|
+
## Exports
|
|
92
|
+
|
|
93
|
+
- `plantuml(options?)` — plugin factory
|
|
94
|
+
- `plantumlPlugin` — alias of `plantuml`
|
|
95
|
+
- Types: `PlantumlOptions`, `PlantumlFormat`
|
|
96
|
+
|
|
97
|
+
## See also
|
|
98
|
+
|
|
99
|
+
- [Plugin guide](../../docs/plugins_en.md)
|
package/README_ja.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# @riebeckite/plugin-plantuml
|
|
2
|
+
|
|
3
|
+
`plantuml` コードブロックを PlantUML の図として表示するプラグインです。ビルド時に PlantUML サーバーの画像 URL を組み立てるだけで、ビルド中にネットワークへアクセスしません。クライアント用の JavaScript も配布しません。
|
|
4
|
+
|
|
5
|
+
[English](./README.md)
|
|
6
|
+
|
|
7
|
+
## 設定する
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { defineConfig } from "@riebeckite/core";
|
|
11
|
+
import { plantuml } from "@riebeckite/plugin-plantuml";
|
|
12
|
+
|
|
13
|
+
export default defineConfig({
|
|
14
|
+
// ...
|
|
15
|
+
plugins: [plantuml()],
|
|
16
|
+
});
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`plantuml` は `plantumlPlugin` という別名でもエクスポートしています。
|
|
20
|
+
|
|
21
|
+
## どのように描画されるか
|
|
22
|
+
|
|
23
|
+
` ```plantuml ` のコードブロックは `figure.rb-plantuml` に置き換わります。図そのものは `<img>` で、PlantUML サーバーが返す画像を指します。
|
|
24
|
+
|
|
25
|
+
```html
|
|
26
|
+
<figure class="rb-plantuml" data-plantuml data-plantuml-marker="..." data-plantuml-source="...">
|
|
27
|
+
<div class="rb-plantuml__frame">
|
|
28
|
+
<img class="rb-plantuml__image" src="https://www.plantuml.com/plantuml/svg/..." alt="..." loading="lazy" />
|
|
29
|
+
</div>
|
|
30
|
+
<details class="rb-plantuml__fallback">
|
|
31
|
+
<summary>Diagram source</summary>
|
|
32
|
+
<pre><code>...</code></pre>
|
|
33
|
+
</details>
|
|
34
|
+
<figcaption class="rb-plantuml__caption">...</figcaption>
|
|
35
|
+
</figure>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
キャプションはコードブロックの `title`、またはソース中の `%% caption: ...` 行から取得します。`%%` は PlantUML のコメント記法ではないため、`%% caption:` 行は図のソースから取り除いてからエンコードします。キャプションがない場合、`<img>` の代替テキストは `PlantUML diagram` になります。`fallback` を有効にすると、元の PlantUML ソースを折りたたみ表示で残します。
|
|
39
|
+
|
|
40
|
+
## URL のエンコード
|
|
41
|
+
|
|
42
|
+
画像 URL は `text encoding` を使ってビルド時に組み立てます。手順は次のとおりです。
|
|
43
|
+
|
|
44
|
+
1. ソースを UTF-8 のバイト列にする
|
|
45
|
+
2. raw DEFLATE(RFC 1951、zlib ヘッダーや Adler-32 を含まない)で圧縮する
|
|
46
|
+
3. PlantUML 独自の base64(アルファベット `0-9A-Za-z-_`、3 バイトを 6 ビットずつ 4 文字へ)で再エンコードする
|
|
47
|
+
|
|
48
|
+
この処理は `src/plantuml-encoder.ts` に実装しています。`node:zlib` は動的 `import` で読み込むため、クライアント向けのバンドルに Node 組み込みモジュールが混入しません。エンコードはビルド時に完結し、PlantUML サーバーへの問い合わせは行いません。
|
|
49
|
+
|
|
50
|
+
## オプション
|
|
51
|
+
|
|
52
|
+
| 項目 | 既定値 | 説明 |
|
|
53
|
+
| --- | --- | --- |
|
|
54
|
+
| `server` | `https://www.plantuml.com/plantuml` | 図を配信する PlantUML サーバーのベース URL。`http(s)` のみ |
|
|
55
|
+
| `format` | `"svg"` | 要求する画像形式。`"svg"` または `"png"` |
|
|
56
|
+
| `caption` | `true` | `title` または `%% caption:` をキャプションとして表示する |
|
|
57
|
+
| `fallback` | `true` | 元の PlantUML ソースを `<details>` に残す |
|
|
58
|
+
|
|
59
|
+
## 出力される HTML / CSS
|
|
60
|
+
|
|
61
|
+
プラグインは `style.css` を公開し、`rb-plantuml`、`rb-plantuml__frame`、`rb-plantuml__image`、`rb-plantuml__caption`、`rb-plantuml__fallback` という安定したクラス名で出力します。CSS 変数 `--rb-color-*` があればそれに追従し、`html[data-theme="dark"]` / `html.dark` で暗色に切り替わります。
|
|
62
|
+
|
|
63
|
+
## 診断
|
|
64
|
+
|
|
65
|
+
エンコードに失敗した場合は `file.message(...)` で診断を出します。診断の `source` は `@riebeckite/plugin-plantuml`、`ruleId` は `encoder-error`(エンコード失敗)または `empty-source`(空のソース)です。
|
|
66
|
+
|
|
67
|
+
## 制限
|
|
68
|
+
|
|
69
|
+
- 表示時に設定した PlantUML サーバーへ到達できる必要があります。オフラインの閲覧環境では図は表示されません
|
|
70
|
+
- 自前の PlantUML サーバーを使う場合は `server` にそのベース URL を指定してください
|
|
71
|
+
- ビルド時にサーバーへ問い合わせないため、構文が正しいかどうかはビルド時には判定しません
|
|
72
|
+
|
|
73
|
+
## 主なエクスポート
|
|
74
|
+
|
|
75
|
+
- `plantuml(options?)`: プラグインを作成する
|
|
76
|
+
- `plantumlPlugin`: `plantuml` の別名
|
|
77
|
+
- 型: `PlantumlOptions`、`PlantumlFormat`
|
|
78
|
+
|
|
79
|
+
## 関連資料
|
|
80
|
+
|
|
81
|
+
- [プラグインシステム](../../../docs/ja/plugin-system.md)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PlantumlOptions } from "./src/types.js";
|
|
2
|
+
export type { PlantumlFormat, PlantumlOptions } from "./src/types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Turns fenced `plantuml` code blocks into `<figure class="rb-plantuml">`
|
|
5
|
+
* elements whose `<img>` points at a PlantUML server URL. The URL is built at
|
|
6
|
+
* build time (UTF-8 → raw DEFLATE → PlantUML base64); no network access is
|
|
7
|
+
* required while building and no client bundle is shipped.
|
|
8
|
+
*/
|
|
9
|
+
export declare function plantuml(options?: PlantumlOptions): import("@riebeckite/core").RiebeckitePlugin<PlantumlOptions>;
|
|
10
|
+
export declare const plantumlPlugin: typeof plantuml;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __esm = (fn, res, err) => function __init() {
|
|
4
|
+
if (err) throw err[0];
|
|
5
|
+
try {
|
|
6
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
7
|
+
} catch (e) {
|
|
8
|
+
throw err = [e], e;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// src/hast.ts
|
|
17
|
+
function visitElements(node, visitor, parent, index) {
|
|
18
|
+
if (isElementNode(node)) visitor(node, parent, index);
|
|
19
|
+
for (const [childIndex, child] of [...getChildren(node)].entries()) {
|
|
20
|
+
visitElements(
|
|
21
|
+
child,
|
|
22
|
+
visitor,
|
|
23
|
+
hasChildren(node) ? node : parent,
|
|
24
|
+
childIndex
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function element(tagName, properties = {}, children = []) {
|
|
29
|
+
return { type: "element", tagName, properties, children };
|
|
30
|
+
}
|
|
31
|
+
function text(value) {
|
|
32
|
+
return { type: "text", value };
|
|
33
|
+
}
|
|
34
|
+
function getTextContent(node) {
|
|
35
|
+
if (node.type === "text" && "value" in node && typeof node.value === "string") {
|
|
36
|
+
return node.value;
|
|
37
|
+
}
|
|
38
|
+
return getChildren(node).map(getTextContent).join("");
|
|
39
|
+
}
|
|
40
|
+
function getStringProperty(node, key) {
|
|
41
|
+
const value = node.properties?.[key];
|
|
42
|
+
if (typeof value === "string") return value;
|
|
43
|
+
if (Array.isArray(value)) return value.join(" ");
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
function hasClass(node, className) {
|
|
47
|
+
const value = node.properties?.className;
|
|
48
|
+
const classes = Array.isArray(value) ? value.map(String) : typeof value === "string" ? value.split(/\s+/) : [];
|
|
49
|
+
return classes.includes(className);
|
|
50
|
+
}
|
|
51
|
+
function isElementNode(node) {
|
|
52
|
+
return node.type === "element";
|
|
53
|
+
}
|
|
54
|
+
function hasChildren(node) {
|
|
55
|
+
return Array.isArray(node.children);
|
|
56
|
+
}
|
|
57
|
+
function getChildren(node) {
|
|
58
|
+
const children = node.children;
|
|
59
|
+
return Array.isArray(children) ? children : [];
|
|
60
|
+
}
|
|
61
|
+
var init_hast = __esm({
|
|
62
|
+
"src/hast.ts"() {
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// src/plantuml-encoder.ts
|
|
67
|
+
var plantuml_encoder_exports = {};
|
|
68
|
+
__export(plantuml_encoder_exports, {
|
|
69
|
+
encodePlantuml: () => encodePlantuml,
|
|
70
|
+
encodePlantumlBase64: () => encodePlantumlBase64
|
|
71
|
+
});
|
|
72
|
+
async function encodePlantuml(source) {
|
|
73
|
+
const { deflateRawSync } = await import("node:zlib");
|
|
74
|
+
const utf8 = new TextEncoder().encode(source);
|
|
75
|
+
return encodePlantumlBase64(deflateRawSync(utf8));
|
|
76
|
+
}
|
|
77
|
+
function encodePlantumlBase64(bytes) {
|
|
78
|
+
let encoded = "";
|
|
79
|
+
for (let index = 0; index < bytes.length; index += 3) {
|
|
80
|
+
const b1 = bytes[index] ?? 0;
|
|
81
|
+
const b2 = bytes[index + 1] ?? 0;
|
|
82
|
+
const b3 = bytes[index + 2] ?? 0;
|
|
83
|
+
encoded += PLANTUML_ALPHABET[b1 >> 2];
|
|
84
|
+
encoded += PLANTUML_ALPHABET[(b1 & 3) << 4 | b2 >> 4];
|
|
85
|
+
encoded += PLANTUML_ALPHABET[(b2 & 15) << 2 | b3 >> 6];
|
|
86
|
+
encoded += PLANTUML_ALPHABET[b3 & 63];
|
|
87
|
+
}
|
|
88
|
+
return encoded;
|
|
89
|
+
}
|
|
90
|
+
var PLANTUML_ALPHABET;
|
|
91
|
+
var init_plantuml_encoder = __esm({
|
|
92
|
+
"src/plantuml-encoder.ts"() {
|
|
93
|
+
PLANTUML_ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_";
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// src/rehype.ts
|
|
98
|
+
var rehype_exports = {};
|
|
99
|
+
__export(rehype_exports, {
|
|
100
|
+
rehypePlantuml: () => rehypePlantuml
|
|
101
|
+
});
|
|
102
|
+
function rehypePlantuml(options = {}) {
|
|
103
|
+
const resolved = {
|
|
104
|
+
server: normalizeServer(options.server ?? DEFAULT_SERVER),
|
|
105
|
+
format: options.format ?? DEFAULT_FORMAT,
|
|
106
|
+
caption: options.caption !== false,
|
|
107
|
+
fallback: options.fallback !== false
|
|
108
|
+
};
|
|
109
|
+
return async (tree, file) => {
|
|
110
|
+
const replacements = [];
|
|
111
|
+
visitElements(tree, (node, parent, index) => {
|
|
112
|
+
if (!parent || index === void 0 || !isPlantumlCodeBlock(node)) return;
|
|
113
|
+
replacements.push(
|
|
114
|
+
replacePlantumlBlock(parent, index, node, file, resolved)
|
|
115
|
+
);
|
|
116
|
+
});
|
|
117
|
+
await Promise.all(replacements);
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
async function replacePlantumlBlock(parent, index, pre, file, options) {
|
|
121
|
+
const code = findDirectChild(pre, "code");
|
|
122
|
+
const raw = (code ? getTextContent(code) : getTextContent(pre)).trim();
|
|
123
|
+
const { caption, source } = options.caption ? resolveCaption(raw, pre, code) : { caption: null, source: raw };
|
|
124
|
+
const imageUrl = await buildImageUrl(source, options, file);
|
|
125
|
+
parent.children = parent.children ?? [];
|
|
126
|
+
parent.children[index] = buildFigure({
|
|
127
|
+
source,
|
|
128
|
+
caption,
|
|
129
|
+
imageUrl,
|
|
130
|
+
fallback: options.fallback
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
async function buildImageUrl(source, options, file) {
|
|
134
|
+
if (source.length === 0) {
|
|
135
|
+
reportPlantumlDiagnostic(
|
|
136
|
+
file,
|
|
137
|
+
"Empty PlantUML diagram source.",
|
|
138
|
+
"empty-source"
|
|
139
|
+
);
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
try {
|
|
143
|
+
const { encodePlantuml: encodePlantuml2 } = await Promise.resolve().then(() => (init_plantuml_encoder(), plantuml_encoder_exports));
|
|
144
|
+
const encoded = await encodePlantuml2(source);
|
|
145
|
+
return `${options.server}/${options.format}/${encoded}`;
|
|
146
|
+
} catch (error) {
|
|
147
|
+
const message = formatError(error);
|
|
148
|
+
reportPlantumlDiagnostic(
|
|
149
|
+
file,
|
|
150
|
+
`PlantUML encoding failed: ${message}`,
|
|
151
|
+
"encoder-error"
|
|
152
|
+
);
|
|
153
|
+
console.warn(`[plantuml] encoding failed: ${message}`);
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function buildFigure(input) {
|
|
158
|
+
const children = [];
|
|
159
|
+
children.push(
|
|
160
|
+
element(
|
|
161
|
+
"div",
|
|
162
|
+
{ className: "rb-plantuml__frame" },
|
|
163
|
+
input.imageUrl ? [
|
|
164
|
+
element("img", {
|
|
165
|
+
className: "rb-plantuml__image",
|
|
166
|
+
src: input.imageUrl,
|
|
167
|
+
alt: input.caption ?? "PlantUML diagram",
|
|
168
|
+
loading: "lazy"
|
|
169
|
+
})
|
|
170
|
+
] : []
|
|
171
|
+
)
|
|
172
|
+
);
|
|
173
|
+
if (input.fallback) {
|
|
174
|
+
children.push(
|
|
175
|
+
element("details", { className: "rb-plantuml__fallback" }, [
|
|
176
|
+
element("summary", {}, [text("Diagram source")]),
|
|
177
|
+
element("pre", {}, [element("code", {}, [text(input.source)])])
|
|
178
|
+
])
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
if (input.caption) {
|
|
182
|
+
children.push(
|
|
183
|
+
element("figcaption", { className: "rb-plantuml__caption" }, [
|
|
184
|
+
text(input.caption)
|
|
185
|
+
])
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
return element(
|
|
189
|
+
"figure",
|
|
190
|
+
{
|
|
191
|
+
className: "rb-plantuml",
|
|
192
|
+
dataPlantuml: true,
|
|
193
|
+
dataPlantumlMarker: FIGURE_MARKER,
|
|
194
|
+
dataPlantumlSource: input.source
|
|
195
|
+
},
|
|
196
|
+
children
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
function isPlantumlCodeBlock(node) {
|
|
200
|
+
if (node.tagName !== "pre") return false;
|
|
201
|
+
const code = findDirectChild(node, "code");
|
|
202
|
+
return Boolean(code && hasClass(code, "language-plantuml"));
|
|
203
|
+
}
|
|
204
|
+
function findDirectChild(node, tagName) {
|
|
205
|
+
return node.children?.find(
|
|
206
|
+
(child) => child.type === "element" && child.tagName === tagName
|
|
207
|
+
) ?? null;
|
|
208
|
+
}
|
|
209
|
+
function resolveCaption(source, pre, code) {
|
|
210
|
+
const title = getStringProperty(pre, "title") ?? getStringProperty(code ?? pre, "title");
|
|
211
|
+
if (title?.trim()) return { caption: title.trim(), source };
|
|
212
|
+
const match = source.match(CAPTION_PATTERN);
|
|
213
|
+
if (!match) return { caption: null, source };
|
|
214
|
+
return {
|
|
215
|
+
caption: match[1].trim() || null,
|
|
216
|
+
// `%%` is not PlantUML comment syntax, so the directive line is removed
|
|
217
|
+
// before the diagram is encoded to keep the source valid.
|
|
218
|
+
source: source.replace(CAPTION_PATTERN, "").trim()
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
function normalizeServer(server) {
|
|
222
|
+
return server.replace(/\/+$/, "");
|
|
223
|
+
}
|
|
224
|
+
function reportPlantumlDiagnostic(file, message, kind) {
|
|
225
|
+
const reporter = file?.message;
|
|
226
|
+
if (typeof reporter !== "function") return;
|
|
227
|
+
const diagnostic = reporter.call(file, message);
|
|
228
|
+
if (diagnostic && typeof diagnostic === "object") {
|
|
229
|
+
Object.assign(diagnostic, {
|
|
230
|
+
source: "@riebeckite/plugin-plantuml",
|
|
231
|
+
ruleId: kind
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function formatError(error) {
|
|
236
|
+
if (error instanceof Error) return error.message;
|
|
237
|
+
return String(error);
|
|
238
|
+
}
|
|
239
|
+
var DEFAULT_SERVER, DEFAULT_FORMAT, CAPTION_PATTERN, FIGURE_MARKER;
|
|
240
|
+
var init_rehype = __esm({
|
|
241
|
+
"src/rehype.ts"() {
|
|
242
|
+
init_hast();
|
|
243
|
+
DEFAULT_SERVER = "https://www.plantuml.com/plantuml";
|
|
244
|
+
DEFAULT_FORMAT = "svg";
|
|
245
|
+
CAPTION_PATTERN = /^%%\s*caption\s*:\s*(.+)$/im;
|
|
246
|
+
FIGURE_MARKER = "RIEBECKITE_EXTERNAL_PLANTUML_MARKER";
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
// index.ts
|
|
251
|
+
import {
|
|
252
|
+
createStyleAsset,
|
|
253
|
+
definePlugin
|
|
254
|
+
} from "@riebeckite/core";
|
|
255
|
+
function plantuml(options = {}) {
|
|
256
|
+
return definePlugin({
|
|
257
|
+
name: "plantuml",
|
|
258
|
+
options,
|
|
259
|
+
validateOptions: validatePlantumlOptions,
|
|
260
|
+
extendHtmlPipeline: (pipeline) => {
|
|
261
|
+
pipeline.use(rehypePlantumlLazy, options);
|
|
262
|
+
},
|
|
263
|
+
assets: [createStyleAsset("plantuml")]
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
var plantumlPlugin = plantuml;
|
|
267
|
+
function validatePlantumlOptions(options) {
|
|
268
|
+
if (!options) return [];
|
|
269
|
+
const issues = [];
|
|
270
|
+
if (options.server !== void 0 && !isHttpServer(options.server)) {
|
|
271
|
+
issues.push({
|
|
272
|
+
path: "server",
|
|
273
|
+
message: "Expected an absolute http(s) URL."
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
if (options.format !== void 0 && options.format !== "svg" && options.format !== "png") {
|
|
277
|
+
issues.push({ path: "format", message: 'Expected "svg" or "png".' });
|
|
278
|
+
}
|
|
279
|
+
for (const key of ["caption", "fallback"]) {
|
|
280
|
+
if (options[key] !== void 0 && typeof options[key] !== "boolean") {
|
|
281
|
+
issues.push({ path: key, message: "Expected a boolean." });
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return issues;
|
|
285
|
+
}
|
|
286
|
+
function isHttpServer(value) {
|
|
287
|
+
return typeof value === "string" && /^https?:\/\/.+/i.test(value.trim());
|
|
288
|
+
}
|
|
289
|
+
function rehypePlantumlLazy(options = {}) {
|
|
290
|
+
return async (tree, file) => {
|
|
291
|
+
const { rehypePlantuml: rehypePlantuml2 } = await Promise.resolve().then(() => (init_rehype(), rehype_exports));
|
|
292
|
+
const transformer = rehypePlantuml2(options);
|
|
293
|
+
await transformer(tree, file);
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
export {
|
|
297
|
+
plantuml,
|
|
298
|
+
plantumlPlugin
|
|
299
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ElementNode, HastNode, ParentNode, TextNode } from "./types.js";
|
|
2
|
+
export declare function visitElements(node: HastNode, visitor: (node: ElementNode, parent?: ParentNode, index?: number) => void, parent?: ParentNode, index?: number): void;
|
|
3
|
+
export declare function element(tagName: string, properties?: Record<string, unknown>, children?: HastNode[]): ElementNode;
|
|
4
|
+
export declare function text(value: string): TextNode;
|
|
5
|
+
export declare function getTextContent(node: HastNode): string;
|
|
6
|
+
export declare function getStringProperty(node: ElementNode, key: string): string | null;
|
|
7
|
+
export declare function hasClass(node: ElementNode, className: string): boolean;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PlantUML text encoding.
|
|
3
|
+
*
|
|
4
|
+
* `plantuml()` does not talk to a PlantUML server at build time. It only builds
|
|
5
|
+
* the image URL a browser can load later, using PlantUML's documented
|
|
6
|
+
* "text encoding" scheme:
|
|
7
|
+
*
|
|
8
|
+
* 1. Encode the diagram source to UTF-8 bytes.
|
|
9
|
+
* 2. Compress the bytes with raw DEFLATE (RFC 1951 — no zlib header or
|
|
10
|
+
* Adler-32 checksum), which is what `zlib.deflateRawSync` produces.
|
|
11
|
+
* 3. Re-encode the compressed bytes with PlantUML's custom base64 variant.
|
|
12
|
+
*
|
|
13
|
+
* PlantUML's base64 variant is *not* the standard RFC 4648 alphabet. It uses
|
|
14
|
+
* `0-9A-Za-z-_` (64 characters) and emits one 6-bit character per 6 bits with
|
|
15
|
+
* a most-significant-bit-first order. Compressed bytes are consumed in 3-byte
|
|
16
|
+
* groups that produce 4 characters:
|
|
17
|
+
*
|
|
18
|
+
* ```
|
|
19
|
+
* c1 = b1 >> 2
|
|
20
|
+
* c2 = ((b1 & 0x03) << 4) | (b2 >> 4)
|
|
21
|
+
* c3 = ((b2 & 0x0f) << 2) | (b3 >> 6)
|
|
22
|
+
* c4 = b3 & 0x3f
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* A trailing group that is shorter than 3 bytes is zero-padded, so no separate
|
|
26
|
+
* padding character is needed.
|
|
27
|
+
*
|
|
28
|
+
* `node:zlib` is imported dynamically so a bundler that statically walks the
|
|
29
|
+
* plugin graph never pulls a Node builtin into the client graph. The only
|
|
30
|
+
* caller is `src/rehype.ts`, which itself is imported lazily from `index.ts`
|
|
31
|
+
* and only runs during the build.
|
|
32
|
+
*/
|
|
33
|
+
/** Encodes PlantUML source into the server URL path segment. */
|
|
34
|
+
export declare function encodePlantuml(source: string): Promise<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Re-encodes raw DEFLATE bytes with PlantUML's custom base64 alphabet.
|
|
37
|
+
* Exposed separately from the compression step so it can be reasoned about
|
|
38
|
+
* (and tested) without a Node runtime.
|
|
39
|
+
*/
|
|
40
|
+
export declare function encodePlantumlBase64(bytes: Uint8Array): string;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export type PlantumlFormat = "svg" | "png";
|
|
2
|
+
export type PlantumlOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* Base URL of the PlantUML server used to render diagrams.
|
|
5
|
+
* Must be an `http(s)` URL so the generated `<img>` can load it.
|
|
6
|
+
* @default "https://www.plantuml.com/plantuml"
|
|
7
|
+
*/
|
|
8
|
+
server?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Output format requested from the PlantUML server.
|
|
11
|
+
* @default "svg"
|
|
12
|
+
*/
|
|
13
|
+
format?: PlantumlFormat;
|
|
14
|
+
/**
|
|
15
|
+
* Show the `%% caption:` line or code block title as a `figcaption`.
|
|
16
|
+
* @default true
|
|
17
|
+
*/
|
|
18
|
+
caption?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Keep the original diagram source in a `<details>` element.
|
|
21
|
+
* @default true
|
|
22
|
+
*/
|
|
23
|
+
fallback?: boolean;
|
|
24
|
+
};
|
|
25
|
+
export type PlantumlErrorKind = "empty-source" | "encoder-error";
|
|
26
|
+
export type ElementNode = {
|
|
27
|
+
type: string;
|
|
28
|
+
tagName?: string;
|
|
29
|
+
properties?: Record<string, unknown>;
|
|
30
|
+
children?: HastNode[];
|
|
31
|
+
};
|
|
32
|
+
export type ParentNode = HastNode & {
|
|
33
|
+
children?: HastNode[];
|
|
34
|
+
};
|
|
35
|
+
export type TextNode = {
|
|
36
|
+
type: "text";
|
|
37
|
+
value: string;
|
|
38
|
+
};
|
|
39
|
+
export type RawNode = {
|
|
40
|
+
type: "raw";
|
|
41
|
+
value: string;
|
|
42
|
+
};
|
|
43
|
+
export type HastNode = ElementNode | TextNode | RawNode | {
|
|
44
|
+
type: string;
|
|
45
|
+
[key: string]: unknown;
|
|
46
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@riebeckite/plugin-plantuml",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"source": "./index.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./style.css": "./style.css"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@riebeckite/core": "0.0.1"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"LICENSE",
|
|
25
|
+
"README.md",
|
|
26
|
+
"README_ja.md",
|
|
27
|
+
"dist",
|
|
28
|
+
"style.css"
|
|
29
|
+
],
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/Rerurate514/riebeckite.git",
|
|
33
|
+
"directory": "packages/plugins/plantuml"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://github.com/Rerurate514/riebeckite#readme",
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/Rerurate514/riebeckite/issues"
|
|
38
|
+
},
|
|
39
|
+
"description": "PlantUML diagram rendering for Riebeckite code blocks.",
|
|
40
|
+
"keywords": [
|
|
41
|
+
"riebeckite",
|
|
42
|
+
"plugin",
|
|
43
|
+
"plantuml",
|
|
44
|
+
"diagrams"
|
|
45
|
+
],
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
48
|
+
},
|
|
49
|
+
"sideEffects": [
|
|
50
|
+
"./style.css"
|
|
51
|
+
],
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "node ../../../scripts/build_package.mjs"
|
|
54
|
+
}
|
|
55
|
+
}
|
package/style.css
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
.rb-plantuml {
|
|
2
|
+
--rb-plantuml-ink: var(--rb-color-ink, #000000);
|
|
3
|
+
--rb-plantuml-paper: var(--rb-color-paper, #ffffff);
|
|
4
|
+
--rb-plantuml-muted: var(--rb-color-muted, #69645c);
|
|
5
|
+
--rb-plantuml-accent: var(--rb-color-accent, #686868);
|
|
6
|
+
--rb-plantuml-rule: var(
|
|
7
|
+
--rb-color-border,
|
|
8
|
+
color-mix(in srgb, var(--rb-plantuml-ink) 18%, transparent)
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
align-items: center;
|
|
14
|
+
gap: 0.75rem;
|
|
15
|
+
margin: 2rem 0;
|
|
16
|
+
padding: 1rem;
|
|
17
|
+
border: 1px solid var(--rb-plantuml-rule);
|
|
18
|
+
background: color-mix(
|
|
19
|
+
in srgb,
|
|
20
|
+
var(--rb-plantuml-paper) 96%,
|
|
21
|
+
var(--rb-plantuml-ink)
|
|
22
|
+
);
|
|
23
|
+
color: var(--rb-plantuml-ink);
|
|
24
|
+
text-align: center;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.rb-plantuml__frame {
|
|
28
|
+
overflow: auto;
|
|
29
|
+
max-width: 100%;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.rb-plantuml__image {
|
|
33
|
+
display: block;
|
|
34
|
+
max-width: 100%;
|
|
35
|
+
height: auto;
|
|
36
|
+
margin: 0 auto;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.rb-plantuml__caption {
|
|
40
|
+
color: var(--rb-plantuml-muted);
|
|
41
|
+
font-size: 0.875rem;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.rb-plantuml__fallback {
|
|
45
|
+
align-self: stretch;
|
|
46
|
+
border-top: 1px solid var(--rb-plantuml-rule);
|
|
47
|
+
color: var(--rb-plantuml-muted);
|
|
48
|
+
font-size: 0.8125rem;
|
|
49
|
+
text-align: left;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.rb-plantuml__fallback summary {
|
|
53
|
+
cursor: pointer;
|
|
54
|
+
padding: 0.5rem 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.rb-plantuml__fallback pre {
|
|
58
|
+
overflow: auto;
|
|
59
|
+
margin: 0;
|
|
60
|
+
padding: 0.75rem;
|
|
61
|
+
border-top: 1px solid var(--rb-plantuml-rule);
|
|
62
|
+
color: var(--rb-plantuml-ink);
|
|
63
|
+
background: color-mix(in srgb, var(--rb-plantuml-ink) 6%, transparent);
|
|
64
|
+
text-align: left;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.rb-plantuml__frame:empty::before {
|
|
68
|
+
content: "Diagram could not be rendered.";
|
|
69
|
+
color: var(--rb-plantuml-muted);
|
|
70
|
+
font-size: 0.875rem;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
html[data-theme="dark"] .rb-plantuml,
|
|
74
|
+
html.dark .rb-plantuml {
|
|
75
|
+
--rb-plantuml-ink: var(--rb-color-paper, #ffffff);
|
|
76
|
+
--rb-plantuml-paper: var(--rb-color-ink, #000000);
|
|
77
|
+
}
|