feat: optimize reader caching and document formats

This commit is contained in:
shenlei
2026-07-20 17:22:06 +09:00
parent 52f803e8db
commit 68d9363f0a
35 changed files with 3771 additions and 2229 deletions
@@ -18,6 +18,18 @@ public final class RDEpubPlainTextBookBuilder {
style: RDEPUBTextRenderStyle
) throws -> RDEPUBTextBook {
let rawText = rd_decodeTextFile(url: textFileURL)
return try build(text: rawText, pageSize: pageSize, style: style)
}
/// Builds a paginated book from text already held in memory. This is used
/// by container formats such as MOBI, whose text does not exist as a
/// standalone file on disk.
public func build(
text: String,
pageSize: CGSize,
style: RDEPUBTextRenderStyle
) throws -> RDEPUBTextBook {
let rawText = text
let chapterSpecs = splitChapters(from: rawText)
var chapters: [RDEPUBTextChapter] = []