Skip to content

Releases

MejiroEPUB 0.1.0

Choose a tag to compare

@2bo-velocity 2bo-velocity released this 06 Dec 12:21

The first release of MejiroEPUB: EPUB 3 generation for PHP 8.3+, built to
stream a whole Japanese web novel into an EPUB without holding it in memory.

composer require 2bo-velocity/mejiroepub

What is in it

A streaming EPUB writer. Document writes each section into the ZIP the
moment it is given and keeps only its table-of-contents entry. A body may be a
string or any iterable — a generator reading rows from a database keeps one line
in memory at a time. Measured on a serial of 132 chapters and 550,000
characters: about 0.1 s and a peak under 1 MB. The test suite holds the library
to it: eight times the text must cost less than twice the memory.

Vertical Japanese. WritingMode::VERTICAL_RL writes vertical-rl and turns
pages right to left. Ruby with fallback parentheses, sesame emphasis dots and
automatic upright two-digit numbers come with it; StyleOptions sets how Latin
text sits in a vertical line and the line height, and leaves fonts and sizes to
the reader.

Three notations, one line per paragraph.

  • Notation::novel() reads the ruby and emphasis syntax of Japanese web-novel
    sites. It is checked against a real site's own parser: every case in the test
    corpus, and 26,753 lines of a published serial, split identically.
  • Notation::mejiro() reads MejiroPDF's inline syntax, so one manuscript gives
    both a PDF and an EPUB. It is checked against MejiroPDF's own tokenizer case
    by case. What EPUB cannot carry (size=, drop caps) keeps its text and is
    reported once per book through your PSR-3 logger.
  • Notation::plain() reads nothing.
  • Paragraph::of() builds a paragraph from parts that are never reinterpreted.

Footnotes as EPUB 3 noteref / footnote pairs at the end of each section,
numbered through the book by default (as MejiroPDF numbers them) or per section.

Covers and illustrations (JPEG, PNG, GIF, WebP), copied into the archive in
chunks; a cover page that keeps the picture's proportions on any screen.

Metadata: title, language, author, publisher, synopsis, source, publication
date and a stable identifier.

Untrusted text is safe to pass. Markup is escaped, control characters and
broken UTF-8 are cleaned, links are limited to http, https and mailto, style
values are validated, and the archive refuses to grow past ZIP's 4 GB limits
rather than writing a broken file.

Upgrade notes

None — this is the first release. While the version is 0.x, a minor version may
change the API; every such change will be listed here.

Quality gates

  • PHPStan level 8, no errors
  • PHPUnit: 254 tests, including byte-level golden files
  • EPUBCheck 5.4.0 on every test publication, warnings treated as failures
  • Checked on Kinokuniya's Kinoppy reader with a 132-chapter vertical novel

Contributing and support

Pull requests are not accepted; bug reports are welcome in Issues. There is no
support commitment. See CONTRIBUTING.md.


日本語

MejiroEPUB の最初のリリースです。PHP 8.3 以上で EPUB 3 を生成します。日本語の Web 小説を
まるごと、メモリに抱えずに EPUB へ流し込むために作りました。

  • ストリームで書き出します。 節は渡された時点で ZIP へ書き、手元には目次の 1 行だけを残します。
    本文には文字列のほか、データベースから 1 行ずつ読むジェネレータも渡せます。132 話・55 万字の
    連載作品で約 0.1 秒、ピーク 1 MB 未満でした。
  • 縦書き(右から左へのページ送り)、ルビ、ゴマ傍点、2 桁数字の自動縦中横。
  • 3 つの記法: 小説投稿サイトの記法(Notation::novel()。実在のサイトのパーサと、テストの全ケースと
    公開作品 26,753 行で一致)、MejiroPDF の記法(Notation::mejiro()。1 つの原稿から PDF と EPUB を作れます)、
    記法なし(Notation::plain())。
  • 脚注(EPUB 3 の noteref / footnote)、表紙と挿絵、メタデータ(出版者・あらすじ・出典を含む)。
  • 信頼できない文章をそのまま渡せます(エスケープ、制御文字の除去、リンクは http・https・mailto のみ)。
  • 品質: PHPStan レベル 8、PHPUnit 254 テスト、全テスト出版物を EPUBCheck 5.4.0 で警告ゼロ、
    紀伊國屋書店 Kinoppy で表示を確認。
  • 0.x の間はマイナーバージョンで API が変わることがあります。変更はここに明記します。
  • プルリクエストは受け付けていません。不具合報告は Issues へお寄せください。サポートのお約束はありません。