diff --git a/app/src/main/java/io/legado/app/help/JsExtensions.kt b/app/src/main/java/io/legado/app/help/JsExtensions.kt index dab032a3c..5d9028bb5 100644 --- a/app/src/main/java/io/legado/app/help/JsExtensions.kt +++ b/app/src/main/java/io/legado/app/help/JsExtensions.kt @@ -6,6 +6,7 @@ import io.legado.app.constant.AppConst.dateFormat import io.legado.app.model.analyzeRule.AnalyzeUrl import io.legado.app.utils.EncoderUtils import io.legado.app.utils.MD5Utils +import io.legado.app.utils.htmlFormat import org.jetbrains.anko.getStackTraceString import java.net.URLEncoder import java.util.* @@ -80,4 +81,8 @@ interface JsExtensions { "" } } + + fun formatHtml(str: String): String { + return str.htmlFormat() + } } 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 8dfe92acc..bf00f0d43 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 @@ -3,7 +3,6 @@ package io.legado.app.model.analyzeRule import android.text.TextUtils.isEmpty import android.text.TextUtils.join import androidx.annotation.Keep -import io.legado.app.utils.htmlFormat import io.legado.app.utils.splitNotBlank import org.jsoup.Jsoup import org.jsoup.nodes.Element @@ -380,7 +379,7 @@ class AnalyzeByJSoup { "html" -> { elements.select("script").remove() elements.select("style").remove() - val html = elements.outerHtml().htmlFormat() + val html = elements.outerHtml() textS.add(html) } "all" -> textS.add(elements.outerHtml()) diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt index d5fd17ed3..dcf38e764 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt @@ -376,7 +376,7 @@ class AnalyzeRule(var book: BaseBook? = null) : JsExtensions { val jsMatcher = JS_PATTERN.matcher(vRuleStr) while (jsMatcher.find()) { if (jsMatcher.start() > start) { - tmp = vRuleStr.substring(start, jsMatcher.start()).replace("\n", "") + tmp = vRuleStr.substring(start, jsMatcher.start()) .trim { it <= ' ' } if (!TextUtils.isEmpty(tmp)) { ruleList.add(SourceRule(tmp, mMode)) @@ -386,7 +386,7 @@ class AnalyzeRule(var book: BaseBook? = null) : JsExtensions { start = jsMatcher.end() } if (vRuleStr.length > start) { - tmp = vRuleStr.substring(start).replace("\n", "").trim { it <= ' ' } + tmp = vRuleStr.substring(start).trim { it <= ' ' } if (!TextUtils.isEmpty(tmp)) { ruleList.add(SourceRule(tmp, mMode)) } diff --git a/app/src/main/java/io/legado/app/model/webBook/BookContent.kt b/app/src/main/java/io/legado/app/model/webBook/BookContent.kt index ffcc09bd5..b17c5e4ff 100644 --- a/app/src/main/java/io/legado/app/model/webBook/BookContent.kt +++ b/app/src/main/java/io/legado/app/model/webBook/BookContent.kt @@ -10,6 +10,7 @@ import io.legado.app.model.Debug import io.legado.app.model.analyzeRule.AnalyzeRule import io.legado.app.model.analyzeRule.AnalyzeUrl import io.legado.app.utils.NetworkUtils +import io.legado.app.utils.htmlFormat import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.withContext @@ -95,7 +96,7 @@ object BookContent { } } content.deleteCharAt(content.length - 1) - var contentStr = content.toString() + var contentStr = content.toString().htmlFormat() val replaceRegex = bookSource.ruleContent?.replaceRegex?.trim() if (!replaceRegex.isNullOrEmpty()) { contentStr = AnalyzeRule(book).setContent(contentStr).getString(replaceRegex)