@riebeckite/plugin-marp 0.0.18 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -2
- package/README_ja.md +27 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +52 -0
- package/dist/src/rehype.d.ts +8 -0
- package/package.json +7 -3
- package/style.css +8 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @riebeckite/plugin-marp
|
|
2
2
|
|
|
3
|
-
Render `marp`
|
|
3
|
+
Render Marp slide decks at build time. A note whose YAML frontmatter contains `marp: true` is rendered as a whole-document deck, and `marp` fenced code blocks render as inline decks.
|
|
4
4
|
|
|
5
5
|
[日本語](./README_ja.md)
|
|
6
6
|
|
|
@@ -23,6 +23,30 @@ export default defineConfig({
|
|
|
23
23
|
});
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
## Obsidian vault compatibility
|
|
27
|
+
|
|
28
|
+
The Obsidian plugins [Marp](https://github.com/jichoup/obsidian-marp-plugin) and [Marp Slides](https://github.com/samuele-cozzi/obsidian-marp-slides) treat the entire note as a Marp deck and never store `marp` code fences. In Obsidian, activation is plugin-level: opening the slide preview or exporting renders the whole file of the active note, and neither plugin reads a per-note marker. Riebeckite instead activates per document using the canonical `marp: true` frontmatter flag — the same signal Marp CLI and the VS Code extension use — so notes written for those plugins are detected as:
|
|
29
|
+
|
|
30
|
+
````markdown
|
|
31
|
+
---
|
|
32
|
+
marp: true
|
|
33
|
+
theme: gaia
|
|
34
|
+
paginate: true
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
# First slide
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
# Second slide
|
|
42
|
+
````
|
|
43
|
+
|
|
44
|
+
The whole document (frontmatter included, so directives such as `theme` and `paginate` apply) is rendered as one `<figure class="rb-marp">` deck that replaces the page body. Slide separators are `---` / `===`, exactly like Marp. Notes without the flag or any `marp` code block are left untouched.
|
|
45
|
+
|
|
46
|
+
> **Activation contract.** Riebeckite is not activated the way the Obsidian plugins are. A note that showed as slides in Obsidian (because you opened the slide preview for it) will **not** render as a deck here unless `marp: true` is present in its frontmatter. Adding that one line is the only change such a vault needs — the deck body (separators, `theme` / `paginate` and other directives, standard Marp syntax) is used exactly as stored. In other words, the output follows Marp semantics, while the plugins' zero-config, plugin-level activation is not reproduced. Treat this as content-compatible, not fully drop-in.
|
|
47
|
+
|
|
48
|
+
## Inline decks
|
|
49
|
+
|
|
26
50
|
In a note, write a fenced code block whose info string is `marp`. Slides are separated by `---`, exactly like Marp. Setting the code block `title` renders a caption.
|
|
27
51
|
|
|
28
52
|
````markdown
|
|
@@ -90,13 +114,15 @@ An unknown theme falls back to the default theme and emits a diagnostic with `so
|
|
|
90
114
|
- No client-side slide editing or paging UI; this only produces static HTML/CSS at build time.
|
|
91
115
|
- Only themes registered in Marp Core are available; loading arbitrary theme CSS is not supported.
|
|
92
116
|
- `inlineSVG: false` emits bare `<section>` elements without the SVG wrapper, and the generated CSS changes to match that structure.
|
|
117
|
+
- Whole-document decks bypass the normal Markdown pipeline, so Obsidian `![[image]]` image embeds are not resolved inside slides. Use regular Markdown image syntax with paths that exist on the published site, mirroring how Marp Slides itself does not support wiki links.
|
|
93
118
|
|
|
94
119
|
## Exports
|
|
95
120
|
|
|
96
121
|
- `marp(options?)` / `marpPlugin(options?)` — plugin factory
|
|
122
|
+
- `isMarpDocument(matter?)` — frontmatter `marp: true` detection helper
|
|
97
123
|
- Types: `MarpOptions`, `MarpDeck`, `MarpBuildRenderResult`
|
|
98
124
|
|
|
99
125
|
## See also
|
|
100
126
|
|
|
101
|
-
- [Plugin guide](../../../docs/docs/reference/plugin-api.
|
|
127
|
+
- [Plugin guide](../../../docs/docs/reference/plugin-api.md)
|
|
102
128
|
|
package/README_ja.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @riebeckite/plugin-marp
|
|
2
2
|
|
|
3
|
-
`marp`
|
|
3
|
+
Marp のスライドデッキをビルド時に描画するプラグインです。YAML frontmatter に `marp: true` を含むノートは文書全体をデッキとして描画し、`marp` コードブロックはインラインデッキとして描画します。
|
|
4
4
|
|
|
5
5
|
[English](./README.md)
|
|
6
6
|
|
|
@@ -23,6 +23,30 @@ export default defineConfig({
|
|
|
23
23
|
});
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
## Obsidian Vault との互換性
|
|
27
|
+
|
|
28
|
+
Obsidian プラグインの [Marp](https://github.com/jichoup/obsidian-marp-plugin) と [Marp Slides](https://github.com/samuele-cozzi/obsidian-marp-slides) はノート全体を Marp デッキとして扱い、`marp` コードフェンスを保存しません。Obsidian 側のアクティベーションはプラグイン単位です。スライドプレビューを開いたり、エクスポートしたりすると、アクティブなノートのファイル全体をデッキとして描画し、ノート単位のマーカーは読みません。Riebeckite では代わりに、文書単位で Marp CLI や VS Code 拡張と同じ canonical なフラグ(frontmatter の `marp: true`)によってデッキ化します。これらのプラグインで書いたノートは次のように検出されます。
|
|
29
|
+
|
|
30
|
+
````markdown
|
|
31
|
+
---
|
|
32
|
+
marp: true
|
|
33
|
+
theme: gaia
|
|
34
|
+
paginate: true
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
# 1 枚目のスライド
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
# 2 枚目のスライド
|
|
42
|
+
````
|
|
43
|
+
|
|
44
|
+
文書全体(directive として `theme` や `paginate` を効かせるため frontmatter を含む)を、ページ本文を置き換える 1 つの `<figure class="rb-marp">` デッキとして描画します。スライドの区切りは Marp と同じく `---` / `===` です。フラグも `marp` コードブロックもないノートは変更しません。
|
|
45
|
+
|
|
46
|
+
> **アクティベーションの契約.** Riebeckite は Obsidian プラグインと同じ方法ではアクティベートされません。Obsidian でスライドとして表示されていたノート(プレビューを開いたノート)も、frontmatter に `marp: true` がなければここではデッキとして描画されません。そのような Vault に必要な変更はこの 1 行の追加だけです。デッキの本体(セパレータ、`theme` / `paginate` などの directive、標準 Marp 構文)は保存された内容をそのまま使います。つまり、出力は Marp の意味論に従いますが、プラグインの設定不要なプラグインレベルでのアクティベーションは再現しません。完全なドロップイン互換ではなく「コンテンツ互換」として扱ってください。
|
|
47
|
+
|
|
48
|
+
## インラインデッキ
|
|
49
|
+
|
|
26
50
|
ノートでは、情報文字列に `marp` を付けたコードブロックを書きます。スライドの区切りは Marp と同じく `---` です。コードブロックの `title` を付けるとキャプションになります。
|
|
27
51
|
|
|
28
52
|
````markdown
|
|
@@ -94,9 +118,10 @@ export default defineConfig({
|
|
|
94
118
|
## 主なエクスポート
|
|
95
119
|
|
|
96
120
|
- `marp(options?)` / `marpPlugin(options?)`: プラグインを作成する
|
|
121
|
+
- `isMarpDocument(matter?)`: frontmatter の `marp: true` を判定するヘルパー
|
|
97
122
|
- 型: `MarpOptions`、`MarpDeck`、`MarpBuildRenderResult`
|
|
98
123
|
|
|
99
124
|
## 関連資料
|
|
100
125
|
|
|
101
|
-
- [プラグインシステム](../../../docs/docs/reference/plugin-api.md)
|
|
126
|
+
- [プラグインシステム](../../../docs/docs/reference/plugin-api.ja.md)
|
|
102
127
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { MarpOptions } from "./src/types.js";
|
|
2
|
+
export { isMarpDocument } from "./src/rehype.js";
|
|
2
3
|
export type { MarpBuildRenderResult, MarpDeck, MarpOptions, } from "./src/types.js";
|
|
3
4
|
/**
|
|
4
5
|
* Renders ` ```marp ` code blocks as static Marp slide decks at build time.
|
package/dist/index.js
CHANGED
|
@@ -168,12 +168,23 @@ var init_render = __esm({
|
|
|
168
168
|
// src/rehype.ts
|
|
169
169
|
var rehype_exports = {};
|
|
170
170
|
__export(rehype_exports, {
|
|
171
|
+
isMarpDocument: () => isMarpDocument,
|
|
171
172
|
rehypeMarp: () => rehypeMarp
|
|
172
173
|
});
|
|
174
|
+
function isMarpDocument(matter) {
|
|
175
|
+
if (!matter || typeof matter !== "object") return false;
|
|
176
|
+
const flag = matter.marp;
|
|
177
|
+
return flag === true || flag === "true";
|
|
178
|
+
}
|
|
173
179
|
function rehypeMarp(options = {}) {
|
|
174
180
|
const className = normalizeClassName(options.className);
|
|
175
181
|
const deckClassName = `${className}__deck`;
|
|
176
182
|
return async (tree, file) => {
|
|
183
|
+
const fileContext = file;
|
|
184
|
+
if (isMarpDocument(fileContext.data?.matter)) {
|
|
185
|
+
await renderWholeDocument(tree, file, fileContext.value ?? "", options);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
177
188
|
const blocks = [];
|
|
178
189
|
visitElements(tree, (node, parent, index) => {
|
|
179
190
|
if (!parent || index === void 0 || !isMarpCodeBlock(node)) return;
|
|
@@ -222,6 +233,45 @@ function rehypeMarp(options = {}) {
|
|
|
222
233
|
}
|
|
223
234
|
};
|
|
224
235
|
}
|
|
236
|
+
async function renderWholeDocument(tree, file, source, options) {
|
|
237
|
+
const className = normalizeClassName(options.className);
|
|
238
|
+
const deckClassName = `${className}__deck`;
|
|
239
|
+
const trimmed = source.trim();
|
|
240
|
+
if (!trimmed) return;
|
|
241
|
+
const result = await renderMarpDeck(trimmed, {
|
|
242
|
+
theme: options.theme?.trim() || "default",
|
|
243
|
+
allowHtml: options.allowHtml !== false,
|
|
244
|
+
math: options.math !== false,
|
|
245
|
+
inlineSVG: options.inlineSVG,
|
|
246
|
+
deckClassName
|
|
247
|
+
});
|
|
248
|
+
if (result.ok === false) {
|
|
249
|
+
reportDiagnostic(
|
|
250
|
+
file,
|
|
251
|
+
`Marp rendering failed: ${result.message}`,
|
|
252
|
+
"render-error"
|
|
253
|
+
);
|
|
254
|
+
console.warn(`[marp] rendering failed: ${result.message}`);
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
if (result.warning) {
|
|
258
|
+
reportDiagnostic(file, result.warning, "theme-fallback");
|
|
259
|
+
console.warn(`[marp] ${result.warning}`);
|
|
260
|
+
}
|
|
261
|
+
const scopedCss = scopeMarpCss(result.deck.css, className, deckClassName);
|
|
262
|
+
const root = tree;
|
|
263
|
+
root.children = [
|
|
264
|
+
buildFigure({
|
|
265
|
+
className,
|
|
266
|
+
deckClassName,
|
|
267
|
+
caption: null,
|
|
268
|
+
source: trimmed,
|
|
269
|
+
slides: result.deck.slides,
|
|
270
|
+
deckHtml: result.deck.html,
|
|
271
|
+
scopedCss
|
|
272
|
+
})
|
|
273
|
+
];
|
|
274
|
+
}
|
|
225
275
|
function buildFigure(input) {
|
|
226
276
|
const children = [];
|
|
227
277
|
if (input.scopedCss) {
|
|
@@ -293,6 +343,7 @@ var init_rehype = __esm({
|
|
|
293
343
|
});
|
|
294
344
|
|
|
295
345
|
// index.ts
|
|
346
|
+
init_rehype();
|
|
296
347
|
import {
|
|
297
348
|
createStyleAsset,
|
|
298
349
|
definePlugin
|
|
@@ -349,6 +400,7 @@ function rehypeMarpLazy(options = {}) {
|
|
|
349
400
|
};
|
|
350
401
|
}
|
|
351
402
|
export {
|
|
403
|
+
isMarpDocument,
|
|
352
404
|
marp,
|
|
353
405
|
marpPlugin
|
|
354
406
|
};
|
package/dist/src/rehype.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
import type { HastNode, MarpOptions } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* `marp: true` in YAML frontmatter is the detection signal used by the Marp
|
|
4
|
+
* ecosystem (Marp CLI and the VS Code extension) to treat a whole document as
|
|
5
|
+
* a Marp deck. The Obsidian Marp plugins (Marp by jichoup, Marp Slides by
|
|
6
|
+
* samuele-cozzi) render the entire note, so this flag and the code block below
|
|
7
|
+
* are the two supported entry points.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isMarpDocument(matter: Record<string, unknown> | undefined): boolean;
|
|
2
10
|
export declare function rehypeMarp(options?: MarpOptions): (tree: HastNode, file: unknown) => Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/plugin-marp",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -16,7 +16,10 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@marp-team/marp-core": "^4.4.0",
|
|
19
|
-
"@riebeckite/core": "0.0.
|
|
19
|
+
"@riebeckite/core": "0.0.20"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"tsx": "^4.22.4"
|
|
20
23
|
},
|
|
21
24
|
"publishConfig": {
|
|
22
25
|
"access": "public"
|
|
@@ -51,6 +54,7 @@
|
|
|
51
54
|
"./style.css"
|
|
52
55
|
],
|
|
53
56
|
"scripts": {
|
|
54
|
-
"build": "node ../../../scripts/build_package.mjs"
|
|
57
|
+
"build": "node ../../../scripts/build_package.mjs",
|
|
58
|
+
"test": "node --import tsx --test \"test/*.test.ts\""
|
|
55
59
|
}
|
|
56
60
|
}
|
package/style.css
CHANGED
|
@@ -58,8 +58,14 @@
|
|
|
58
58
|
background: color-mix(in srgb, var(--rr-marp-ink) 6%, transparent);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
html.dark .rb-marp {
|
|
61
|
+
:is(:root, .rb-theme-root)[data-theme="dark"] .rb-marp {
|
|
63
62
|
--rr-marp-paper: var(--rb-color-ink, #000000);
|
|
64
63
|
--rr-marp-ink: var(--rb-color-paper, #ffffff);
|
|
65
64
|
}
|
|
65
|
+
|
|
66
|
+
@media (prefers-color-scheme: dark) {
|
|
67
|
+
:is(:root, .rb-theme-root):not([data-theme]) .rb-marp {
|
|
68
|
+
--rr-marp-paper: var(--rb-color-ink, #000000);
|
|
69
|
+
--rr-marp-ink: var(--rb-color-paper, #ffffff);
|
|
70
|
+
}
|
|
71
|
+
}
|