From b741b83d6679cb2b2952f65e2a3e976536400799 Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 23 Jul 2020 23:01:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AD=A3=E6=96=87=E5=A2=9E=E5=8A=A0=E5=90=88?= =?UTF-8?q?=E5=B9=B6=E5=90=8E=E6=9B=BF=E6=8D=A2=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/model/webBook/BookContent.kt | 18 ++++++++++++------ .../book/source/edit/BookSourceEditActivity.kt | 2 +- app/src/main/res/values-zh-rHK/strings.xml | 1 + app/src/main/res/values-zh-rTW/strings.xml | 1 + app/src/main/res/values-zh/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 6 files changed, 17 insertions(+), 7 deletions(-) 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 a5ee5b26a..9e5336b62 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 @@ -87,21 +87,27 @@ object BookContent { analyzeContent( book, item.nextUrl, it, contentRule, bookChapter, bookSource, false ) - item.content = contentData.content - } + item.content = contentData.content + } } } for (item in contentDataList) { content.append(item.content).append("\n") } } - content.deleteCharAt(content.length - 1) + var contentStr = content.toString().htmlFormat() + val replaceRegex = bookSource.ruleContent?.replaceRegex + replaceRegex?.trim { it <= ' ' }?.split("##")?.let { + if (it.size > 1) { + contentStr = contentStr.replace(it[1].toRegex(), it.getOrNull(2) ?: "") + } + } Debug.log(bookSource.bookSourceUrl, "┌获取章节名称") Debug.log(bookSource.bookSourceUrl, "└${bookChapter.title}") Debug.log(bookSource.bookSourceUrl, "┌获取正文内容") - Debug.log(bookSource.bookSourceUrl, "└\n$content") - return content.toString() + Debug.log(bookSource.bookSourceUrl, "└\n$contentStr") + return contentStr } @Throws(Exception::class) @@ -126,7 +132,7 @@ object BookContent { } Debug.log(bookSource.bookSourceUrl, "└" + nextUrlList.joinToString(","), printLog) } - val content = analyzeRule.getString(contentRule.content).htmlFormat() + val content = analyzeRule.getString(contentRule.content) return ContentData(content, nextUrlList) } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt index b9f191563..d53c9a05c 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt @@ -233,7 +233,7 @@ class BookSourceEditActivity : add(EditEntity("nextContentUrl", cr?.nextContentUrl, R.string.rule_next_content)) add(EditEntity("webJs", cr?.webJs, R.string.rule_web_js)) add(EditEntity("sourceRegex", cr?.sourceRegex, R.string.rule_source_regex)) - add(EditEntity("replaceRegex", cr?.replaceRegex, R.string.replace)) + add(EditEntity("replaceRegex", cr?.replaceRegex, R.string.rule_replace_regex)) add(EditEntity("imageStyle", cr?.imageStyle, R.string.rule_image_style)) } //发现 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index c898a62e6..c25e0c32a 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -725,4 +725,5 @@ 恢复时忽略一些内容不恢复,方便不同手机配置不同 阅读界面设置 图片样式(imageStyle) + 替换规则(replaceRegex) diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index feb6c2d4a..bb5b6ba27 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -725,5 +725,6 @@ 恢复时忽略一些内容不恢复,方便不同手机配置不同 阅读界面设置 图片样式(imageStyle) + 替换规则(replaceRegex) diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index beec7d5b4..9ecea1099 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -725,4 +725,5 @@ 恢复时忽略一些内容不恢复,方便不同手机配置不同 阅读界面设置 图片样式(imageStyle) + 替换规则(replaceRegex) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 78c9b7ce1..d7bdbec39 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -410,6 +410,7 @@ 正文下一页URL规则(nextContentUrl) webJs 资源正则(sourceRegex) + 替换规则(replaceRegex) 图片样式(imageStyle) 图标(sourceIcon)