mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-30 23:49:10 -04:00
feat(text): plain-text (.txt) renderer
makeTextBook: UTF-8 decode (BOM stripped), blank-line paragraph split, hard-wrapped lines joined (natural reflow under font-size changes), HTML escaped, sections capped at ~150KB at paragraph boundaries (small Part N TOC, avoids one giant DOM). Sections expose load/createDocument/size per the reflowable interface; positions for txt books are percentage-based (sections get fake CFIs from index, same as other non-EPUB books). makeBook: dispatches text/plain or .txt in the final non-zip/non-pdf branch. EPUB/PDF/CBZ/MOBI/FB2 routing untouched. Tests: offline node harness (isText, paragraph join/split, escaping, section capping, TOC shape, dispatch incl. zip-still-routes-to-EPUB).
This commit is contained in:
@@ -117,6 +117,10 @@ export const makeBook = async (file, options = {}) => {
|
||||
const { makeFB2 } = await import('./fb2.js')
|
||||
book = await makeFB2(file)
|
||||
}
|
||||
else {
|
||||
const { isText, makeTextBook } = await import('./text.js')
|
||||
if (isText(file)) book = await makeTextBook(file)
|
||||
}
|
||||
}
|
||||
if (!book) throw new UnsupportedTypeError('File type not supported')
|
||||
return book
|
||||
|
||||
Reference in New Issue
Block a user