From 9da68faedb0fefbde5fd047903d00e0fbca259e0 Mon Sep 17 00:00:00 2001 From: gedoor Date: Mon, 20 Jul 2020 12:18:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/utils/StringExtensions.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/utils/StringExtensions.kt b/app/src/main/java/io/legado/app/utils/StringExtensions.kt index 6da5a6cc6..96b210ad9 100644 --- a/app/src/main/java/io/legado/app/utils/StringExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/StringExtensions.kt @@ -1,7 +1,8 @@ package io.legado.app.utils -val removeHtmlRegex = - "]*>".toRegex() +val removeHtmlRegex = "]*>".toRegex() +val imgRegex = "]*>".toRegex() +val notImgHtmlRegex = "^\\s*|]*>".toRegex() fun String?.safeTrim() = if (this.isNullOrBlank()) null else this.trim() @@ -37,7 +38,10 @@ fun String?.isJsonArray(): Boolean = fun String?.htmlFormat(): String { this ?: return "" - return this.replace(removeHtmlRegex, "\n") + return this + .replace(imgRegex, "\n$0\n") + .replace(removeHtmlRegex, "\n") + .replace(notImgHtmlRegex, "") .replace("\\s*\\n+\\s*".toRegex(), "\n  ") .replace("^[\\n\\s]+".toRegex(), "  ") .replace("[\\n\\s]+$".toRegex(), "")