mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34:25 +08:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
aee7cecc53
@ -190,17 +190,24 @@ class EpubFile(var book: Book) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getBody(res: Resource, startFragmentId: String?, endFragmentId: String?): Element {
|
private fun getBody(res: Resource, startFragmentId: String?, endFragmentId: String?): Element {
|
||||||
val doc = Jsoup.parse(String(res.data, mCharset))
|
val originHtml = String(res.data, mCharset)
|
||||||
val body = doc.body()
|
var html = originHtml
|
||||||
|
var doc = Jsoup.parse(html)
|
||||||
|
var body = doc.body()
|
||||||
if (!startFragmentId.isNullOrBlank()) {
|
if (!startFragmentId.isNullOrBlank()) {
|
||||||
body.getElementById(startFragmentId)?.previousElementSiblings()?.remove()
|
body.getElementById(startFragmentId)?.outerHtml()?.let {
|
||||||
|
html = html.substringAfter(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!endFragmentId.isNullOrBlank() && endFragmentId != startFragmentId) {
|
if (!endFragmentId.isNullOrBlank() && endFragmentId != startFragmentId) {
|
||||||
body.getElementById(endFragmentId)?.run {
|
body.getElementById(endFragmentId)?.outerHtml()?.let {
|
||||||
nextElementSiblings().remove()
|
html = html.substringBefore(it)
|
||||||
remove()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (html != originHtml) {
|
||||||
|
doc = Jsoup.parse(html)
|
||||||
|
body = doc.body()
|
||||||
|
}
|
||||||
/*选择去除正文中的H标签,部分书籍标题与阅读标题重复待优化*/
|
/*选择去除正文中的H标签,部分书籍标题与阅读标题重复待优化*/
|
||||||
val tag = Book.hTag
|
val tag = Book.hTag
|
||||||
if (book.getDelTag(tag)) {
|
if (book.getDelTag(tag)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user