@rshirohara/rekurke-parse
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

rekurke-parse

LICENSE

rekurke plugin to support for parsing kakuyomu novel format.

Contents

What is this?

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

Install

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

npm install @rshirohara/rekurke-parse

Use

Say we have the following module example.js:

import { rekurkeParse } from "@rshirohara/rekurke-parse";
import { unified } from "unified";

main();

async function main() {
  const source = [
    "これが一段落目\r\n",
    "ここから二段落目",
    "これはルビ|振《ふ》り",
    "これは《《強調》》",
  ].join("\n");
  const ast = await unified().use(rekurkeParse).parse(source);

  console.log(ast);
}

Running that with node example.js yields:

{
  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: "break" },
        { type: "text", value: "これは" },
        { type: "emphasis", value: "強調" },
      ],
    },
  ],
}

API

unified().use(rekurkeParse)

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

Syntax

Kakuyomu novel format text is parsed according to the official documentation.

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

Package Sidebar

Install

npm i @rshirohara/rekurke-parse

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

158 kB

Total Files

23

Last publish

Collaborators

  • rshirohara