@riebeckite/plugin-kanban 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,116 @@
1
+ # @riebeckite/plugin-kanban
2
+
3
+ Render Obsidian Kanban boards as static HTML at build time. No client-side
4
+ JavaScript is required.
5
+
6
+ [日本語](./README_ja.md)
7
+
8
+ ## Overview
9
+
10
+ `kanban()` turns kanban markdown into a board. It accepts two kinds of input:
11
+
12
+ - The body of a ` ```kanban ` fenced code block.
13
+ - A whole note whose frontmatter contains `kanban-plugin` (enabled by
14
+ `autoDetect`, on by default).
15
+
16
+ Columns are lines that start with `## ` (configurable with `columnMarker`).
17
+ Every list item that follows becomes a card: `- [ ] text` (unchecked),
18
+ `- [x] text` (checked), or a plain `- text` item.
19
+
20
+ Card text supports inline `[[wikilinks]]` (resolved to real hrefs from the
21
+ content manifest), `#tags`, and simple `**bold**` emphasis.
22
+
23
+ ## Usage
24
+
25
+ ```ts
26
+ import { defineConfig } from "@riebeckite/core";
27
+ import { kanban } from "@riebeckite/plugin-kanban";
28
+
29
+ export default defineConfig({
30
+ // ...
31
+ plugins: [kanban()],
32
+ });
33
+ ```
34
+
35
+ ## Board syntax
36
+
37
+ ````md
38
+ ## Backlog
39
+
40
+ - [ ] Draft the release notes
41
+ - [ ] Link to [[index]]
42
+ - [x] Review **metadata**
43
+
44
+ ## Done
45
+
46
+ - [x] Publish the fixture
47
+ ````
48
+
49
+ A note that is itself a board looks the same, with the board written directly
50
+ in the body and `kanban-plugin` set in the frontmatter:
51
+
52
+ ```md
53
+ ---
54
+ title: Roadmap
55
+ kanban-plugin: board
56
+ ---
57
+
58
+ ## Planned
59
+
60
+ - [ ] Ship the plugin
61
+ ```
62
+
63
+ ## Output
64
+
65
+ ```html
66
+ <div class="rb-kanban" data-kanban data-kanban-plugin data-kanban-source="note">
67
+ <div class="rb-kanban__board" data-kanban-board>
68
+ <div class="rb-kanban__column" data-column="Backlog">
69
+ <header class="rb-kanban__column-title">Backlog</header>
70
+ <ul class="rb-kanban__cards">
71
+ <li class="rb-kanban__card" data-checked="false">
72
+ <span class="rb-kanban__checkbox" data-checked="false" aria-hidden="true"></span>
73
+ <span class="rb-kanban__card-text">Draft the release notes</span>
74
+ </li>
75
+ </ul>
76
+ </div>
77
+ </div>
78
+ </div>
79
+ ```
80
+
81
+ `data-kanban-source` is `"block"` for a fenced block and `"note"` for an
82
+ auto-detected note.
83
+
84
+ ## Options
85
+
86
+ | Option | Type | Default | Description |
87
+ | --- | --- | --- | --- |
88
+ | `className` | `string` | `"rb-kanban"` | Root CSS class; block names derive from it |
89
+ | `language` | `string` | `"kanban"` | Fence language to target |
90
+ | `columnMarker` | `string` | `"##"` | Prefix that starts a column |
91
+ | `autoDetect` | `boolean` | `true` | Render notes with `kanban-plugin` frontmatter |
92
+ | `fallback` | `boolean` | `true` | Keep unsupported lines in a `<details>` fallback |
93
+
94
+ ## Fallback and diagnostics
95
+
96
+ Lines that are neither a column nor a list item are kept verbatim inside
97
+ `details.rb-kanban__fallback` when `fallback` is enabled, so nothing is lost.
98
+
99
+ Parse problems (for example a block with no columns) are attached to the
100
+ document with a `@riebeckite/plugin-kanban` message.
101
+
102
+ ## Exports
103
+
104
+ - `kanban(options?)` — plugin factory
105
+ - `kanbanPlugin` — alias of `kanban`
106
+ - `resolveKanbanOptions(options?)` — apply defaults
107
+ - `remarkKanban(options?)` — remark transform used by the plugin
108
+ - `parseKanban(source, options)`, `renderKanban(result, options, resolveLink, source)`
109
+ - `stripFrontmatter(markdown)`, `isKanbanNote(frontmatter)`
110
+ - `createKanbanLinkResolver(manifest)`, `createKanbanPlaceholder(source)`
111
+ - Types: `KanbanOptions`, `ResolvedKanbanOptions`, `KanbanCard`, `KanbanColumn`,
112
+ `KanbanParseResult`, `KanbanLinkResolver`, `RemarkKanbanOptions`
113
+
114
+ ## See also
115
+
116
+ - [Plugin guide](../../../docs/en/plugin-system.md)
package/README_ja.md ADDED
@@ -0,0 +1,106 @@
1
+ # @riebeckite/plugin-kanban
2
+
3
+ Obsidian の Kanban ボードを、ビルド時に静的 HTML へ変換するプラグインです。クライアント側の JavaScript は不要です。
4
+
5
+ [English](./README.md)
6
+
7
+ ## 使い方
8
+
9
+ `kanban()` をプラグインに追加します。
10
+
11
+ ```ts
12
+ import { defineConfig } from "@riebeckite/core";
13
+ import { kanban } from "@riebeckite/plugin-kanban";
14
+
15
+ export default defineConfig({
16
+ // ...
17
+ plugins: [kanban()],
18
+ });
19
+ ```
20
+
21
+ ## ボードの書き方
22
+
23
+ 入力は次の2通りです。
24
+
25
+ - ` ```kanban ` のフェンスコードブロックの本文
26
+ - フロントマターに `kanban-plugin` を持つノートの本文(`autoDetect`、既定で有効)
27
+
28
+ どちらも本文の書き方は同じです。`## `(`columnMarker` で変更可)で始まる行が列を区切り、その後に続くリスト項目がカードになります。カードは `- [ ]`(未完了)、`- [x]`(完了)、`- テキスト`(チェックボックスなし)をそのまま扱います。
29
+
30
+ ````md
31
+ ## Backlog
32
+
33
+ - [ ] リリースノートの下書き
34
+ - [ ] [[index]] へのリンクを張る
35
+ - [x] **メタデータ**を確認する
36
+
37
+ ## Done
38
+
39
+ - [x] フィクスチャを公開する
40
+ ````
41
+
42
+ ノート全体をボードにする場合は、本文に同じ内容を書き、フロントマターに `kanban-plugin` を追加します。
43
+
44
+ ```md
45
+ ---
46
+ title: Roadmap
47
+ kanban-plugin: board
48
+ ---
49
+
50
+ ## Planned
51
+
52
+ - [ ] プラグインを公開する
53
+ ```
54
+
55
+ カードのテキストでは `[[ウィキリンク]]`(マニフェストから実際の href に解決)、`#タグ`、`**太字**` を使えます。
56
+
57
+ ## 出力
58
+
59
+ ```html
60
+ <div class="rb-kanban" data-kanban data-kanban-plugin data-kanban-source="note">
61
+ <div class="rb-kanban__board" data-kanban-board>
62
+ <div class="rb-kanban__column" data-column="Backlog">
63
+ <header class="rb-kanban__column-title">Backlog</header>
64
+ <ul class="rb-kanban__cards">
65
+ <li class="rb-kanban__card" data-checked="false">
66
+ <span class="rb-kanban__checkbox" data-checked="false" aria-hidden="true"></span>
67
+ <span class="rb-kanban__card-text">リリースノートの下書き</span>
68
+ </li>
69
+ </ul>
70
+ </div>
71
+ </div>
72
+ </div>
73
+ ```
74
+
75
+ `data-kanban-source` は、フェンスブロックなら `"block"`、自動検出したノートなら `"note"` です。
76
+
77
+ ## オプション
78
+
79
+ | オプション | 型 | 既定値 | 内容 |
80
+ | --- | --- | --- | --- |
81
+ | `className` | `string` | `"rb-kanban"` | ルートの CSS クラス。各要素のクラス名はこれを基に組み立てる |
82
+ | `language` | `string` | `"kanban"` | 対象のフェンス言語 |
83
+ | `columnMarker` | `string` | `"##"` | 列の始まりを示す接頭辞 |
84
+ | `autoDetect` | `boolean` | `true` | `kanban-plugin` を持つノートをボードとして描画する |
85
+ | `fallback` | `boolean` | `true` | 解釈できなかった行を `<details>` に残す |
86
+
87
+ ## フォールバックと診断
88
+
89
+ 列でもリスト項目でもない行は、`fallback` を切らない限り `details.rb-kanban__fallback` にそのまま残ります。取りこぼしはありません。
90
+
91
+ 列が1つもないなど解析に問題がある場合は、`@riebeckite/plugin-kanban` を発行元とするメッセージを文書に付与します。
92
+
93
+ ## エクスポート
94
+
95
+ - `kanban(options?)` — プラグインファクトリ
96
+ - `kanbanPlugin` — `kanban` の別名
97
+ - `resolveKanbanOptions(options?)` — 既定値を適用する
98
+ - `remarkKanban(options?)` — プラグインが使う Remark 変換
99
+ - `parseKanban(source, options)` と `renderKanban(result, options, resolveLink, source)`
100
+ - `stripFrontmatter(markdown)` と `isKanbanNote(frontmatter)`
101
+ - `createKanbanLinkResolver(manifest)` と `createKanbanPlaceholder(source)`
102
+ - 型: `KanbanOptions`、`ResolvedKanbanOptions`、`KanbanCard`、`KanbanColumn`、`KanbanParseResult`、`KanbanLinkResolver`、`RemarkKanbanOptions`
103
+
104
+ ## 関連資料
105
+
106
+ - [プラグインガイド](../../../docs/ja/plugin-system.md)
@@ -0,0 +1,12 @@
1
+ import { type KanbanOptions } from "./src/types.js";
2
+ export { isKanbanNote, parseKanban, stripFrontmatter } from "./src/parse.js";
3
+ export type { KanbanCard, KanbanColumn, KanbanParseResult, } from "./src/parse.js";
4
+ export { KANBAN_ATTRIBUTE, createKanbanPlaceholder, createKanbanPlaceholderPattern, decodeKanbanSource, encodeKanbanSource, } from "./src/placeholder.js";
5
+ export { createKanbanLinkResolver, renderKanban } from "./src/render.js";
6
+ export type { KanbanLink, KanbanLinkResolver, KanbanSource, } from "./src/render.js";
7
+ export { remarkKanban } from "./src/remark.js";
8
+ export type { RemarkKanbanOptions } from "./src/remark.js";
9
+ export { resolveKanbanOptions } from "./src/types.js";
10
+ export type { KanbanOptions, ResolvedKanbanOptions } from "./src/types.js";
11
+ export declare function kanban(options?: KanbanOptions): import("@riebeckite/core").RiebeckitePlugin<KanbanOptions>;
12
+ export declare const kanbanPlugin: typeof kanban;
package/dist/index.js ADDED
@@ -0,0 +1,329 @@
1
+ // index.ts
2
+ import {
3
+ createStyleAsset,
4
+ definePlugin
5
+ } from "@riebeckite/core";
6
+
7
+ // src/remark.ts
8
+ import { visit } from "unist-util-visit";
9
+
10
+ // src/parse.ts
11
+ var LIST_ITEM = /^\s*[-*+]\s+(.*)$/;
12
+ var TASK_MARKER = /^\[([ xX])\]\s*(.*)$/;
13
+ function parseKanban(source, options) {
14
+ const columns = [];
15
+ const fallback = [];
16
+ const problems = [];
17
+ const heading = new RegExp(
18
+ `^\\s*${escapeRegExp(options.columnMarker)}\\s+(.+?)\\s*$`
19
+ );
20
+ let current = null;
21
+ for (const rawLine of source.replace(/\r\n?/g, "\n").split("\n")) {
22
+ const line = rawLine.replace(/\s+$/, "");
23
+ if (line.trim() === "") continue;
24
+ const columnName = line.match(heading)?.[1]?.trim();
25
+ if (columnName) {
26
+ current = { name: columnName, cards: [] };
27
+ columns.push(current);
28
+ continue;
29
+ }
30
+ const item = line.match(LIST_ITEM)?.[1]?.trim();
31
+ if (item !== void 0) {
32
+ if (item === "") {
33
+ fallback.push(line);
34
+ continue;
35
+ }
36
+ const card = parseCard(item);
37
+ if (current) {
38
+ current.cards.push(card);
39
+ } else {
40
+ fallback.push(line);
41
+ problems.push(
42
+ "A card appeared before the first column and was kept in the fallback."
43
+ );
44
+ }
45
+ continue;
46
+ }
47
+ fallback.push(line);
48
+ }
49
+ if (columns.length === 0) {
50
+ problems.push(
51
+ `No columns were found (expected a line starting with "${options.columnMarker} ").`
52
+ );
53
+ }
54
+ return { columns, fallback, problems };
55
+ }
56
+ function isKanbanNote(frontmatter) {
57
+ return typeof frontmatter === "object" && frontmatter !== null && Object.hasOwn(frontmatter, "kanban-plugin");
58
+ }
59
+ function stripFrontmatter(markdown) {
60
+ return markdown.replace(
61
+ /^\uFEFF?(?:---|\+\+\+)\r?\n[\s\S]*?\r?\n(?:---|\+\+\+)[ \t]*\r?\n?/,
62
+ ""
63
+ );
64
+ }
65
+ function parseCard(text) {
66
+ const task = text.match(TASK_MARKER);
67
+ if (task) {
68
+ return {
69
+ checked: task[1]?.toLowerCase() === "x",
70
+ text: (task[2] ?? "").trim()
71
+ };
72
+ }
73
+ return { checked: false, text: text.trim() };
74
+ }
75
+ function escapeRegExp(value) {
76
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
77
+ }
78
+
79
+ // src/placeholder.ts
80
+ var KANBAN_ATTRIBUTE = "data-rr-kanban";
81
+ function encodeKanbanSource(source) {
82
+ return encodeURIComponent(source);
83
+ }
84
+ function decodeKanbanSource(encoded) {
85
+ return decodeURIComponent(encoded);
86
+ }
87
+ function createKanbanPlaceholder(source) {
88
+ return `<div ${KANBAN_ATTRIBUTE}="${encodeKanbanSource(source)}"></div>`;
89
+ }
90
+ function createKanbanPlaceholderPattern() {
91
+ return new RegExp(
92
+ `<div\\b[^>]*\\b${KANBAN_ATTRIBUTE}="([^"]*)"[^>]*>\\s*</div>`,
93
+ "g"
94
+ );
95
+ }
96
+
97
+ // src/types.ts
98
+ function resolveKanbanOptions(options = {}) {
99
+ return {
100
+ className: options.className?.trim() || "rb-kanban",
101
+ language: options.language?.trim() || "kanban",
102
+ columnMarker: options.columnMarker?.trim() || "##",
103
+ autoDetect: options.autoDetect ?? true,
104
+ fallback: options.fallback ?? true
105
+ };
106
+ }
107
+
108
+ // src/remark.ts
109
+ function remarkKanban(options = {}) {
110
+ const resolved = resolveKanbanOptions(options);
111
+ return (tree, file) => {
112
+ if (resolved.autoDetect && isKanbanNote(readMatter(file))) {
113
+ reportProblems(file, "note", parseKanban(readBody(file), resolved));
114
+ }
115
+ visit(tree, "code", (node, index, parent) => {
116
+ if (node.lang !== resolved.language) return;
117
+ if (!parent || index === void 0) return;
118
+ reportProblems(file, "block", parseKanban(node.value, resolved));
119
+ const html = {
120
+ type: "html",
121
+ value: createKanbanPlaceholder(node.value)
122
+ };
123
+ parent.children.splice(index, 1, html);
124
+ });
125
+ };
126
+ }
127
+ function reportProblems(file, scope, result) {
128
+ if (result.problems.length === 0) return;
129
+ const reporter = file?.message;
130
+ if (typeof reporter !== "function") return;
131
+ for (const problem of result.problems) {
132
+ const diagnostic = reporter.call(file, `Kanban ${scope}: ${problem}`);
133
+ if (diagnostic && typeof diagnostic === "object") {
134
+ Object.assign(diagnostic, {
135
+ source: "@riebeckite/plugin-kanban",
136
+ ruleId: "kanban-parse"
137
+ });
138
+ }
139
+ }
140
+ }
141
+ function readMatter(file) {
142
+ return file?.data?.matter;
143
+ }
144
+ function readBody(file) {
145
+ const value = file?.value;
146
+ return typeof value === "string" ? stripFrontmatter(value) : "";
147
+ }
148
+
149
+ // src/render.ts
150
+ import { escapeHtml, escapeHtmlAttribute } from "@riebeckite/core";
151
+ var WIKILINK = /\[\[([^\]|#]+)(?:#([^\]|]+))?(?:\|([^\]]+))?\]\]/g;
152
+ var TAG = /(^|[\s(])#([A-Za-z0-9_\-/]+)/g;
153
+ var BOLD = /\*\*([^*]+)\*\*/g;
154
+ function createKanbanLinkResolver(manifest) {
155
+ return (target) => {
156
+ const label = target.trim();
157
+ if (!label) return null;
158
+ const slug = manifest.contentIndex.get(label.toLowerCase());
159
+ if (!slug) return null;
160
+ const entry = manifest.bySlug.get(slug);
161
+ if (!entry) return null;
162
+ return { href: entry.permalink, label };
163
+ };
164
+ }
165
+ function renderKanban(result, options, resolveLink, source) {
166
+ const className = escapeHtmlAttribute(options.className);
167
+ const parts = [
168
+ `<div class="${className}" data-kanban data-kanban-plugin data-kanban-source="${source}">`,
169
+ `<div class="${className}__board" data-kanban-board>`
170
+ ];
171
+ for (const column of result.columns) {
172
+ parts.push(renderColumn(column, options, resolveLink));
173
+ }
174
+ parts.push("</div>");
175
+ if (options.fallback && result.fallback.length > 0) {
176
+ parts.push(renderFallback(result.fallback, options));
177
+ }
178
+ parts.push("</div>");
179
+ return parts.join("");
180
+ }
181
+ function renderColumn(column, options, resolveLink) {
182
+ const className = escapeHtmlAttribute(options.className);
183
+ const cards = column.cards.map((card) => renderCard(card, options, resolveLink)).join("");
184
+ return [
185
+ `<div class="${className}__column" data-column="${escapeHtmlAttribute(column.name)}">`,
186
+ `<header class="${className}__column-title">${escapeHtml(column.name)}</header>`,
187
+ `<ul class="${className}__cards">${cards}</ul>`,
188
+ "</div>"
189
+ ].join("");
190
+ }
191
+ function renderCard(card, options, resolveLink) {
192
+ const className = escapeHtmlAttribute(options.className);
193
+ const checked = card.checked ? "true" : "false";
194
+ return [
195
+ `<li class="${className}__card" data-checked="${checked}">`,
196
+ `<span class="${className}__checkbox" data-checked="${checked}" aria-hidden="true"></span>`,
197
+ `<span class="${className}__card-text">${renderCardText(card.text, options, resolveLink)}</span>`,
198
+ "</li>"
199
+ ].join("");
200
+ }
201
+ function renderCardText(text, options, resolveLink) {
202
+ const className = escapeHtmlAttribute(options.className);
203
+ let html = escapeHtml(text);
204
+ html = html.replace(
205
+ BOLD,
206
+ (_match, content) => `<strong class="${className}__strong">${content}</strong>`
207
+ );
208
+ html = html.replace(
209
+ TAG,
210
+ (_match, prefix, tag) => `${prefix}<span class="${className}__tag">#${tag}</span>`
211
+ );
212
+ html = html.replace(WIKILINK, (_match, target, fragment, alias) => {
213
+ const label = (alias ?? target).trim();
214
+ const link = resolveLink(target);
215
+ if (!link) {
216
+ return `<span class="${className}__wikilink ${className}__wikilink--broken">${escapeHtml(label)}</span>`;
217
+ }
218
+ const anchor = fragment ? `#${fragment}` : "";
219
+ return `<a class="${className}__wikilink" href="${escapeHtmlAttribute(`${link.href}${anchor}`)}" data-kanban-link="${escapeHtmlAttribute(target.trim())}">${escapeHtml(label)}</a>`;
220
+ });
221
+ return html;
222
+ }
223
+ function renderFallback(lines, options) {
224
+ const className = escapeHtmlAttribute(options.className);
225
+ return [
226
+ `<details class="${className}__fallback">`,
227
+ `<summary class="${className}__fallback-title">Unsupported content</summary>`,
228
+ `<pre class="${className}__fallback-body">${escapeHtml(lines.join("\n"))}</pre>`,
229
+ "</details>"
230
+ ].join("");
231
+ }
232
+
233
+ // src/runtime.ts
234
+ function createKanbanRuntime(options) {
235
+ const markdownBySlug = /* @__PURE__ */ new Map();
236
+ const contentBySlug = /* @__PURE__ */ new Map();
237
+ return {
238
+ track(slug, markdown, content) {
239
+ markdownBySlug.set(slug, markdown);
240
+ contentBySlug.set(slug, content);
241
+ },
242
+ resolve(manifest) {
243
+ const resolveLink = createKanbanLinkResolver(manifest);
244
+ for (const entry of manifest.entries) {
245
+ const markdown = markdownBySlug.get(entry.slug);
246
+ if (options.autoDetect && markdown !== void 0 && isKanbanNote(entry.frontmatter)) {
247
+ const parsed = parseKanban(stripFrontmatter(markdown), options);
248
+ applyHtml(entry, contentBySlug, resolveLink, options, "note", parsed);
249
+ continue;
250
+ }
251
+ if (!entry.html.includes(KANBAN_ATTRIBUTE)) continue;
252
+ const html = replacePlaceholders(entry, options, resolveLink);
253
+ if (html !== entry.html) {
254
+ entry.html = html;
255
+ const content = contentBySlug.get(entry.slug);
256
+ if (content) content.html = html;
257
+ }
258
+ }
259
+ }
260
+ };
261
+ }
262
+ function applyHtml(entry, contentBySlug, resolveLink, options, source, parsed) {
263
+ const html = renderKanban(parsed, options, resolveLink, source);
264
+ if (html === entry.html) return;
265
+ entry.html = html;
266
+ const content = contentBySlug.get(entry.slug);
267
+ if (content) content.html = html;
268
+ }
269
+ function replacePlaceholders(entry, options, resolveLink) {
270
+ const pattern = createKanbanPlaceholderPattern();
271
+ return entry.html.replace(pattern, (_match, encoded) => {
272
+ const parsed = parseKanban(decodeKanbanSource(encoded), options);
273
+ return renderKanban(parsed, options, resolveLink, "block");
274
+ });
275
+ }
276
+
277
+ // index.ts
278
+ function kanban(options = {}) {
279
+ const resolved = resolveKanbanOptions(options);
280
+ const runtime = createKanbanRuntime(resolved);
281
+ return definePlugin({
282
+ name: "kanban",
283
+ options,
284
+ validateOptions: validateKanbanOptions,
285
+ extendMarkdownPipeline: (pipeline) => {
286
+ pipeline.use(remarkKanban, resolved);
287
+ },
288
+ onPostProcessed: (context) => {
289
+ runtime.track(context.slug, context.markdown, context.content);
290
+ },
291
+ onManifestCreated: (context) => {
292
+ runtime.resolve(context.manifest);
293
+ },
294
+ assets: [createStyleAsset("kanban")]
295
+ });
296
+ }
297
+ var kanbanPlugin = kanban;
298
+ function validateKanbanOptions(options) {
299
+ if (!options) return [];
300
+ const issues = [];
301
+ for (const key of ["className", "language", "columnMarker"]) {
302
+ const value = options[key];
303
+ if (value !== void 0 && (typeof value !== "string" || value.trim() === "")) {
304
+ issues.push({ path: key, message: "Expected a non-empty string." });
305
+ }
306
+ }
307
+ for (const key of ["autoDetect", "fallback"]) {
308
+ if (options[key] !== void 0 && typeof options[key] !== "boolean") {
309
+ issues.push({ path: key, message: "Expected a boolean." });
310
+ }
311
+ }
312
+ return issues;
313
+ }
314
+ export {
315
+ KANBAN_ATTRIBUTE,
316
+ createKanbanLinkResolver,
317
+ createKanbanPlaceholder,
318
+ createKanbanPlaceholderPattern,
319
+ decodeKanbanSource,
320
+ encodeKanbanSource,
321
+ isKanbanNote,
322
+ kanban,
323
+ kanbanPlugin,
324
+ parseKanban,
325
+ remarkKanban,
326
+ renderKanban,
327
+ resolveKanbanOptions,
328
+ stripFrontmatter
329
+ };
@@ -0,0 +1,17 @@
1
+ import type { ResolvedKanbanOptions } from "./types.js";
2
+ export type KanbanCard = {
3
+ checked: boolean;
4
+ text: string;
5
+ };
6
+ export type KanbanColumn = {
7
+ name: string;
8
+ cards: KanbanCard[];
9
+ };
10
+ export type KanbanParseResult = {
11
+ columns: KanbanColumn[];
12
+ fallback: string[];
13
+ problems: string[];
14
+ };
15
+ export declare function parseKanban(source: string, options: ResolvedKanbanOptions): KanbanParseResult;
16
+ export declare function isKanbanNote(frontmatter: unknown): boolean;
17
+ export declare function stripFrontmatter(markdown: string): string;
@@ -0,0 +1,5 @@
1
+ export declare const KANBAN_ATTRIBUTE = "data-rr-kanban";
2
+ export declare function encodeKanbanSource(source: string): string;
3
+ export declare function decodeKanbanSource(encoded: string): string;
4
+ export declare function createKanbanPlaceholder(source: string): string;
5
+ export declare function createKanbanPlaceholderPattern(): RegExp;
@@ -0,0 +1,4 @@
1
+ import type { Root } from "mdast";
2
+ import { type KanbanOptions } from "./types.js";
3
+ export type RemarkKanbanOptions = KanbanOptions;
4
+ export declare function remarkKanban(options?: KanbanOptions): (tree: Root, file?: unknown) => void;
@@ -0,0 +1,11 @@
1
+ import type { ContentManifest } from "@riebeckite/core";
2
+ import type { KanbanParseResult } from "./parse.js";
3
+ import type { ResolvedKanbanOptions } from "./types.js";
4
+ export type KanbanLink = {
5
+ href: string;
6
+ label: string;
7
+ };
8
+ export type KanbanLinkResolver = (target: string) => KanbanLink | null;
9
+ export type KanbanSource = "block" | "note";
10
+ export declare function createKanbanLinkResolver(manifest: ContentManifest): KanbanLinkResolver;
11
+ export declare function renderKanban(result: KanbanParseResult, options: ResolvedKanbanOptions, resolveLink: KanbanLinkResolver, source: KanbanSource): string;
@@ -0,0 +1,7 @@
1
+ import type { ContentManifest, PostContent } from "@riebeckite/core";
2
+ import type { ResolvedKanbanOptions } from "./types.js";
3
+ export type KanbanRuntime = {
4
+ track(slug: string, markdown: string, content: PostContent): void;
5
+ resolve(manifest: ContentManifest): void;
6
+ };
7
+ export declare function createKanbanRuntime(options: ResolvedKanbanOptions): KanbanRuntime;
@@ -0,0 +1,15 @@
1
+ export type KanbanOptions = {
2
+ className?: string;
3
+ language?: string;
4
+ columnMarker?: string;
5
+ autoDetect?: boolean;
6
+ fallback?: boolean;
7
+ };
8
+ export type ResolvedKanbanOptions = {
9
+ className: string;
10
+ language: string;
11
+ columnMarker: string;
12
+ autoDetect: boolean;
13
+ fallback: boolean;
14
+ };
15
+ export declare function resolveKanbanOptions(options?: KanbanOptions): ResolvedKanbanOptions;
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@riebeckite/plugin-kanban",
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
+ "@types/mdast": "^4.0.4",
19
+ "unist-util-visit": "^5.1.0",
20
+ "@riebeckite/core": "0.0.1"
21
+ },
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "files": [
26
+ "LICENSE",
27
+ "README.md",
28
+ "README_ja.md",
29
+ "dist",
30
+ "style.css"
31
+ ],
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/Rerurate514/riebeckite.git",
35
+ "directory": "packages/plugins/kanban"
36
+ },
37
+ "homepage": "https://github.com/Rerurate514/riebeckite#readme",
38
+ "bugs": {
39
+ "url": "https://github.com/Rerurate514/riebeckite/issues"
40
+ },
41
+ "description": "Build-time rendering for Obsidian Kanban boards.",
42
+ "keywords": [
43
+ "riebeckite",
44
+ "plugin",
45
+ "kanban",
46
+ "obsidian"
47
+ ],
48
+ "engines": {
49
+ "node": "^20.19.0 || >=22.12.0"
50
+ },
51
+ "sideEffects": [
52
+ "./style.css"
53
+ ],
54
+ "scripts": {
55
+ "build": "node ../../../scripts/build_package.mjs"
56
+ }
57
+ }
package/style.css ADDED
@@ -0,0 +1,144 @@
1
+ .rb-kanban {
2
+ --rb-kanban-ink: var(--rb-color-ink, #000000);
3
+ --rb-kanban-paper: var(--rb-color-paper, #ffffff);
4
+ --rb-kanban-muted: var(--rb-color-muted, #69645c);
5
+ --rb-kanban-accent: var(--rb-color-accent, #686868);
6
+ --rb-kanban-rule: var(
7
+ --rb-color-border,
8
+ color-mix(in srgb, var(--rb-kanban-ink) 18%, transparent)
9
+ );
10
+ --rb-kanban-surface: color-mix(
11
+ in srgb,
12
+ var(--rb-kanban-paper) 94%,
13
+ var(--rb-kanban-ink)
14
+ );
15
+
16
+ margin: 1.5rem 0;
17
+ color: var(--rb-kanban-ink);
18
+ }
19
+
20
+ .rb-kanban__board {
21
+ display: flex;
22
+ gap: 1rem;
23
+ align-items: flex-start;
24
+ overflow-x: auto;
25
+ padding-bottom: 0.5rem;
26
+ scroll-snap-type: x proximity;
27
+ }
28
+
29
+ .rb-kanban__column {
30
+ flex: 0 0 16rem;
31
+ min-width: 16rem;
32
+ max-width: 20rem;
33
+ scroll-snap-align: start;
34
+ border: 1px solid var(--rb-kanban-rule);
35
+ background: var(--rb-kanban-surface);
36
+ }
37
+
38
+ .rb-kanban__column-title {
39
+ margin: 0;
40
+ padding: 0.5rem 0.75rem;
41
+ border-bottom: 1px solid var(--rb-kanban-rule);
42
+ font-size: 0.875rem;
43
+ font-weight: 700;
44
+ letter-spacing: 0.01em;
45
+ }
46
+
47
+ .rb-kanban__cards {
48
+ margin: 0;
49
+ padding: 0.5rem;
50
+ list-style: none;
51
+ display: flex;
52
+ flex-direction: column;
53
+ gap: 0.5rem;
54
+ }
55
+
56
+ .rb-kanban__card {
57
+ display: flex;
58
+ gap: 0.5rem;
59
+ align-items: baseline;
60
+ padding: 0.5rem 0.625rem;
61
+ border: 1px solid var(--rb-kanban-rule);
62
+ background: var(--rb-kanban-paper);
63
+ font-size: 0.875rem;
64
+ line-height: 1.4;
65
+ }
66
+
67
+ .rb-kanban__card-text {
68
+ flex: 1 1 auto;
69
+ min-width: 0;
70
+ overflow-wrap: anywhere;
71
+ }
72
+
73
+ .rb-kanban__checkbox {
74
+ flex: 0 0 auto;
75
+ width: 0.75rem;
76
+ height: 0.75rem;
77
+ margin-top: 0.2em;
78
+ border: 1px solid var(--rb-kanban-ink);
79
+ transform: translateY(0.05em);
80
+ }
81
+
82
+ .rb-kanban__card[data-checked="true"] .rb-kanban__checkbox {
83
+ background: var(--rb-kanban-accent);
84
+ border-color: var(--rb-kanban-accent);
85
+ }
86
+
87
+ .rb-kanban__card[data-checked="true"] .rb-kanban__card-text {
88
+ color: var(--rb-kanban-muted);
89
+ text-decoration: line-through;
90
+ text-decoration-color: var(--rb-kanban-rule);
91
+ }
92
+
93
+ .rb-kanban__strong {
94
+ font-weight: 700;
95
+ }
96
+
97
+ .rb-kanban__tag {
98
+ color: var(--rb-kanban-muted);
99
+ font-size: 0.8125em;
100
+ white-space: nowrap;
101
+ }
102
+
103
+ .rb-kanban__wikilink {
104
+ color: inherit;
105
+ text-decoration: underline;
106
+ text-decoration-color: var(--rb-kanban-rule);
107
+ text-underline-offset: 0.2em;
108
+ }
109
+
110
+ .rb-kanban__wikilink:hover,
111
+ .rb-kanban__wikilink:focus-visible {
112
+ text-decoration-color: var(--rb-kanban-accent);
113
+ }
114
+
115
+ .rb-kanban__wikilink--broken {
116
+ color: var(--rb-kanban-muted);
117
+ text-decoration: line-through;
118
+ }
119
+
120
+ .rb-kanban__fallback {
121
+ margin-top: 0.75rem;
122
+ font-size: 0.8125rem;
123
+ color: var(--rb-kanban-muted);
124
+ }
125
+
126
+ .rb-kanban__fallback-title {
127
+ cursor: pointer;
128
+ }
129
+
130
+ .rb-kanban__fallback-body {
131
+ margin: 0.5rem 0 0;
132
+ padding: 0.5rem 0.75rem;
133
+ overflow-x: auto;
134
+ border: 1px solid var(--rb-kanban-rule);
135
+ background: var(--rb-kanban-surface);
136
+ font-size: 0.75rem;
137
+ white-space: pre-wrap;
138
+ }
139
+
140
+ html[data-theme="dark"] .rb-kanban,
141
+ html.dark .rb-kanban {
142
+ --rb-kanban-ink: var(--rb-color-paper, #ffffff);
143
+ --rb-kanban-paper: var(--rb-color-ink, #000000);
144
+ }