teapub
v3.1.0
Published
generate epubs using typescript and preact
Downloads
37
Readme
TeaPub :tea::beer:
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