Commit graph svitak/app/EpubParser.hs
Author SHA1 Message Date
8be29359fc
add Html and PlainText types, improved type safety 2026-07-07 13:33:51 +01:00
4e990f19cd
add book-wide text search 2026-07-06 01:16:57 +01:00
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
f17f6a63e2
improve chapter name sanitization 2026-06-25 22:08:53 +01:00
dcf7ce2971
remove redundant imports 2026-03-23 01:42:44 +00:00
9784b7c7de
improve error handling 2026-03-22 03:24:56 +00:00
a5f227fc7a
finish navigation implementation in epubparser 2026-03-19 02:31:01 +00:00
36d6d46c57
remove repeated function 2026-03-19 02:31:01 +00:00
fd05214fee
epub version awareness 2026-02-23 02:28:02 +00:00
c7850d3ad1
fix imports 2026-02-22 23:50:45 +00:00
80be08965e implement generic bookinfo and move logic to parser 2026-02-12 12:47:01 +00:00
55b04ecf44 explicit types 2026-02-12 11:17:36 +00:00
7cd9e79c94 add navigation module 2026-02-11 06:22:09 +00:00
96924df78f compressed function rewrite 2026-02-11 03:50:42 +00:00
0a43a51205 epub3 nav support 2026-02-11 03:07:49 +00:00
8ebfc59d2b page tracking 2026-02-09 04:11:59 +00:00
d65a483878 nxc parsing 2026-02-09 03:15:06 +00:00
4ddb090b2f table of contents integration 2026-02-08 03:02:54 +00:00
de7a64cade replace tagsoup with scalpel 2026-02-04 06:15:20 +00:00
b24288eb70 add seperate types module 2026-02-05 03:25:31 +00:00
4c6c181e65 implement consistent formatting 2026-02-04 05:07:48 +00:00
1cab6a9bab seperate state handling logic 2026-02-04 03:51:47 +00:00
28e5d6ec36 seperate pure functions from IO 2026-02-04 02:38:17 +00:00
a53ef52902 Documentation 2026-02-04 02:12:28 +00:00
a41828dbbd Eager parsing on seperate thread 2026-01-28 19:21:10 +00:00
018e5290a3 feature:MVar Implementation
Replace IORef

Branch created to replace the use of IORef with MVar
2026-01-26 13:44:06 +00:00
4a55d773c6 improve chapter detection 2026-01-27 21:21:15 +00:00
2c06dda760 Update project file
Needed for new test suite
2026-01-26 14:26:29 +00:00
3987c1a853 Begin implementing chapter title parsing
Right now chapter titles are completely plain, parsing the tags will allow us to render it properly.

Revert chapterTitle addition and add it to seperate branch until its completed

Delegating the task of implementing chapter title parsing into a different branch instead of having it incomplete in the main one

Merge chtitle into main
2026-01-26 09:26:45 +00:00
935dc795d0 Add navigation and proper webkit integration with basic chapter display 2026-01-26 04:30:47 +00:00
396a9cdb16 Add image rendering alongside automatic mimetype detection 2026-01-26 02:59:11 +00:00
b666d8477f Integrate parsing backend with gtk. TODO: Base64 image embedding for image compatibility 2026-01-26 02:00:06 +00:00
adfc94e352 Minor cleanup 2026-01-25 04:34:24 +00:00
747c9183a9 Implement epub metadata module to the backend 2026-01-25 04:29:45 +00:00
609024f30e cleanup 2026-01-25 03:08:45 +00:00
8d3848451c Add tag support 2026-01-25 03:06:12 +00:00
29aabbf591 Complete basic text parsing functionality 2026-01-25 02:03:38 +00:00
f6c7d9065e Add chapter getter 2026-01-24 18:22:13 +00:00
a9e774676e Complete mapping from spine to full path in manifest 2026-01-24 02:03:09 +00:00
4bc89a49c1 Add spine to file path resolving 2026-01-24 01:48:02 +00:00
9938b51ba1 Add spine getter 2026-01-24 01:15:24 +00:00
092ef7b8f1 Implement scalpel 2026-01-24 00:56:23 +00:00
f32ddea748 Add tag extractor 2026-01-24 00:33:53 +00:00
2a35aff1b2 Add reader environment 2026-01-24 00:04:45 +00:00
0f9a03822e Add parsing and associated modules 2026-01-23 23:33:00 +00:00
0ac0ae8d61 Updated cabal file and new function 2026-01-23 22:37:35 +00:00
0b3fa129aa Add parser 2026-01-21 02:23:54 +00:00