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

0.3.0 • Public • Published

repixe-stringify

LICENSE

repixe plugin to add support for serializing pixiv novel format.

Contents

What is this?

This package is a unified plugin that defines how to take a syntax tree as input and turn it into serialized pixiv novel format.

Install

This package is ESM only. in Node.js (18.0+), Install with npm:

npm install @rshirohara/repixe-stringify

Use

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]ページへの参照。

API

unified().use(repixeStringify)

Add support for serializing pixiv novel format input. There are no options.

Syntax

This package serializes according to pixiv novel format.

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

Readme

Keywords

Package Sidebar

Install

npm i @rshirohara/repixe-stringify

Weekly Downloads

3

Version

0.3.0

License

MIT

Unpacked Size

12.8 kB

Total Files

11

Last publish

Collaborators

  • rshirohara