This commit is contained in:
Horis
2023-03-11 21:00:12 +08:00
parent 6c93dcc93c
commit d80316d65e
@@ -142,7 +142,7 @@ class EpubFile(var book: Book) {
return "<img src=\"cover.jpeg\" />"
}
/*获取当前章节文本*/
epubBook?.let {
val contents = epubBookContents ?: return null
val nextChapterFirstResourceHref = chapter.getVariable("nextUrl")?.substringBeforeLast("#")
val currentChapterFirstResourceHref = chapter.url.substringBeforeLast("#")
val isLastChapter = nextChapterFirstResourceHref.isNullOrBlank()
@@ -153,7 +153,6 @@ class EpubFile(var book: Book) {
val includeNextChapterResource = !endFragmentId.isNullOrBlank()
/*一些书籍依靠href索引的resource会包含多个章节,需要依靠fragmentId来截取到当前章节的内容*/
/*注:这里较大增加了内容加载的时间,所以首次获取内容后可存储到本地cache,减少重复加载*/
val contents = epubBookContents ?: return null
for (res in contents) {
if (!findChapterFirstSource) {
if (currentChapterFirstResourceHref != res.href) continue
@@ -197,8 +196,6 @@ class EpubFile(var book: Book) {
}
return HtmlFormatter.formatKeepImg(html)
}
return null
}
private fun getBody(res: Resource, startFragmentId: String?, endFragmentId: String?): Element {
// Jsoup可能会修复不规范的xhtml文件 解析处理后再获取