@rshirohara/rekurke-stringify
Version:
rekurke plugin to add support for serializing kakuyomu novel format.
129 lines (95 loc) • 3.02 kB
Markdown
[![LICENSE][license-badge]][license]
**rekurke** plugin to support for serializing
[][kakuyomu-novel] format.
- [rekurke-stringify](
- [Contents](
- [What is this?](
- [Install](
- [Use](
- [API](
- [`unified().use(rekurkeStringify)`](
- [Syntax](
- [Syntax tree](
- [Types](
- [License](
This package is a [unified][] plugin that defines how to take a syntax tree as input and turn into serialized [kakuyomu novel][kakuyomu-novel] format.
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).
in Node.js (18.0+), Install with [npm][]:
```shell
npm install @rshirohara/rekurke-stringify
```
Say we have the following module `example.js`:
```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:
```text
これが一段落目。
これが二段落目。
これは|ルビ振《るびふ》り。
ここから三段落目。
これは《《強調》》。
```
Add support for serializing kakuyomu novel format input.
There are no options.
The package serializes according to [kakuyomu novel][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.
[][License]
<!-- Link definitions -->
[]: https://kakuyomu.jp
[]: ../kkast
[]: https://img.shields.io/github/license/RShirohara/unified-webnovel
[]: ./LICENSE.md
[]: https://docs.npmjs.com/cli/install
[]: https://www.typescriptlang.org
[]: https://github.com/unifiedjs/unified