@b4moss/hyogen-md 0.10.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/LICENSE +21 -0
- package/README.md +130 -0
- package/README_ja.md +130 -0
- package/dist/client.d.ts +46 -0
- package/dist/client.js +2930 -0
- package/dist/index.d.ts +99 -0
- package/dist/index.js +3109 -0
- package/package.json +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bicycle for Mind LLC., Kohki SHIKATA
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# hyogen.md (`@b4moss/hyogen-md`)
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@b4moss/hyogen-md)
|
|
6
|
+
[](./LICENSE)
|
|
7
|
+
[](https://www.npmjs.com/package/@b4moss/hyogen-md)
|
|
8
|
+
[](#status)
|
|
9
|
+
|
|
10
|
+
Extended Markdown template engine for TypeScript / JavaScript.
|
|
11
|
+
|
|
12
|
+
Control flow and templating live in HTML comments (`@hg` … `@endhg` or `@@` … `@@`), so source files stay preview-friendly. The library outputs **Markdown only** (HTML is left to the consumer).
|
|
13
|
+
|
|
14
|
+
- **Package name:** `@b4moss/hyogen-md`
|
|
15
|
+
- **Product name:** hyogen.md(表現.md)
|
|
16
|
+
- **License:** MIT
|
|
17
|
+
- **Japanese README:** [README_ja.md](./README_ja.md)
|
|
18
|
+
- **Changelog:** [user-docs/changelog.md](https://github.com/b4m-oss/hyogen-md/blob/develop/user-docs/changelog.md)
|
|
19
|
+
- **Specs (Japanese, maintainers):** [dev-docs/](https://github.com/b4m-oss/hyogen-md/tree/develop/dev-docs)
|
|
20
|
+
|
|
21
|
+
> **Homepage:** [https://github.com/b4m-oss/hyogen-md](https://github.com/b4m-oss/hyogen-md)
|
|
22
|
+
|
|
23
|
+
This file is kept **in sync** at the repository root and at `app/README.md` (npm package root).
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Install
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install @b4moss/hyogen-md
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Requires **Node.js >= 20**.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Quick start
|
|
38
|
+
|
|
39
|
+
### Client / CSR (`@b4moss/hyogen-md/client`)
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { renderClient } from "@b4moss/hyogen-md/client";
|
|
43
|
+
|
|
44
|
+
const result = await renderClient(
|
|
45
|
+
{ path: "/src/index.md" },
|
|
46
|
+
{ siteName: "Demo" },
|
|
47
|
+
{
|
|
48
|
+
loader: async (path) => {
|
|
49
|
+
// resolve path → file contents (virtual FS, fetch, etc.)
|
|
50
|
+
return await readSomewhere(path);
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
console.log(result.markdown);
|
|
56
|
+
console.log(result.warnings);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Server / SSR (`@b4moss/hyogen-md`)
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import { renderServer, createNodeLoader } from "@b4moss/hyogen-md";
|
|
63
|
+
|
|
64
|
+
const result = await renderServer(
|
|
65
|
+
{ path: "./pages/index.md" },
|
|
66
|
+
{ title: "Hello" },
|
|
67
|
+
{
|
|
68
|
+
loader: createNodeLoader(),
|
|
69
|
+
// serverContext: { apiKey: "…" }, // server-only; not available on renderClient
|
|
70
|
+
},
|
|
71
|
+
);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### SSG batch (`build`)
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
import { build } from "@b4moss/hyogen-md";
|
|
78
|
+
|
|
79
|
+
const { files, warnings } = await build({
|
|
80
|
+
input: "./src/**/*.md",
|
|
81
|
+
outDir: "./out",
|
|
82
|
+
context: { siteName: "Demo" },
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
API details: [dev-docs/specs/api.md](https://github.com/b4m-oss/hyogen-md/blob/develop/dev-docs/specs/api.md).
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Repository layout
|
|
91
|
+
|
|
92
|
+
| Path | Role |
|
|
93
|
+
|------|------|
|
|
94
|
+
| `app/` | Library published to npm (`files`: `dist`, plus README / LICENSE) |
|
|
95
|
+
| `playground/` | Local Vite + Vue playground (**not** published to npm) |
|
|
96
|
+
| `user-docs/` | User-facing docs (e.g. [changelog](https://github.com/b4m-oss/hyogen-md/blob/develop/user-docs/changelog.md)) |
|
|
97
|
+
| `dev-docs/` | Specs and roadmap (**Japanese**, maintainers) |
|
|
98
|
+
|
|
99
|
+
### Playground (local only)
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
cd playground
|
|
103
|
+
npm install
|
|
104
|
+
npm run dev
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Uses `../app` via Vite alias. Virtual FS + `localStorage` only (no real disk I/O).
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Status
|
|
112
|
+
|
|
113
|
+
This is **0.x**. APIs and output may change until `1.0.0`.
|
|
114
|
+
Published: **`@b4moss/hyogen-md@0.10.0`** (git tag `v0.10.0`).
|
|
115
|
+
|
|
116
|
+
Playground UX is part of the **v0.10.0** product milestone but is **not** included in the npm tarball.
|
|
117
|
+
|
|
118
|
+
The coverage badge reflects approximate **statement coverage for `app/`** (library) from Vitest (~84%). Initial release goal is ≥50%. It is not yet wired to CI / Codecov.
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Changelog
|
|
123
|
+
|
|
124
|
+
See **[user-docs/changelog.md](https://github.com/b4m-oss/hyogen-md/blob/develop/user-docs/changelog.md)** (Japanese: [changelog_ja.md](https://github.com/b4m-oss/hyogen-md/blob/develop/user-docs/changelog_ja.md)).
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## License
|
|
129
|
+
|
|
130
|
+
[MIT](./LICENSE) © Kohki SHIKATA
|
package/README_ja.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# hyogen.md(`@b4moss/hyogen-md`)
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@b4moss/hyogen-md)
|
|
6
|
+
[](./LICENSE)
|
|
7
|
+
[](https://www.npmjs.com/package/@b4moss/hyogen-md)
|
|
8
|
+
[](#ステータス)
|
|
9
|
+
|
|
10
|
+
TypeScript / JavaScript 向けの拡張 Markdown テンプレートエンジンです。
|
|
11
|
+
|
|
12
|
+
制御構文は HTML コメント内(`@hg` … `@endhg` または `@@` … `@@`)に閉じるため、生ソースのプレビューを壊しにくいです。ライブラリの出力は **Markdown のみ**(HTML 化は利用側)。
|
|
13
|
+
|
|
14
|
+
- **パッケージ名:** `@b4moss/hyogen-md`
|
|
15
|
+
- **製品名:** hyogen.md(表現.md)
|
|
16
|
+
- **ライセンス:** MIT
|
|
17
|
+
- **English README:** [README.md](./README.md)
|
|
18
|
+
- **Changelog:** [user-docs/changelog_ja.md](https://github.com/b4m-oss/hyogen-md/blob/develop/user-docs/changelog_ja.md)
|
|
19
|
+
- **仕様(日本語・メンテナー向け):** [dev-docs/](https://github.com/b4m-oss/hyogen-md/tree/develop/dev-docs)
|
|
20
|
+
|
|
21
|
+
> **Homepage:** [https://github.com/b4m-oss/hyogen-md](https://github.com/b4m-oss/hyogen-md)
|
|
22
|
+
|
|
23
|
+
本ファイルはリポジトリ根と `app/README_ja.md` で **同内容を同期**します。
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## インストール
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install @b4moss/hyogen-md
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Node.js >= 20** が必要です。
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## クイックスタート
|
|
38
|
+
|
|
39
|
+
### クライアント / CSR(`@b4moss/hyogen-md/client`)
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { renderClient } from "@b4moss/hyogen-md/client";
|
|
43
|
+
|
|
44
|
+
const result = await renderClient(
|
|
45
|
+
{ path: "/src/index.md" },
|
|
46
|
+
{ siteName: "Demo" },
|
|
47
|
+
{
|
|
48
|
+
loader: async (path) => {
|
|
49
|
+
// path → ファイル内容(仮想 FS・fetch など)
|
|
50
|
+
return await readSomewhere(path);
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
console.log(result.markdown);
|
|
56
|
+
console.log(result.warnings);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### サーバ / SSR(`@b4moss/hyogen-md`)
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import { renderServer, createNodeLoader } from "@b4moss/hyogen-md";
|
|
63
|
+
|
|
64
|
+
const result = await renderServer(
|
|
65
|
+
{ path: "./pages/index.md" },
|
|
66
|
+
{ title: "Hello" },
|
|
67
|
+
{
|
|
68
|
+
loader: createNodeLoader(),
|
|
69
|
+
// serverContext: { apiKey: "…" }, // サーバ専用。renderClient では不可
|
|
70
|
+
},
|
|
71
|
+
);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### SSG 一括(`build`)
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
import { build } from "@b4moss/hyogen-md";
|
|
78
|
+
|
|
79
|
+
const { files, warnings } = await build({
|
|
80
|
+
input: "./src/**/*.md",
|
|
81
|
+
outDir: "./out",
|
|
82
|
+
context: { siteName: "Demo" },
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
API の詳細: [dev-docs/specs/api.md](https://github.com/b4m-oss/hyogen-md/blob/develop/dev-docs/specs/api.md)。
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## リポジトリ構成
|
|
91
|
+
|
|
92
|
+
| パス | 役割 |
|
|
93
|
+
|------|------|
|
|
94
|
+
| `app/` | npm 公開するライブラリ(`dist` + README / LICENSE) |
|
|
95
|
+
| `playground/` | ローカル向け Vite + Vue プレイグラウンド(**npm 非同梱**) |
|
|
96
|
+
| `user-docs/` | 利用者向けドキュメント(例: [changelog](https://github.com/b4m-oss/hyogen-md/blob/develop/user-docs/changelog_ja.md)) |
|
|
97
|
+
| `dev-docs/` | 仕様・ロードマップ(**日本語**・メンテナー向け) |
|
|
98
|
+
|
|
99
|
+
### プレイグラウンド(ローカルのみ)
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
cd playground
|
|
103
|
+
npm install
|
|
104
|
+
npm run dev
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Vite alias で `../app` を参照します。仮想 FS + `localStorage` のみ(実ディスクは使いません)。
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## ステータス
|
|
112
|
+
|
|
113
|
+
**0.x** です。`1.0.0` まで API・出力は変わりえます。
|
|
114
|
+
公開済み: **`@b4moss/hyogen-md@0.10.0`**(git tag `v0.10.0`)。
|
|
115
|
+
|
|
116
|
+
Playground UX は **v0.10.0** マイルストーンに含まれますが、**npm の tarball には入りません**。
|
|
117
|
+
|
|
118
|
+
coverage バッジはライブラリ(`app/`)の Vitest **statement カバレッジ概算(約 84%)**です。初期リリース目標は 50% 以上。CI / Codecov 連携はまだありません。
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Changelog
|
|
123
|
+
|
|
124
|
+
**[user-docs/changelog_ja.md](https://github.com/b4m-oss/hyogen-md/blob/develop/user-docs/changelog_ja.md)** を参照(English: [changelog.md](https://github.com/b4m-oss/hyogen-md/blob/develop/user-docs/changelog.md))。
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## ライセンス
|
|
129
|
+
|
|
130
|
+
[MIT](./LICENSE) © Kohki SHIKATA
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export declare function renderClient(
|
|
2
|
+
input: string | { path: string },
|
|
3
|
+
context?: HyogenContext,
|
|
4
|
+
options?: RenderOptions & { serverContext?: HyogenContext },
|
|
5
|
+
): Promise<RenderResult>;
|
|
6
|
+
|
|
7
|
+
export declare function createHyogenError(options: {
|
|
8
|
+
code: string;
|
|
9
|
+
message?: string;
|
|
10
|
+
path?: string;
|
|
11
|
+
details?: Record<string, unknown>;
|
|
12
|
+
}): HyogenError;
|
|
13
|
+
|
|
14
|
+
export declare function formatMessage(
|
|
15
|
+
code: string,
|
|
16
|
+
details?: Record<string, unknown>,
|
|
17
|
+
): string;
|
|
18
|
+
|
|
19
|
+
export type HyogenContext = Record<string, unknown>;
|
|
20
|
+
|
|
21
|
+
export type HyogenDiagnostic = {
|
|
22
|
+
code: string;
|
|
23
|
+
message: string;
|
|
24
|
+
path?: string;
|
|
25
|
+
details?: Record<string, unknown>;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type HyogenWarning = HyogenDiagnostic;
|
|
29
|
+
export type HyogenError = Error & HyogenDiagnostic;
|
|
30
|
+
export type Loader = (path: string) => Promise<string>;
|
|
31
|
+
|
|
32
|
+
export type RenderOptions = {
|
|
33
|
+
preserveFrontMatter?: boolean;
|
|
34
|
+
preserveHgComments?: boolean;
|
|
35
|
+
loader?: Loader;
|
|
36
|
+
root?: string;
|
|
37
|
+
path?: string;
|
|
38
|
+
constrainToRoot?: boolean;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type RenderResult = {
|
|
42
|
+
markdown: string;
|
|
43
|
+
warnings: HyogenWarning[];
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export {};
|