@kubohiroya/turbowarp-markdown 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +19 -0
- package/README.md +21 -1
- package/dist/turbowarp-markdown.js +1 -1
- package/docs/index.html +3 -0
- package/package.json +14 -7
package/README.ja.md
CHANGED
|
@@ -6,6 +6,15 @@
|
|
|
6
6
|
|
|
7
7
|
TurboWarp 上で Markdown を immutable な構造化フラグメントとして組み立て、最後の出力境界でだけ Markdown 文字列へレンダリングする拡張です。
|
|
8
8
|
|
|
9
|
+
## 実行できるサンプル
|
|
10
|
+
|
|
11
|
+
[**TurboWarp Editorでデモを開く**](https://turbowarp.org/editor?project_url=https%3A%2F%2Fkubohiroya.github.io%2Fturbowarp-markdown%2Fsamples%2Fbuild-markdown-card.sb3) · [SB3をダウンロード](https://kubohiroya.github.io/turbowarp-markdown/samples/build-markdown-card.sb3)
|
|
12
|
+
|
|
13
|
+
**Allow**で読み込みを許可し、緑の旗を押します。
|
|
14
|
+
`heading`・`bold`・`paragraph`・`render`で短い紹介文を生成し、結果のMarkdown文字列を表示。サンプルの元データと期待結果は[`samples/README.md`](samples/README.md)に記載しています。
|
|
15
|
+
|
|
16
|
+
`pnpm run samples:build`でSB3を再生成し、`pnpm run samples:check`で更新漏れと生成処理を確認します。
|
|
17
|
+
|
|
9
18
|
## 概要
|
|
10
19
|
|
|
11
20
|
- エスケープ済み text、bold、italic、link、inline code を作れます。
|
|
@@ -19,6 +28,16 @@ TurboWarp 上で Markdown を immutable な構造化フラグメントとして
|
|
|
19
28
|
|
|
20
29
|
`turbowarp-http-server` とは npm パッケージ依存では結合しません。Markdown 拡張で作ったフラグメントを `render Markdown` で文字列化し、HTTP レスポンス本文として渡してください。content type は `text/markdown; charset=utf-8` を明示する想定です。
|
|
21
30
|
|
|
31
|
+
## Document Dataで解析・読み取りする
|
|
32
|
+
|
|
33
|
+
`turbowarp-markdown:v1:`の値は組み立て用の形式で、読み取るための木ではありません。箇条書きの項目やinlineの中身が入れ子の`sequence`に入ることがあり、中身が1つのときと複数のときで形も変わります。組み立てた文書の一部を読み取ったり置き換えたり、構造を順にたどったりするときは、`render Markdown`で文字列にして[TurboWarp Document Data](https://github.com/kubohiroya/turbowarp-document-data)へ渡してください。
|
|
34
|
+
|
|
35
|
+
```text
|
|
36
|
+
parse Markdown (render Markdown (fragment)) as document [doc]
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Document Dataは解析したMarkdownをmdastの木として保持し、子は常に平らな`children`配列に並びます。位置を指定してtextを読み取り・置き換えるblockがあります。2つの拡張はnpmパッケージ依存を持たず、描画した文字列だけを受け渡すため、この拡張はサンドボックス内のまま動作します。Document Data自体はサンドボックスなしで動作します。
|
|
40
|
+
|
|
22
41
|
## 開発
|
|
23
42
|
|
|
24
43
|
```bash
|
package/README.md
CHANGED
|
@@ -6,6 +6,16 @@ English | [日本語](README.ja.md)
|
|
|
6
6
|
|
|
7
7
|
A TurboWarp extension for building Markdown as immutable structured fragments and rendering it only at the output boundary.
|
|
8
8
|
|
|
9
|
+
## Runnable sample
|
|
10
|
+
|
|
11
|
+
[**Open the demo in TurboWarp Editor**](https://turbowarp.org/editor?project_url=https%3A%2F%2Fkubohiroya.github.io%2Fturbowarp-markdown%2Fsamples%2Fbuild-markdown-card.sb3) · [Download the SB3](https://kubohiroya.github.io/turbowarp-markdown/samples/build-markdown-card.sb3)
|
|
12
|
+
|
|
13
|
+
Choose **Allow** and click the green flag.
|
|
14
|
+
A heading and a bold Ready paragraph as Markdown text.
|
|
15
|
+
|
|
16
|
+
Editable sources and expected results: [`samples/README.md`](samples/README.md).
|
|
17
|
+
Run `pnpm run samples:build` after source/bundle changes and `pnpm run samples:check` before committing.
|
|
18
|
+
|
|
9
19
|
## What it does
|
|
10
20
|
|
|
11
21
|
- creates escaped inline text, bold, italic, links, and code spans;
|
|
@@ -34,7 +44,7 @@ pnpm install --frozen-lockfile
|
|
|
34
44
|
The package is version-pinned when used from npm:
|
|
35
45
|
|
|
36
46
|
```bash
|
|
37
|
-
pnpm add --save-exact @kubohiroya/turbowarp-markdown@0.
|
|
47
|
+
pnpm add --save-exact @kubohiroya/turbowarp-markdown@0.6.0
|
|
38
48
|
```
|
|
39
49
|
|
|
40
50
|
## Quick Start
|
|
@@ -256,6 +266,16 @@ Use `render Markdown [FRAGMENT]` when validation is not needed. Use `render Mark
|
|
|
256
266
|
|
|
257
267
|
Validation is intentionally lightweight. It catches common mistakes such as a `list item` used outside a list and block fragments nested inside inline-only fragments. It also warns about empty documents, empty lists, empty headings, and links without visible content or destinations.
|
|
258
268
|
|
|
269
|
+
## Parse and read with Document Data
|
|
270
|
+
|
|
271
|
+
The `turbowarp-markdown:v1:` values are a build format, not a tree meant for reading: list items and inline content can sit inside nested `sequence` fragments, and a fragment with one child has a different shape from one with several. To read or replace parts of a document you built, or to walk its structure, render it and pass the string to [TurboWarp Document Data](https://github.com/kubohiroya/turbowarp-document-data):
|
|
272
|
+
|
|
273
|
+
```text
|
|
274
|
+
parse Markdown (render Markdown (fragment)) as document [doc]
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
Document Data keeps the parsed Markdown as an mdast tree whose children are always flat `children` arrays, and its blocks read and replace text by location. The two extensions share no package dependency and exchange only the rendered string, so this extension keeps running in the sandbox; Document Data itself runs without the sandbox.
|
|
278
|
+
|
|
259
279
|
## Development
|
|
260
280
|
|
|
261
281
|
```bash
|
|
@@ -20,7 +20,7 @@ var extensionConfig = {
|
|
|
20
20
|
blockIconURI: "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0OCA0OCI+PHJlY3QgeD0iNiIgeT0iOCIgd2lkdGg9IjM2IiBoZWlnaHQ9IjMyIiByeD0iNCIgZmlsbD0iIzJGNjM4NiIvPjxwYXRoIGQ9Ik0xMyAzMFYxOGw1IDcgNS03djEyTTI3LjUgMjB2MTBNMjcuNSAyMGgyLjVhNSA1IDAgMCAxIDAgMTBoLTIuNSIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjZmZmZmZmIiBzdHJva2Utd2lkdGg9IjMiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg=="
|
|
21
21
|
};
|
|
22
22
|
//#endregion
|
|
23
|
-
//#region node_modules/.pnpm/@kubohiroya+turbowarp-extension-data-editor@0.
|
|
23
|
+
//#region node_modules/.pnpm/@kubohiroya+turbowarp-extension-data-editor@0.8.1_react@18.3.1/node_modules/@kubohiroya/turbowarp-extension-data-editor/dist/fixed-input-schema.js
|
|
24
24
|
var numberToken = /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$/u;
|
|
25
25
|
var invalidNumber = Object.freeze({
|
|
26
26
|
kind: "invalid",
|
package/docs/index.html
CHANGED
|
@@ -65,6 +65,9 @@ render Markdown [combined result]</code></pre>
|
|
|
65
65
|
|
|
66
66
|
<h2>TypeScript API</h2>
|
|
67
67
|
<p>The package also exports block-free builder functions from <code>@kubohiroya/turbowarp-markdown</code>, including <code>text</code>, <code>bold</code>, <code>italic</code>, <code>link</code>, <code>heading</code>, <code>paragraph</code>, <code>quote</code>, <code>codeBlock</code>, <code>listItem</code>, <code>unorderedList</code>, <code>orderedList</code>, <code>concat</code>, and <code>render</code>.</p>
|
|
68
|
+
<section id="runnable-sample"><h2>Runnable sample / 実行できるサンプル</h2>
|
|
69
|
+
<p><a href="https://turbowarp.org/editor?project_url=https%3A%2F%2Fkubohiroya.github.io%2Fturbowarp-markdown%2Fsamples%2Fbuild-markdown-card.sb3">Open in TurboWarp Editor</a> · <a href="https://kubohiroya.github.io/turbowarp-markdown/samples/build-markdown-card.sb3">Download build-markdown-card.sb3</a></p>
|
|
70
|
+
<p>A heading and a bold Ready paragraph as Markdown text.</p><p>Allowで読み込みを許可し、緑の旗を押します。</p></section>
|
|
68
71
|
<!-- BEGIN COMPLETE BLOCK REFERENCE -->
|
|
69
72
|
<section lang="en" id="extension-block-reference" aria-labelledby="block-reference-title">
|
|
70
73
|
<h2 id="block-reference-title">TurboWarp Markdown: complete block reference</h2>
|
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubohiroya/turbowarp-markdown",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "An immutable Markdown builder extension for TurboWarp.",
|
|
5
|
-
"author":
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Hiroya Kubo",
|
|
7
|
+
"email": "hiroya@cuc.ac.jp",
|
|
8
|
+
"url": "https://github.com/kubohiroya"
|
|
9
|
+
},
|
|
6
10
|
"license": "MPL-2.0",
|
|
7
11
|
"homepage": "https://github.com/kubohiroya/turbowarp-markdown#readme",
|
|
8
12
|
"repository": {
|
|
@@ -55,20 +59,23 @@
|
|
|
55
59
|
"template:readme": "node scripts/apply-readme-template.ts",
|
|
56
60
|
"repo:check": "node scripts/check-repo.ts",
|
|
57
61
|
"pack:check": "npm pack --dry-run --ignore-scripts",
|
|
58
|
-
"check": "pnpm run typecheck && pnpm run lint && pnpm run test && pnpm run docs:check && pnpm run check:dist && pnpm run repo:check && pnpm run pack:check",
|
|
59
|
-
"check:dist": "pnpm run build && node scripts/check-dist.ts"
|
|
62
|
+
"check": "pnpm run typecheck && pnpm run lint && pnpm run test && pnpm run docs:check && pnpm run check:dist && pnpm run repo:check && pnpm run pack:check && pnpm run samples:check",
|
|
63
|
+
"check:dist": "pnpm run build && node scripts/check-dist.ts",
|
|
64
|
+
"samples:build": "node scripts/build-samples.mjs",
|
|
65
|
+
"samples:check": "node scripts/build-samples.mjs --check && node --test scripts/verify-samples.mjs",
|
|
66
|
+
"pages:build": "node scripts/prepare-pages.mjs"
|
|
60
67
|
},
|
|
61
68
|
"devDependencies": {
|
|
62
69
|
"@eslint/js": "^9.39.5",
|
|
63
|
-
"@kubohiroya/turbowarp-extension-manifest": "^0.
|
|
64
|
-
"@kubohiroya/vite-plugin-turbowarp-extension": "^0.
|
|
70
|
+
"@kubohiroya/turbowarp-extension-manifest": "^0.5.0",
|
|
71
|
+
"@kubohiroya/vite-plugin-turbowarp-extension": "^0.11.0",
|
|
65
72
|
"@types/node": "^24.13.3",
|
|
66
73
|
"eslint": "^9.39.5",
|
|
67
74
|
"typescript": "^5.9.3",
|
|
68
75
|
"typescript-eslint": "^8.66.0",
|
|
69
76
|
"vite": "^8.2.2",
|
|
70
77
|
"vitest": "^4.1.10",
|
|
71
|
-
"@kubohiroya/turbowarp-extension-data-editor": "^0.
|
|
78
|
+
"@kubohiroya/turbowarp-extension-data-editor": "^0.8.1"
|
|
72
79
|
},
|
|
73
80
|
"gitHead": "a02baff13a8da2f82f8807d33fdc6c50e8505cb4",
|
|
74
81
|
"x-turbowarp-source": {
|