pull/274/head
gedoor 4 years ago
parent 410c021c3f
commit 3b8e8765ce
  1. 2
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt
  2. 8
      app/src/main/java/io/legado/app/model/localBook/EPUBFile.kt

@ -378,7 +378,7 @@ class AnalyzeByJSoup {
}
"html" -> {
elements.select("script, style").remove()
val html = elements.html()
val html = elements.outerHtml()
textS.add(html)
}
"all" -> textS.add(elements.outerHtml())

@ -93,9 +93,13 @@ class EPUBFile(val book: io.legado.app.data.entities.Book) {
val resource = eBook.resources.getByHref(chapter.url)
val doc = Jsoup.parse(String(resource.data, mCharset))
val elements = doc.body().children()
elements.select("script, style").remove()
elements.select("script").remove()
elements.select("style").remove()
return elements.outerHtml()
.replace("</?(?:div|p|b|br|hr|h\\d|article|dd|dl)[^>]*>".toRegex(), "\n")
.replace("</?(?:div|p|b|br|hr|h\\d|article|dd|dl|span)[^>]*>".toRegex(), "\n")
.replace("\\s*\\n+\\s*".toRegex(), "\n  ")
.replace("^[\\n\\s]+".toRegex(), "  ")
.replace("[\\n\\s]+$".toRegex(), "")
}
return null
}

Loading…
Cancel
Save