0.2.3 • Published 1 month ago

@rshirohara/repixe-parse v0.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

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

0.2.3

1 month ago

0.2.2

1 month ago

0.2.1

3 months ago

0.1.2

10 months ago

0.1.4

10 months ago

0.1.3

10 months ago

0.1.5

10 months ago

0.1.1

11 months ago

0.1.0

11 months ago