rekurke plugin to support for parsing kakuyomu novel format.
This package is a unified plugin that defines how to take kakuyomu novel format as input and turn it into a syntax tree.
This package is ESM only. in Node.js (18.0+), Install with npm:
npm install @rshirohara/rekurke-parse
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: "強調" },
],
},
],
}
Add support for parsing kakuyomu novel format input. There are no options.
Kakuyomu novel format text is parsed according to the official documentation.
The syntax tree format uses in rekurke is kkast.
This package is fully typed with TypeScript. There are no extra exported types.