@riebeckite/plugin-markmap 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 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,140 @@
1
+ # @riebeckite/plugin-markmap
2
+
3
+ Renders ` ```markmap ` code blocks as Markdown-heading mindmaps. The mindmap is
4
+ drawn in the browser by `markmap-lib` + `markmap-view`, which are imported from
5
+ the CDN only when a figure is present.
6
+
7
+ [Japanese](./README_ja.md)
8
+
9
+ ## Configure
10
+
11
+ ```ts
12
+ import { defineConfig } from "@riebeckite/core";
13
+ import { markmap } from "@riebeckite/plugin-markmap";
14
+
15
+ export default defineConfig({
16
+ // ...
17
+ plugins: [
18
+ markmap({
19
+ caption: true,
20
+ height: 320,
21
+ fallback: true,
22
+ }),
23
+ ],
24
+ });
25
+ ```
26
+
27
+ The plugin runs with `order: -10`.
28
+
29
+ ## Syntax
30
+
31
+ The block body is ordinary Markdown: headings become nodes and their nesting
32
+ becomes the tree. Content other than headings is ignored.
33
+
34
+ ````markdown
35
+ ```markmap
36
+ # Project
37
+
38
+ ## Design
39
+
40
+ ### Notation
41
+ ### Rendering
42
+
43
+ ## Delivery
44
+ ```
45
+ ````
46
+
47
+ The caption comes from the code-block `title`.
48
+
49
+ ## How it renders
50
+
51
+ A ` ```markmap ` block becomes a `figure.rb-markmap`:
52
+
53
+ - `figure.rb-markmap`: carries `data-markmap="pending"`,
54
+ `data-markmap-source` (the raw Markdown) and `data-markmap-height`
55
+ - `div.rb-markmap__canvas`: the element the SVG is rendered into
56
+ (`role="img"`)
57
+ - `figcaption.rb-markmap__caption`: the caption (enabled by default)
58
+ - `details.rb-markmap__fallback`: the raw Markdown, folded away
59
+
60
+ `initMarkmap` finds every `[data-markmap="pending"]`, loads the runtime, runs
61
+ `markmap-lib`'s `Transformer` over `data-markmap-source`, and renders the
62
+ resulting tree with `markmap-view`'s `Markmap.create`. On success the figure
63
+ becomes `data-markmap="rendered"`.
64
+
65
+ If loading the runtime, transforming the source, or rendering fails, the
66
+ initializer does not throw: it opens that figure's `details` and marks it
67
+ `data-markmap="error"`.
68
+
69
+ A block whose body has no Markdown heading is left as a normal code block, and a
70
+ diagnostic with `source: "@riebeckite/plugin-markmap"` is emitted.
71
+
72
+ ## Options
73
+
74
+ | Option | Default | Description |
75
+ | --- | --- | --- |
76
+ | `caption` | `true` | Show the code-block `title` as a caption |
77
+ | `height` | `320` | Canvas height in pixels |
78
+ | `className` | `"rb-markmap"` | Base class applied to the figure |
79
+ | `language` | `"markmap"` | Fenced-code language to recognize |
80
+ | `fallback` | `true` | Render the `<details>` block with the raw Markdown |
81
+ | `colorFreezeLevel` | — | Depth at which node colours are frozen |
82
+
83
+ ## Client rendering
84
+
85
+ The client initializer is static and receives no plugin options. `height` and
86
+ `colorFreezeLevel` are embedded into the figure's `data-markmap-*` attributes,
87
+ and `initMarkmap` reads them from there.
88
+
89
+ `markmap-lib` and `markmap-view` are fetched from jsDelivr with a computed
90
+ import specifier, so they are never bundled into the host's client bundle.
91
+ `markmap-view` pulls `d3` in as its own dependency. Because the libraries are
92
+ loaded lazily, the page still renders (with the fallback `details`) when
93
+ JavaScript is disabled.
94
+
95
+ ## The input-notation seam
96
+
97
+ The code-block body is turned into a mindmap tree by a single, pure function in
98
+ `src/parse.ts`:
99
+
100
+ ```ts
101
+ parseMarkmapSource(source: string): MarkmapNode | null
102
+ ```
103
+
104
+ `MarkmapNode` is the notation-neutral tree (`{ content, children, payload? }`).
105
+ Only the standard Markdown-heading notation is implemented today. A future
106
+ alternative notation (for example an "ExcaliMindMap"-style outline) is added by
107
+ implementing another parser that produces the same `MarkmapNode` shape; the
108
+ figure emission and the render path do not parse the notation themselves, so
109
+ they stay unchanged. `parseMarkmapSource` is exported from the package entry
110
+ point for that purpose.
111
+
112
+ ## Output hooks
113
+
114
+ - `figure[data-markmap]`: state (`pending` / `rendered` / `error`)
115
+ - `figure[data-markmap-source]`: the raw Markdown
116
+ - `figure[data-markmap-height]`, `figure[data-markmap-color-freeze-level]`
117
+ - `[data-markmap-canvas]`: the render target
118
+ - `details.rb-markmap__fallback`: the raw Markdown
119
+
120
+ ## Main exports
121
+
122
+ - `markmap(options?)`: create the plugin (`markmapPlugin` is an alias)
123
+ - `initMarkmap`: initialize client-side rendering
124
+ - `parseMarkmapSource`: parse the standard notation into a tree
125
+ - `describeMarkmapTree`: derive an accessible label from a tree
126
+ - Types: `MarkmapOptions`, `MarkmapNode`, `MarkmapClientOptions`
127
+
128
+ ## Limitations
129
+
130
+ - Rendering is client-only. Nothing is rendered at build time, so mindmaps are
131
+ not visible without JavaScript (the source remains in the fallback `details`)
132
+ - The client fetches `markmap-lib`, `markmap-view`, and their CDN sub-modules on
133
+ first use, so the first render waits on the network
134
+ - Not every Markdown extension is supported by the standard notation; the
135
+ parser recognises ATX (`#`) headings and ignores fenced code blocks
136
+ - `markmap-lib` and `markmap-view` are MIT licensed
137
+
138
+ ## See also
139
+
140
+ - [Plugin system](../../../docs/en/plugin-system.md)
package/README_ja.md ADDED
@@ -0,0 +1,113 @@
1
+ # @riebeckite/plugin-markmap
2
+
3
+ ` ```markmap ` コードブロックを、Markdown の見出しから組み立てるマインドマップとして表示するプラグインです。マインドマップはブラウザ側で `markmap-lib` と `markmap-view` により描画し、これらのライブラリは図があるときだけ CDN から読み込みます。
4
+
5
+ [English](./README.md)
6
+
7
+ ## 設定する
8
+
9
+ ```ts
10
+ import { defineConfig } from "@riebeckite/core";
11
+ import { markmap } from "@riebeckite/plugin-markmap";
12
+
13
+ export default defineConfig({
14
+ // ...
15
+ plugins: [
16
+ markmap({
17
+ caption: true,
18
+ height: 320,
19
+ fallback: true,
20
+ }),
21
+ ],
22
+ });
23
+ ```
24
+
25
+ このプラグインは `order: -10` で実行されます。
26
+
27
+ ## 記法
28
+
29
+ コードブロックの本文は通常の Markdown です。見出しがノードになり、見出しの階層が木構造になります。見出し以外の内容は無視します。
30
+
31
+ ````markdown
32
+ ```markmap
33
+ # プロジェクト
34
+
35
+ ## 設計
36
+
37
+ ### 記法
38
+ ### 描画
39
+
40
+ ## リリース
41
+ ```
42
+ ````
43
+
44
+ キャプションにはコードブロックの `title` を使います。
45
+
46
+ ## どのように描画されるか
47
+
48
+ ` ```markmap ` のコードブロックは `figure.rb-markmap` に置き換わります。
49
+
50
+ - `figure.rb-markmap`: `data-markmap="pending"`、`data-markmap-source`(元の Markdown)、`data-markmap-height` を持ちます
51
+ - `div.rb-markmap__canvas`: SVG を描画する領域(`role="img"`)
52
+ - `figcaption.rb-markmap__caption`: キャプション(既定で有効)
53
+ - `details.rb-markmap__fallback`: 元の Markdown を折りたたんで表示
54
+
55
+ `initMarkmap` は `[data-markmap="pending"]` を探し、ランタイムを読み込んでから `markmap-lib` の `Transformer` を `data-markmap-source` に適用し、得られた木を `markmap-view` の `Markmap.create` で描画します。描画に成功すると `data-markmap="rendered"` になります。
56
+
57
+ ランタイムの読み込み、ソースの変換、描画のいずれかが失敗した場合は例外を投げず、その figure の `details` を開いて元の Markdown を見せます(`data-markmap="error"`)。
58
+
59
+ Markdown の見出しを 1 つも含まないコードブロックは置き換えず、通常のコードブロックのまま残し、`source: "@riebeckite/plugin-markmap"` を持つ診断を出します。
60
+
61
+ ## オプション
62
+
63
+ | 項目 | 既定値 | 説明 |
64
+ | --- | --- | --- |
65
+ | `caption` | `true` | コードブロックの `title` をキャプションとして表示する |
66
+ | `height` | `320` | キャンバスの高さ(ピクセル) |
67
+ | `className` | `"rb-markmap"` | figure に付ける基準クラス |
68
+ | `language` | `"markmap"` | 対象にするコードブロックの言語 |
69
+ | `fallback` | `true` | 元の Markdown を表示する `details` を描画する |
70
+ | `colorFreezeLevel` | — | ノードの色を固定する深さ |
71
+
72
+ ## クライアント側の描画
73
+
74
+ クライアントの初期化コードは静的なので、プラグインのオプションは受け取りません。`height` と `colorFreezeLevel` は figure の `data-markmap-*` 属性に埋め込まれ、`initMarkmap` がそこから読み取ります。
75
+
76
+ `markmap-lib` と `markmap-view` は計算された import 指定子で jsDelivr から取得するため、ホストのクライアントバンドルには含まれません。`markmap-view` は依存として `d3` を読み込みます。ライブラリを遅延して読み込むので、JavaScript を無効にしていてもページは表示され、元の Markdown はフォールバックの `details` から読めます。
77
+
78
+ ## 入力記法の継ぎ目(notation seam)
79
+
80
+ コードブロックの本文は、`src/parse.ts` にある単一の純粋関数でマインドマップの木に変換します。
81
+
82
+ ```ts
83
+ parseMarkmapSource(source: string): MarkmapNode | null
84
+ ```
85
+
86
+ `MarkmapNode` は記法に依存しない木(`{ content, children, payload? }`)です。現在は標準の Markdown 見出し記法だけを実装しています。将来別の入力記法(たとえば "ExcaliMindMap" 風のアウトライン)を追加するときは、同じ `MarkmapNode` を返すパーサーを実装するだけです。figure の生成と描画の経路は記法を解析しないため、変更する必要はありません。`parseMarkmapSource` はそのためにパッケージのエントリーポイントから公開しています。
87
+
88
+ ## 出力のフック
89
+
90
+ - `figure[data-markmap]`: 状態(`pending` / `rendered` / `error`)
91
+ - `figure[data-markmap-source]`: 元の Markdown
92
+ - `figure[data-markmap-height]`、`figure[data-markmap-color-freeze-level]`
93
+ - `[data-markmap-canvas]`: 描画先の要素
94
+ - `details.rb-markmap__fallback`: 元の Markdown
95
+
96
+ ## 主なエクスポート
97
+
98
+ - `markmap(options?)`: プラグインを作成する(`markmapPlugin` は別名)
99
+ - `initMarkmap`: クライアント側の描画を初期化する
100
+ - `parseMarkmapSource`: 標準記法を木に変換する
101
+ - `describeMarkmapTree`: 木からアクセシブルなラベルを作る
102
+ - 型: `MarkmapOptions`、`MarkmapNode`、`MarkmapClientOptions`
103
+
104
+ ## 制限
105
+
106
+ - 描画はクライアント側のみです。ビルド時に何も生成しないため、JavaScript が無効な環境ではマインドマップは表示されません(元の Markdown はフォールバックの `details` に残ります)
107
+ - クライアントは初回描画時に `markmap-lib`、`markmap-view` とその CDN サブモジュールを取得するため、最初の描画はネットワーク待ちになります
108
+ - 標準記法が対応する Markdown 拡張は限られます。パーサーは ATX(`#`)見出しを認識し、コードフェンス内は無視します
109
+ - `markmap-lib` と `markmap-view` は MIT ライセンスです
110
+
111
+ ## 関連資料
112
+
113
+ - [プラグインシステム](../../../docs/ja/plugin-system.md)
@@ -0,0 +1,2 @@
1
+ export { initMarkmap } from "./src/init.js";
2
+ export type { MarkmapAssets, MarkmapClientOptions, MarkmapNode, MarkmapPureNode, MarkmapRuntime, MarkmapTransformer, MarkmapTransformResult, } from "./src/types.js";
package/dist/client.js ADDED
@@ -0,0 +1,118 @@
1
+ // src/init.ts
2
+ var DEFAULT_CLASS_NAME = "rb-markmap";
3
+ var SVG_NAMESPACE = "http://www.w3.org/2000/svg";
4
+ var DEFAULT_LIB_URL = "https://cdn.jsdelivr.net/npm/markmap-lib@0.18.12/+esm";
5
+ var DEFAULT_VIEW_URL = "https://cdn.jsdelivr.net/npm/markmap-view@0.18.12/+esm";
6
+ async function initMarkmap(options = {}) {
7
+ const baseClass = options.className?.trim() || DEFAULT_CLASS_NAME;
8
+ const figures = Array.from(
9
+ document.querySelectorAll('[data-markmap="pending"]')
10
+ );
11
+ if (figures.length === 0) return;
12
+ const runtime = await loadRuntime(options);
13
+ if (!runtime) {
14
+ for (const figure of figures) setError(figure);
15
+ return;
16
+ }
17
+ for (const figure of figures) {
18
+ await renderFigure(runtime, figure, baseClass);
19
+ }
20
+ }
21
+ async function renderFigure(runtime, figure, baseClass) {
22
+ const canvas = figure.querySelector(
23
+ `[data-markmap-canvas], .${baseClass}__canvas`
24
+ );
25
+ const source = figure.dataset.markmapSource;
26
+ if (!canvas || !source) {
27
+ setError(figure);
28
+ return;
29
+ }
30
+ try {
31
+ const transformer = new runtime.Transformer();
32
+ const result = transformer.transform(source);
33
+ await loadAssets(runtime, transformer.getUsedAssets(result.features));
34
+ const svg = ensureSvg(canvas, baseClass, figure.dataset.markmapHeight);
35
+ const markmapOptions = buildOptions(
36
+ runtime,
37
+ figure.dataset.markmapColorFreezeLevel,
38
+ result.frontmatter?.markmap
39
+ );
40
+ runtime.Markmap.create(svg, markmapOptions, result.root);
41
+ figure.dataset.markmap = "rendered";
42
+ } catch {
43
+ setError(figure);
44
+ }
45
+ }
46
+ function ensureSvg(canvas, baseClass, height) {
47
+ const existing = canvas.querySelector("svg");
48
+ if (existing) return existing;
49
+ const svg = document.createElementNS(SVG_NAMESPACE, "svg");
50
+ svg.setAttribute("class", `${baseClass}__svg`);
51
+ svg.setAttribute("width", "100%");
52
+ svg.setAttribute("height", height && Number(height) > 0 ? height : "320");
53
+ svg.setAttribute("role", "presentation");
54
+ canvas.append(svg);
55
+ return svg;
56
+ }
57
+ function buildOptions(runtime, colorFreezeLevel, frontmatterOptions) {
58
+ const json = { ...frontmatterOptions ?? {} };
59
+ const freeze = readNumber(colorFreezeLevel);
60
+ if (freeze !== void 0) json.colorFreezeLevel = freeze;
61
+ return runtime.deriveOptions ? runtime.deriveOptions(json) : json;
62
+ }
63
+ async function loadAssets(runtime, assets) {
64
+ const tasks = [];
65
+ if (runtime.loadJS && assets.scripts?.length) {
66
+ tasks.push(runtime.loadJS(assets.scripts));
67
+ }
68
+ if (runtime.loadCSS && assets.styles?.length) {
69
+ tasks.push(runtime.loadCSS(assets.styles));
70
+ }
71
+ await Promise.all(tasks).catch(() => void 0);
72
+ }
73
+ async function loadRuntime(options) {
74
+ if (options.runtime) return options.runtime;
75
+ try {
76
+ const [lib, view] = await Promise.all([
77
+ importModule(options.libUrl ?? DEFAULT_LIB_URL),
78
+ importModule(options.viewUrl ?? DEFAULT_VIEW_URL)
79
+ ]);
80
+ const Transformer = readExport(lib, "Transformer");
81
+ const Markmap = readExport(view, "Markmap");
82
+ if (typeof Transformer !== "function" || !Markmap) return null;
83
+ return {
84
+ Transformer,
85
+ Markmap,
86
+ deriveOptions: readExport(view, "deriveOptions"),
87
+ loadJS: readExport(view, "loadJS"),
88
+ loadCSS: readExport(view, "loadCSS")
89
+ };
90
+ } catch {
91
+ return null;
92
+ }
93
+ }
94
+ function importModule(url) {
95
+ const importer = new Function(
96
+ "url",
97
+ "return import(url)"
98
+ );
99
+ return importer(url);
100
+ }
101
+ function readExport(module, name) {
102
+ if (name in module) return module[name];
103
+ const fallback = module.default;
104
+ return fallback?.[name];
105
+ }
106
+ function readNumber(value) {
107
+ if (value === void 0) return void 0;
108
+ const parsed = Number(value);
109
+ return Number.isFinite(parsed) ? parsed : void 0;
110
+ }
111
+ function setError(figure) {
112
+ figure.dataset.markmap = "error";
113
+ const fallback = figure.querySelector("details");
114
+ if (fallback) fallback.open = true;
115
+ }
116
+ export {
117
+ initMarkmap
118
+ };
@@ -0,0 +1,12 @@
1
+ import type { MarkmapOptions } from "./src/types.js";
2
+ export { resolveMarkmapOptions } from "./src/options.js";
3
+ export { describeMarkmapTree, parseMarkmapSource } from "./src/parse.js";
4
+ export type { MarkmapClientOptions, MarkmapNode, MarkmapOptions, MarkmapResolvedOptions, } from "./src/types.js";
5
+ /**
6
+ * Renders fenced `markmap` code blocks as Markdown-heading mindmaps. The mindmap
7
+ * is drawn in the browser by `initMarkmap`, which imports `markmap-lib` and
8
+ * `markmap-view` from the CDN only when a figure is present.
9
+ */
10
+ export declare function markmap(options?: MarkmapOptions): import("@riebeckite/core").RiebeckitePlugin<MarkmapOptions>;
11
+ /** Alias kept for symmetry with the other plugin factories. */
12
+ export declare const markmapPlugin: typeof markmap;
package/dist/index.js ADDED
@@ -0,0 +1,264 @@
1
+ // index.ts
2
+ import {
3
+ createClientEntry,
4
+ createStyleAsset,
5
+ definePlugin
6
+ } from "@riebeckite/core";
7
+
8
+ // src/options.ts
9
+ var DEFAULT_MARKMAP_CLASS_NAME = "rb-markmap";
10
+ var DEFAULT_MARKMAP_HEIGHT = 320;
11
+ var DEFAULT_MARKMAP_LANGUAGE = "markmap";
12
+ function resolveMarkmapOptions(options = {}) {
13
+ return {
14
+ caption: options.caption !== false,
15
+ height: normalizeHeight(options.height),
16
+ className: options.className?.trim() || DEFAULT_MARKMAP_CLASS_NAME,
17
+ language: options.language?.trim() || DEFAULT_MARKMAP_LANGUAGE,
18
+ fallback: options.fallback !== false,
19
+ colorFreezeLevel: normalizeColorFreezeLevel(options.colorFreezeLevel)
20
+ };
21
+ }
22
+ function normalizeHeight(height) {
23
+ return typeof height === "number" && Number.isFinite(height) && height > 0 ? height : DEFAULT_MARKMAP_HEIGHT;
24
+ }
25
+ function normalizeColorFreezeLevel(level) {
26
+ return typeof level === "number" && Number.isInteger(level) && level >= 0 ? level : null;
27
+ }
28
+
29
+ // src/parse.ts
30
+ var ATX_HEADING = /^ {0,3}(#{1,6})(?:[ \t]+(.*?))?[ \t]*#*[ \t]*$/;
31
+ var CODE_FENCE = /^ {0,3}(`{3,}|~{3,})/;
32
+ function parseMarkmapSource(source) {
33
+ const roots = [];
34
+ const stack = [];
35
+ let fence = null;
36
+ for (const line of source.split(/\r?\n/)) {
37
+ const fenceMatch = CODE_FENCE.exec(line);
38
+ if (fenceMatch) {
39
+ const marker = fenceMatch[1][0];
40
+ if (fence === null) fence = marker;
41
+ else if (fence === marker) fence = null;
42
+ continue;
43
+ }
44
+ if (fence !== null) continue;
45
+ const heading = ATX_HEADING.exec(line);
46
+ if (!heading) continue;
47
+ const level = heading[1].length;
48
+ const node = {
49
+ content: (heading[2] ?? "").trim(),
50
+ children: []
51
+ };
52
+ while (stack.length > 0 && stack[stack.length - 1].level >= level) {
53
+ stack.pop();
54
+ }
55
+ const parent = stack[stack.length - 1];
56
+ if (parent) parent.node.children.push(node);
57
+ else roots.push(node);
58
+ stack.push({ level, node });
59
+ }
60
+ if (roots.length === 0) return null;
61
+ if (roots.length === 1) return roots[0];
62
+ return { content: "", children: roots };
63
+ }
64
+ function describeMarkmapTree(tree) {
65
+ if (!tree) return "";
66
+ if (tree.content.trim() !== "") return tree.content.trim();
67
+ for (const child of tree.children) {
68
+ const label = describeMarkmapTree(child);
69
+ if (label !== "") return label;
70
+ }
71
+ return "";
72
+ }
73
+
74
+ // src/rehype.ts
75
+ var DIAGNOSTIC_SOURCE = "@riebeckite/plugin-markmap";
76
+ function rehypeMarkmap(options = {}) {
77
+ const resolved = resolveMarkmapOptions(options);
78
+ return (tree, file) => {
79
+ visitElements(tree, (node, parent, index) => {
80
+ if (!parent || index === void 0) return;
81
+ if (!isMarkmapCodeBlock(node, resolved.language)) return;
82
+ replaceMarkmapBlock(parent, index, node, file, resolved);
83
+ });
84
+ };
85
+ }
86
+ function replaceMarkmapBlock(parent, index, pre, file, options) {
87
+ const code = findDirectChild(pre, "code");
88
+ const source = code ? getTextContent(code).trim() : getTextContent(pre).trim();
89
+ const tree = parseMarkmapSource(source);
90
+ if (tree === null) {
91
+ reportDiagnostic(file, "Expected at least one Markdown heading.");
92
+ return;
93
+ }
94
+ const caption = options.caption ? extractCaption(pre, code) : null;
95
+ const label = caption ?? describeMarkmapTree(tree);
96
+ parent.children = parent.children ?? [];
97
+ parent.children[index] = buildFigure({
98
+ className: options.className,
99
+ source,
100
+ caption,
101
+ label: label || "Mind map",
102
+ height: options.height,
103
+ fallback: options.fallback,
104
+ colorFreezeLevel: options.colorFreezeLevel
105
+ });
106
+ }
107
+ function buildFigure(input) {
108
+ const base = input.className;
109
+ const labelId = `${base}-caption`;
110
+ const children = [
111
+ element(
112
+ "div",
113
+ {
114
+ className: `${base}__canvas`,
115
+ dataMarkmapCanvas: "true",
116
+ role: "img",
117
+ ariaLabelledby: input.caption ? labelId : void 0,
118
+ ariaLabel: input.caption ? void 0 : input.label
119
+ },
120
+ []
121
+ )
122
+ ];
123
+ if (input.caption) {
124
+ children.push(
125
+ element("figcaption", { id: labelId, className: `${base}__caption` }, [
126
+ text(input.caption)
127
+ ])
128
+ );
129
+ }
130
+ if (input.fallback) {
131
+ children.push(
132
+ element("details", { className: `${base}__fallback` }, [
133
+ element("summary", {}, [text("Markdown source")]),
134
+ element("pre", {}, [element("code", {}, [text(input.source)])])
135
+ ])
136
+ );
137
+ }
138
+ return element(
139
+ "figure",
140
+ {
141
+ className: base,
142
+ dataMarkmap: "pending",
143
+ dataMarkmapSource: input.source,
144
+ dataMarkmapHeight: String(input.height),
145
+ dataMarkmapColorFreezeLevel: input.colorFreezeLevel === null ? void 0 : String(input.colorFreezeLevel)
146
+ },
147
+ children
148
+ );
149
+ }
150
+ function extractCaption(pre, code) {
151
+ const title = getStringProperty(pre, "title") ?? (code ? getStringProperty(code, "title") : null);
152
+ return title?.trim() || null;
153
+ }
154
+ function isMarkmapCodeBlock(node, language) {
155
+ if (node.tagName !== "pre") return false;
156
+ const code = findDirectChild(node, "code");
157
+ return Boolean(code && hasClass(code, `language-${language}`));
158
+ }
159
+ function findDirectChild(node, tagName) {
160
+ return node.children?.find(
161
+ (child) => child.type === "element" && child.tagName === tagName
162
+ ) ?? null;
163
+ }
164
+ function reportDiagnostic(file, message) {
165
+ const reporter = file?.message;
166
+ if (typeof reporter !== "function") return;
167
+ const diagnostic = reporter.call(
168
+ file,
169
+ `Invalid Markmap source: ${message}`
170
+ );
171
+ if (diagnostic && typeof diagnostic === "object") {
172
+ Object.assign(diagnostic, {
173
+ source: DIAGNOSTIC_SOURCE,
174
+ ruleId: "invalid-source"
175
+ });
176
+ }
177
+ }
178
+ function visitElements(node, visitor, parent, index) {
179
+ if (isElementNode(node)) visitor(node, parent, index);
180
+ for (const [childIndex, child] of [...getChildren(node)].entries()) {
181
+ visitElements(child, visitor, hasChildren(node) ? node : parent, childIndex);
182
+ }
183
+ }
184
+ function element(tagName, properties = {}, children = []) {
185
+ return { type: "element", tagName, properties, children };
186
+ }
187
+ function text(value) {
188
+ return { type: "text", value };
189
+ }
190
+ function getTextContent(node) {
191
+ if (node.type === "text" && "value" in node && typeof node.value === "string") {
192
+ return node.value;
193
+ }
194
+ return getChildren(node).map(getTextContent).join("");
195
+ }
196
+ function getStringProperty(node, key) {
197
+ const value = node.properties?.[key];
198
+ if (typeof value === "string") return value;
199
+ if (Array.isArray(value)) return value.join(" ");
200
+ return null;
201
+ }
202
+ function hasClass(node, className) {
203
+ const value = node.properties?.className;
204
+ const classes = Array.isArray(value) ? value.map(String) : typeof value === "string" ? value.split(/\s+/) : [];
205
+ return classes.includes(className);
206
+ }
207
+ function isElementNode(node) {
208
+ return node.type === "element";
209
+ }
210
+ function hasChildren(node) {
211
+ return Array.isArray(node.children);
212
+ }
213
+ function getChildren(node) {
214
+ const children = node.children;
215
+ return Array.isArray(children) ? children : [];
216
+ }
217
+
218
+ // index.ts
219
+ function markmap(options = {}) {
220
+ return definePlugin({
221
+ name: "markmap",
222
+ order: -10,
223
+ options,
224
+ validateOptions: validateMarkmapOptions,
225
+ extendHtmlPipeline: (pipeline) => {
226
+ pipeline.use(rehypeMarkmap, options);
227
+ },
228
+ assets: [createStyleAsset("markmap")],
229
+ clientEntries: [createClientEntry("markmap", "initMarkmap")]
230
+ });
231
+ }
232
+ var markmapPlugin = markmap;
233
+ function validateMarkmapOptions(options) {
234
+ if (!options) return [];
235
+ const issues = [];
236
+ for (const key of ["caption", "fallback"]) {
237
+ if (options[key] !== void 0 && typeof options[key] !== "boolean") {
238
+ issues.push({ path: key, message: "Expected a boolean." });
239
+ }
240
+ }
241
+ for (const key of ["className", "language"]) {
242
+ const value = options[key];
243
+ if (value !== void 0 && (typeof value !== "string" || value.trim() === "")) {
244
+ issues.push({ path: key, message: "Expected a non-empty string." });
245
+ }
246
+ }
247
+ if (options.height !== void 0 && (typeof options.height !== "number" || !Number.isFinite(options.height) || options.height <= 0)) {
248
+ issues.push({ path: "height", message: "Expected a positive number." });
249
+ }
250
+ if (options.colorFreezeLevel !== void 0 && (!Number.isInteger(options.colorFreezeLevel) || options.colorFreezeLevel < 0)) {
251
+ issues.push({
252
+ path: "colorFreezeLevel",
253
+ message: "Expected a non-negative integer."
254
+ });
255
+ }
256
+ return issues;
257
+ }
258
+ export {
259
+ describeMarkmapTree,
260
+ markmap,
261
+ markmapPlugin,
262
+ parseMarkmapSource,
263
+ resolveMarkmapOptions
264
+ };
@@ -0,0 +1,9 @@
1
+ import type { MarkmapClientOptions } from "./types.js";
2
+ /**
3
+ * Renders every server-emitted `[data-markmap="pending"]` figure in the
4
+ * browser.
5
+ *
6
+ * The Markdown source travels in `data-markmap-source`, so the page still
7
+ * renders (with the fallback `<details>`) when JavaScript is disabled.
8
+ */
9
+ export declare function initMarkmap(options?: MarkmapClientOptions): Promise<void>;
@@ -0,0 +1,14 @@
1
+ import type { MarkmapOptions, MarkmapResolvedOptions } from "./types.js";
2
+ /** Default base class for the generated figure. */
3
+ export declare const DEFAULT_MARKMAP_CLASS_NAME = "rb-markmap";
4
+ /** Default canvas height in pixels. */
5
+ export declare const DEFAULT_MARKMAP_HEIGHT = 320;
6
+ /** Default fenced-code language. */
7
+ export declare const DEFAULT_MARKMAP_LANGUAGE = "markmap";
8
+ /**
9
+ * Applies defaults to the user-provided options.
10
+ *
11
+ * Shared by the plugin factory (for metadata/validation) and the rehype
12
+ * transformer (for figure emission), so both agree on a single resolution.
13
+ */
14
+ export declare function resolveMarkmapOptions(options?: MarkmapOptions): MarkmapResolvedOptions;
@@ -0,0 +1,21 @@
1
+ import type { MarkmapNode } from "./types.js";
2
+ /**
3
+ * Parses a fenced code block body written in the standard Markmap
4
+ * Markdown-heading notation into a mindmap tree.
5
+ *
6
+ * This is the **input-notation seam** of the plugin: every supported notation
7
+ * produces the same `MarkmapNode` shape, so a future alternative notation (for
8
+ * example an "ExcaliMindMap"-style outline) only has to add another parser
9
+ * here instead of touching the figure/render path. See the READMEs for the
10
+ * documented contract.
11
+ *
12
+ * Returns `null` when the source contains no heading at all, which the rehype
13
+ * transformer reports as an invalid block. Content inside fenced code blocks is
14
+ * ignored, mirroring Markdown parsing.
15
+ */
16
+ export declare function parseMarkmapSource(source: string): MarkmapNode | null;
17
+ /**
18
+ * Returns a human-readable label for a parsed tree, used as a fallback
19
+ * accessible name for the rendered canvas.
20
+ */
21
+ export declare function describeMarkmapTree(tree: MarkmapNode | null): string;
@@ -0,0 +1,7 @@
1
+ import type { HastNode, MarkmapOptions } from "./types.js";
2
+ /**
3
+ * Replaces every fenced `markmap` code block with a figure that carries the
4
+ * raw Markdown in `data-markmap-source`. The mindmap itself is drawn in the
5
+ * browser by `initMarkmap`.
6
+ */
7
+ export declare function rehypeMarkmap(options?: MarkmapOptions): (tree: HastNode, file: unknown) => void;
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Public types for the Markmap plugin.
3
+ *
4
+ * This module is imported by the build-time transformer, the browser
5
+ * initializer, and the package entry point, so it must stay free of Node-only
6
+ * imports.
7
+ */
8
+ /** A node in the notation-neutral mindmap tree. */
9
+ export type MarkmapNode = {
10
+ /** Raw (Markdown) content of the node. */
11
+ content: string;
12
+ /** Child nodes, in document order. */
13
+ children: MarkmapNode[];
14
+ /** Extra data reserved for alternative input notations. */
15
+ payload?: Record<string, unknown>;
16
+ };
17
+ /**
18
+ * Options accepted by the `markmap` plugin factory.
19
+ *
20
+ * Note that client initializers are static, so the resolved values are
21
+ * forwarded to the browser through `data-markmap-*` attributes.
22
+ */
23
+ export type MarkmapOptions = {
24
+ /** Render the code-block title as a `<figcaption>`. Defaults to `true`. */
25
+ caption?: boolean;
26
+ /** Canvas height in pixels. Defaults to `320`. */
27
+ height?: number;
28
+ /** Base CSS class applied to the figure. Defaults to `"rb-markmap"`. */
29
+ className?: string;
30
+ /** Fenced-code language to recognize. Defaults to `"markmap"`. */
31
+ language?: string;
32
+ /** Render a `<details>` block holding the raw Markdown. Defaults to `true`. */
33
+ fallback?: boolean;
34
+ /**
35
+ * Depth at which node colours are frozen, forwarded to `markmap-view`.
36
+ * Omission keeps the `markmap-view` default.
37
+ */
38
+ colorFreezeLevel?: number;
39
+ };
40
+ /** Options after defaults have been applied. */
41
+ export type MarkmapResolvedOptions = {
42
+ caption: boolean;
43
+ height: number;
44
+ className: string;
45
+ language: string;
46
+ fallback: boolean;
47
+ colorFreezeLevel: number | null;
48
+ };
49
+ /** Options accepted by `initMarkmap` when called programmatically. */
50
+ export type MarkmapClientOptions = {
51
+ /** Base class used to find figures. Defaults to `"rb-markmap"`. */
52
+ className?: string;
53
+ /** ESM URL of `markmap-lib`. Defaults to the pinned jsDelivr build. */
54
+ libUrl?: string;
55
+ /** ESM URL of `markmap-view`. Defaults to the pinned jsDelivr build. */
56
+ viewUrl?: string;
57
+ /** Preloaded runtime, used to skip the CDN import. */
58
+ runtime?: MarkmapRuntime;
59
+ };
60
+ /** The subset of `markmap-common`'s `IPureNode` the renderer relies on. */
61
+ export type MarkmapPureNode = {
62
+ content: string;
63
+ children: MarkmapPureNode[];
64
+ payload?: Record<string, unknown>;
65
+ };
66
+ /** Result of `markmap-lib`'s `Transformer#transform`. */
67
+ export type MarkmapTransformResult = {
68
+ root: MarkmapPureNode;
69
+ features: Record<string, boolean>;
70
+ frontmatter?: {
71
+ markmap?: Record<string, unknown>;
72
+ };
73
+ };
74
+ /** Assets reported by `markmap-lib` for a set of used features. */
75
+ export type MarkmapAssets = {
76
+ styles?: unknown[];
77
+ scripts?: unknown[];
78
+ };
79
+ /** The `markmap-lib` surface the initializer uses. */
80
+ export type MarkmapTransformer = {
81
+ transform(source: string): MarkmapTransformResult;
82
+ getUsedAssets(features: Record<string, boolean>): MarkmapAssets;
83
+ };
84
+ /** The `markmap-view` surface the initializer uses. */
85
+ export type MarkmapRuntime = {
86
+ Transformer: new () => MarkmapTransformer;
87
+ Markmap: {
88
+ create(svg: SVGElement, options: Record<string, unknown>, root: MarkmapPureNode): unknown;
89
+ };
90
+ deriveOptions?: (options: Record<string, unknown>) => Record<string, unknown>;
91
+ loadJS?: (items: unknown[]) => Promise<void>;
92
+ loadCSS?: (items: unknown[]) => Promise<void>;
93
+ };
94
+ export type ElementNode = {
95
+ type: string;
96
+ tagName?: string;
97
+ properties?: Record<string, unknown>;
98
+ children?: HastNode[];
99
+ };
100
+ export type ParentNode = HastNode & {
101
+ children?: HastNode[];
102
+ };
103
+ export type TextNode = {
104
+ type: "text";
105
+ value: string;
106
+ };
107
+ export type RawNode = {
108
+ type: "raw";
109
+ value: string;
110
+ };
111
+ export type HastNode = ElementNode | TextNode | RawNode | {
112
+ type: string;
113
+ [key: string]: unknown;
114
+ };
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@riebeckite/plugin-markmap",
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
+ "./client": {
16
+ "types": "./dist/client.d.ts",
17
+ "import": "./dist/client.js",
18
+ "source": "./client.ts",
19
+ "default": "./dist/client.js"
20
+ },
21
+ "./style.css": "./style.css"
22
+ },
23
+ "dependencies": {
24
+ "markmap-lib": "^0.18.12",
25
+ "markmap-view": "^0.18.12",
26
+ "@riebeckite/core": "0.0.1"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "files": [
32
+ "LICENSE",
33
+ "README.md",
34
+ "README_ja.md",
35
+ "dist",
36
+ "style.css"
37
+ ],
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "https://github.com/Rerurate514/riebeckite.git",
41
+ "directory": "packages/plugins/markmap"
42
+ },
43
+ "homepage": "https://github.com/Rerurate514/riebeckite#readme",
44
+ "bugs": {
45
+ "url": "https://github.com/Rerurate514/riebeckite/issues"
46
+ },
47
+ "description": "Markdown mindmap rendering with Markmap for Riebeckite.",
48
+ "keywords": [
49
+ "riebeckite",
50
+ "plugin",
51
+ "markmap",
52
+ "mindmap"
53
+ ],
54
+ "engines": {
55
+ "node": "^20.19.0 || >=22.12.0"
56
+ },
57
+ "sideEffects": [
58
+ "./style.css"
59
+ ],
60
+ "scripts": {
61
+ "build": "node ../../../scripts/build_package.mjs"
62
+ }
63
+ }
package/style.css ADDED
@@ -0,0 +1,67 @@
1
+ .rb-markmap {
2
+ --rb-markmap-paper: var(--rb-color-paper, #ffffff);
3
+ --rb-markmap-ink: var(--rb-color-ink, #000000);
4
+ --rb-markmap-muted: var(--rb-color-muted, #69645c);
5
+ --rb-markmap-rule: var(
6
+ --rb-color-border,
7
+ color-mix(in srgb, var(--rb-markmap-ink) 18%, transparent)
8
+ );
9
+ margin: 2rem 0;
10
+ border: 1px solid var(--rb-markmap-rule);
11
+ background: color-mix(
12
+ in srgb,
13
+ var(--rb-markmap-paper) 96%,
14
+ var(--rb-markmap-ink)
15
+ );
16
+ color: var(--rb-markmap-ink);
17
+ }
18
+
19
+ .rb-markmap__caption {
20
+ padding: 0.625rem 0.75rem;
21
+ border-bottom: 1px solid var(--rb-markmap-rule);
22
+ color: var(--rb-markmap-muted);
23
+ font-size: 0.875rem;
24
+ }
25
+
26
+ .rb-markmap__canvas {
27
+ overflow: auto;
28
+ padding: 1rem;
29
+ }
30
+
31
+ .rb-markmap__canvas > .rb-markmap__svg,
32
+ .rb-markmap__canvas > svg {
33
+ display: block;
34
+ max-width: 100%;
35
+ }
36
+
37
+ .rb-markmap__fallback {
38
+ border-top: 1px solid var(--rb-markmap-rule);
39
+ color: var(--rb-markmap-muted);
40
+ font-size: 0.8125rem;
41
+ }
42
+
43
+ .rb-markmap__fallback summary {
44
+ cursor: pointer;
45
+ padding: 0.5rem 0.75rem;
46
+ }
47
+
48
+ .rb-markmap__fallback pre {
49
+ overflow: auto;
50
+ margin: 0 1rem;
51
+ padding: 0.75rem;
52
+ border-top: 1px solid var(--rb-markmap-rule);
53
+ color: var(--rb-markmap-ink);
54
+ background: color-mix(in srgb, var(--rb-markmap-ink) 6%, transparent);
55
+ }
56
+
57
+ .rb-markmap[data-markmap="error"] .rb-markmap__canvas:empty::before,
58
+ .rb-markmap[data-markmap="pending"] .rb-markmap__canvas:empty::before {
59
+ content: "Mind map could not be rendered.";
60
+ color: var(--rb-markmap-muted);
61
+ }
62
+
63
+ html[data-theme="dark"] .rb-markmap,
64
+ html.dark .rb-markmap {
65
+ --rb-markmap-paper: var(--rb-color-ink, #000000);
66
+ --rb-markmap-ink: var(--rb-color-paper, #ffffff);
67
+ }