repixe plugin to add support for serializing pixiv novel format.
This package is a unified plugin that defines how to take a syntax tree as input and turn it into serialized pixiv novel format.
This package is ESM only. in Node.js (18.0+), Install with npm:
npm install @rshirohara/repixe-stringify
Say we have the following module example.js
import { unified } from "unified";
import { repixeStringify } from "@rshirohara/repixe-stringify";
main();
async function main() {
const source = {
type: "root",
children: [
{
type: "paragraph",
children: [
{
type: "text",
value: "ここが一段落目。"
}
]
},
{
type: "paragraph",
children: [
{ type: "text", value: "ここが二" },
{ type: "ruby", value: "段落", ruby: "だんらく" },
{ type: "text", value: "目。" },
{ type: "break" },
{ type: "text", value: "ここが二行目。" }
]
},
{
type: "paragraph",
children: [
{ type: "text", value: "ここから三段落目。" },
{ type: "break" },
{
type: "link",
url: "https://example.com",
children: [{ type: "text", value: "リンク" }]
},
{ type: "text", value: "も使える。" }
]
},
{ type: "pageBreak" },
{
type: "paragraph",
children: [
{ type: "text", value: "ここからページが変わる。" },
{ type: "break" },
{ type: "pageReference", pageNumber: 1 },
{ type: "text", value: "ページへの参照。" }
]
}
]
};
const result = await unified().use(repixeStringify).compile(source);
console.log(result);
}
Running that with node example.js
yields:
ここが一段落目。
ここが二[[rb: 段落 > だんらく]]目。
ここが二行目。
ここから三段落目。
[[jumpuri: リンク > https://example.com]]も使える。
[newpage]
ここからページが変わる。
[jump:1]ページへの参照。
Add support for serializing pixiv novel format input. There are no options.
This package serializes according to pixiv novel format.
The syntax tree format used in repixe is pxast.
This package is fully typed with TypeScript. There are no extra exported types.