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

0.2.3 • Public • Published

repixe-parse

LICENSE

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.

This plugin uses pixiv-novel-parser for parsing pixiv novel format text into tokens and turns those into pxast syntax trees.

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 uses pixiv-novel-parser.

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.

License

MIT

/@rshirohara/repixe-parse/

    Package Sidebar

    Install

    npm i @rshirohara/repixe-parse

    Weekly Downloads

    0

    Version

    0.2.3

    License

    MIT

    Unpacked Size

    26.1 kB

    Total Files

    19

    Last publish

    Collaborators

    • rshirohara