EPUB reader written in Haskell
  • Haskell 92%
  • Scheme 4.5%
  • Shell 3.5%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Marko Andjelic 2011d638b0
refactor: streaming loader, hierarchical TOC, parser robustness
Rework the reader around a clean BookInfo interface and lazy chapter loading.

Types/parser:
- BookInfo now splits into loadStructure (cheap: spine refs + TOC tree) and renderChapter (one chapter on demand). EpubEnv carries the parsed archive.
- resolveZipPath collapses ./.. and strips #fragments (normalise does not), so relative hrefs like ../Images/x.jpg resolve; used for chapters and images.
- decodeEntry tolerates encodings: UTF-8/UTF-16 BOMs, Latin-1 fallback instead of throwing on invalid bytes.
- Skip spine items with no manifest entry instead of throwing an error.
- Scan the zip for a .opf if container.xml is missing.
- Image inlining rewrites the src URL string, not the whole <img> tag (scalpel
  re-serialises tags, so a whole-tag replace silently missed self-closing imgs).

Navigation:
- Hierarchical TOC: ncxToc (EPUB 2), navToc (EPUB 3), guideToc (<guide> fallback). Nested scrapers use atDepth 1 to take only direct children.

UI:
- Streaming: render the opened chapter on demand, cache it, preload neighbours so arrow paging is instant with a placeholder that covers uncached jumps.
- Sidebar shows the TOC tree with CSS styling. Clicks scroll to #fragments.
- wrapHtml wraps each body in a full HTML document for reliable WebKit render.

Test: 'svitak-test <book> <idx>' dumps one rendered chapter. cabal test stanza fixed to list all needed modules/deps.
2026-06-26 03:45:29 +01:00
app refactor: streaming loader, hierarchical TOC, parser robustness 2026-06-26 03:45:29 +01:00
test refactor: streaming loader, hierarchical TOC, parser robustness 2026-06-26 03:45:29 +01:00
.envrc fix guix dev setup, add hls to dev env 2026-06-23 23:50:49 +01:00
.gitignore add gitignore 2026-01-20 22:37:24 -04:00
guix.scm fix guix dev setup, add hls to dev env 2026-06-23 23:50:49 +01:00
LICENSE Initialization 2026-01-21 01:23:54 +00:00
README.md Initialization 2026-01-21 01:23:54 +00:00
run-svitak.sh fix: build outside the guix container, run the binary inside 2026-06-26 03:44:18 +01:00
svitak.cabal refactor: streaming loader, hierarchical TOC, parser robustness 2026-06-26 03:45:29 +01:00

Svitak 📖

A minimal EPUB parser and reader written in Haskell.

Installation

System prerequisites:

  • GHC ≥ 9.10
  • GTK / WebKit system libraries (required by gi-gtk and gi-webkit)

Dependencies

Arch:

sudo pacman -S \
  ghc cabal-install \
  gtk4 \
  webkitgtk-6.0 \
  gobject-introspection \
  pkgconf

Feel free to make a pull request for instructions regarding your OS/distro

Clone the repo

git clone "https://git.ajattix.org/castelia/svitak.git" && cd svitak

Building

Update the package index (optional but recommended):

cabal update

Proceed with building:

cabal build