diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt index 7e49ac677..8ecb6d6bd 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.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()) diff --git a/app/src/main/java/io/legado/app/model/localBook/EPUBFile.kt b/app/src/main/java/io/legado/app/model/localBook/EPUBFile.kt index 2aafc1bc8..68ffd484f 100644 --- a/app/src/main/java/io/legado/app/model/localBook/EPUBFile.kt +++ b/app/src/main/java/io/legado/app/model/localBook/EPUBFile.kt @@ -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("]*>".toRegex(), "\n") + .replace("]*>".toRegex(), "\n") + .replace("\\s*\\n+\\s*".toRegex(), "\n  ") + .replace("^[\\n\\s]+".toRegex(), "  ") + .replace("[\\n\\s]+$".toRegex(), "") } return null }