poltak-epub-parser
v0.1.2
Published
A lightweight browser-first EPUB parsing library.
Downloads
299
Readme
poltak-epub-parser
A lightweight EPUB parsing library based on zip.js. It extracts metadata, chapters, a table of contents, and a combined text stream from an EPUB file.
It is intended for browser use only (not Node).
Install
npm install poltak-epub-parserUsage
import { parseEpub } from 'poltak-epub-parser'
const input = document.querySelector('input[type="file"]')
input.addEventListener('change', async () => {
const file = input.files?.[0]
if (!file) return
const data = await parseEpub(file)
console.log(data.title)
console.log(data.author)
console.log(data.tableOfContents)
})API
parseEpub(file: File | Blob): Promise<EpubData>
Parses an EPUB file and returns:
title: stringauthor: stringchapters: array of{ id, title, content, order, wordStartIndex, wordCount }tableOfContents: array of{ title, href, order, wordStartIndex }allText: combined text for speed-reading and indexing
Notes
- This library depends on browser APIs (
DOMParser,File,Blob) and does not support Node.
