rekurke plugin to support for serializing kakuyomu novel format.
This package is a unified plugin that defines how to take a syntax tree as input and turn into serialized kakuyomu novel format.
This package is ESM only. in Node.js (18.0+), Install with npm:
npm install @rshirohara/rekurke-stringify
Say we have the following module example.js
:
import { unified } from "unified";
import { rekurkeStringify } from "@rshirohara/rekurke-stringify";
main();
async function main() {
const source = {
type: "root",
children: [
{
type: "paragraph",
children: [{ type: "text", value: "これが一段落目。" }],
},
{ type: "paragraphMargin", size: 1 },
{
type: "paragraph",
children: [
{ type: "text", value: "これが二段落目。" },
{ type: "break" },
{ type: "text", value: "これは" },
{ type: "ruby", value: "ルビ振", ruby: "るびふ" },
{ type: "text", value: "り。" },
],
},
{ type: "paragraphMargin", size: 2 },
{
type: "paragraph",
children: [
{ type: "text", value: "ここから三段落目。" },
{ type: "break" },
{ type: "text", value: "これは" },
{ type: "emphasis", value: "強調" },
{ type: "text", value: "。" },
],
},
],
};
const text = await unified().use(rekurkeStringify).compile(source);
console.log(text);
}
Running that with node example.js
yields:
これが一段落目。
これが二段落目。
これは|ルビ振《るびふ》り。
ここから三段落目。
これは《《強調》》。
Add support for serializing kakuyomu novel format input. There are no options.
The package serializes according to kakuyomu novel format.
The syntax tree format uses in rekurke is kkast.
This package is fully typed with TypeScript. There are no extra exported types.