3.0.0 • Published 1 month ago

teapub v3.0.0

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

TeaPub :tea::beer:

build docs npm license

A pure TypeScript preact-based library for generating ePub files. In contrast to html-to-epub and nodepub, this runs in any javascript environment and seeks a more minimal approach to ePub generation rather than autogenerating content like a cover and table of contents.

Usage

A minimal example

import { render } from "teapub";

const buffer = await render({
  title: "title",
  sections: [{
    title: "section title",
    content: "<my html>",
  }],
});

This library can also include images encoded as buffers. To include them, add an images mapping that maps the src attribute of images in the included html to buffers with optional mime type.

import { readFile } from "fs/promises";
import { render } from "teapub";

const data = await readFile("myfile.jpg");

const buffer = await render({
  title: "title",
  sections: [{
    title: "section title",
    content: `<img src="myfile.jpg"></img>`,
  }],
  images: new Map([["myfile.jpg", { data }]]),
});

Missing

This is intended as barebones, so a lot of aspects related to generating "books" as epubs are missing, but easily includable upon request:

  • custom fonts
  • covers, custom or otherwise
  • table of contents page, custom or otherwise
  • customizable node and attribute filtering
3.0.0

1 month ago

2.2.1

1 month ago

2.2.0

7 months ago

2.1.0

8 months ago

2.0.1

8 months ago

2.0.0

8 months ago

1.0.2

11 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.3

10 months ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago