Commit Graph
18 Commits
Author SHA1 Message Date
John O'Keefe ac699e71ee feat(rtff-pdb): RTF and PalmDOC plain-text support (v0.5.0)
rtf.js: a minimal single-pass RTF tokenizer extracting document text
with paragraph structure — groups, control words with signed params,
\\'hh Windows-1252 escapes, \\uN unicode with \\ucN fallback skipping,
known text destinations skipped whole (fonttbl/colortbl/stylesheet/
info/headers/pict/field/...), spec-required ignoring of unknown words.
Format runs are intentionally not converted; RTF is read as styled
text like .txt.

pdb.js: the TEXt/REAd PalmDOC container (PalmDOC, TealDoc) — the PDB
record reader and LZ77 decompressor are shared from mobi.js (both
exported; upstream already carried the TODO for this path). Records
decode as Windows-1252 and feed the plain-text pipeline (paragraph
split, line join, ~150KB sectioning, Part N TOC).

makeBook dispatch: content-based (TEXtREAd magic at offset 60;
'{\\rtf' magic), after MOBI and before the text branch.

Tests: node harness covering store + compressed PalmDOC, RTF paragraphs
/escapes/unicode/hex/destination-skipping, makeBook routing; txt/docx
regression suites pass.
2026-10-03 14:49:22 -04:00
LarzansandLars E. 9a676796f7 Fix MOBI anchors being calculated too late (#118)
The MOBI6.init() method builds #fileposList (the map of all filepos byte-offset references, used to insert <a id="fileposXXXX"> anchors into section HTML) after calling getGuide() and the TOC-section loader — both of which call createDocument() → loadText(), which caches the section HTML. Since #fileposList is still empty at that point, the cached HTML has no anchor elements.

Later, when Foliate calls getElementById('filepos12345') on the cached (anchor-less) document, it returns null, so the paginator falls back to ?? 0 — i.e. scroll to position 0 = first page.

For EPUB this doesn't happen because chapters are separate files; navigation loads a new section by index, not by searching for an anchor element within one section.

Co-authored-by: Lars E. <lars@ermert.es>
2026-04-03 16:01:12 +00:00
Huang Xin 6b11e17443 Properly handle empty fragments for MOBI (#107) 2025-11-28 22:39:57 +00:00
Huang Xin b1f72c0395 Fixed multibyte characters in MOBI fragment selectors (#99) 2025-09-23 15:22:33 +00:00
Huang Xin 55c0027d11 Speed up text sectioning for large MOBI books (#92) 2025-08-01 23:19:23 +00:00
Huang Xin f1d4a4290d Fixed multibyte characters in MOBI fragment selectors (#91)
For Chinese/CJK text, multibyte character offsets
were being incorrectly used as bytes offsets after decoding
2025-08-01 23:17:33 +00:00
Huang Xin f2d32152df Add transform target for KF8 files (#74) 2025-06-10 10:43:34 +00:00
John Factotum 9ff893f3e7 Treat XHTML without xmlns as HTML
The XHTML 1.1 spec says

    The start tag of the root element of the document MUST explicitly
    contain an xmlns declaration for the XHTML namespace

There doesn't seem to be such a requirement in the WHATWG spec. But at
any rate browsers won't render it properly without the XHTML namespace.
2024-07-27 09:46:04 +08:00
John Factotum 660f6bbf1e KF8: fix contributor not exposed in metadata 2024-07-15 00:11:25 +08:00
John Factotum 5cda2125d8 MOBI6: empty string instead of undefined in TOC
Should fix https://github.com/johnfactotum/foliate/issues/1347
2024-07-15 00:08:50 +08:00
John Factotum 5600b6c0dc Migrate to ESLint 9 and fix linting issues 2024-04-23 12:59:31 +08:00
John Factotum 4d7d010e29 MOBI6: build TOC from end-of-file TOC
Fixes #16
2023-10-29 19:04:52 +08:00
John Factotum 495aef0064 KF8: remove KindleUnpack compat
- KindleUnpack's rules for when to insert the coverpage seems a bit
  too involved to replicate exactly.
- The feature is marked "XXX experimental" in KindleUnpack source code
  after 10 years.
- The feature makes no sense as the cover page might not even exist in
  the source EPUB in the first place.

It seems to me now that it might be better to just bite the bullet.
2023-09-11 14:03:54 +08:00
John Factotum e7009357a2 KF8/FXL: get page spread from RESC 2023-09-11 14:01:56 +08:00
John Factotum ab6048411a KF8: fix embedded images in SVG 2023-09-11 12:53:09 +08:00
John Factotum 5da3be5200 Add destroy method
Which revokes all blob URLs and removes the element from document.
2023-05-09 14:02:07 +08:00
John Factotum af0050aba7 MOBI: fix duplicated anchors 2022-10-26 06:07:15 +00:00
John Factotum 5fc72d121c Add files via upload 2022-10-18 18:55:54 +00:00