0.1.3 • Published 9 months ago

@rshirohara/rekurke-stringify v0.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

rekurke-stringify

LICENSE

rekurke plugin to support for serializing kakuyomu novel format.

Contents

What is this?

This package is a unified plugin that defines how to take a syntax tree as input and turn into serialized kakuyomu novel format.

Install

This package is ESM only. in Node.js (18.0+), Install with npm:

npm install @rshirohara/rekurke-stringify

Use

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:

これが一段落目。

これが二段落目。
これは|ルビ振《るびふ》り。


ここから三段落目。
これは《《強調》》。

API

unified().use(rekurkeStringify)

Add support for serializing kakuyomu novel format input. There are no options.

Syntax

The package serializes according to kakuyomu novel format.

Syntax tree

The syntax tree format uses in rekurke is kkast.

Types

This package is fully typed with TypeScript. There are no extra exported types.

License

MIT

0.1.3

9 months ago

0.1.2

10 months ago

0.1.1

1 year ago

0.1.0

1 year ago