Licence
MIT
Version
0.3.2
Deps
2
Size
241 kB
Vulns
0
Weekly
0
DeprecatedThis package is deprecated
repixe-parse
repixe plugin to add support for parsing pixiv novel format.
Contents
What is this?
This package is a unified plugin that defines how to take pixiv 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/repixe-parse
Use
Say we have the following module example.js:
import { unified } from "unified";
import { repixeParse } from "@rshirohara/repixe-parse";
main();
async function main() {
const source = [
"これが一段落目\n\n",
"ここから二段落目",
"[[rb:二行目>にぎょうめ]]",
"[[jumpuri:リンク>https://example.com]]も使える。"
].join("\n");
const ast = await unified().use(repixeParse).parse(source);
console.log(ast);
}
Running that with node example.js yields:
{
type: "root",
children: [
{
type: "paragraph",
children: [
{type: "text", value: "これが一段落目"}
]
},
{
type: "paragraph",
children: [
{type: "text", value: "ここから二段落目"},
{type: "break"},
{type: "ruby", value: "二行目", ruby: "にぎょうめ"},
{type: "break"},
{type: "link", url: "https://example.com", children: [
{type: "text", value: "リンク"}
]},
{type: "text": value: "も使える"}
]
}
]
}
API
unified().use(repixeParse)
Add support for parsing pixiv novel format input. There are no options.
Syntax
Pixiv novel format text is parsed according to the official documentation.
Syntax tree
The syntax tree format used in repixe is pxast.
Types
This package is fully typed with TypeScript. There are no extra exported types.