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.
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 }]]),
});
This is intended as barebones, so a lot of aspects related to generating "books" as epubs are missing, but easily includable upon request:
Generated using TypeDoc