From 616874f31699b3624d6a98eeaccb09b32e9cdc27 Mon Sep 17 00:00:00 2001 From: bushixuanqi <57338301+bushixuanqi@users.noreply.github.com> Date: Fri, 23 Jul 2021 00:23:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E9=99=A4=E7=BD=91=E9=A1=B5=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 清除网页注释 --- app/src/main/java/io/legado/app/utils/HtmlFormatter.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt b/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt index 52763a41f..ab779e288 100644 --- a/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt +++ b/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt @@ -6,6 +6,7 @@ import java.util.regex.Pattern object HtmlFormatter { private val wrapHtmlRegex = "]*>".toRegex() + private val commentRegex = "".toRegex() //注释 private val notImgHtmlRegex = "])[^<>]*>".toRegex() private val otherHtmlRegex = "])[^<>]*>".toRegex() private val formatImagePattern = Pattern.compile( @@ -16,6 +17,7 @@ object HtmlFormatter { fun format(html: String?, otherRegex: Regex = otherHtmlRegex): String { html ?: return "" return html.replace(wrapHtmlRegex, "\n") + .replace(commentRegex, "") .replace(otherRegex, "") .replace("\\s*\\n+\\s*".toRegex(), "\n  ") .replace("^[\\n\\s]+".toRegex(), "  ")