This commit is contained in:
Horis 2024-02-23 10:27:08 +08:00
parent 0045a3f98c
commit d4ac63e1b0
2 changed files with 6 additions and 0 deletions

View File

@ -52,4 +52,6 @@ object AppPattern {
val spaceRegex = "\\s+".toRegex()
val regexCharRegex = "[{}()\\[\\].+*?^$\\\\|]".toRegex()
val LFRegex = "\n".toRegex()
}

View File

@ -1,6 +1,7 @@
package io.legado.app.model.webBook
import io.legado.app.R
import io.legado.app.constant.AppPattern
import io.legado.app.data.appDb
import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter
@ -131,7 +132,10 @@ object BookContent {
//全文替换
val replaceRegex = contentRule.replaceRegex
if (!replaceRegex.isNullOrEmpty()) {
contentStr = contentStr.split(AppPattern.LFRegex)
.joinToString("\n") { it.trim { c -> c <= ' ' || c == ' ' } }
contentStr = analyzeRule.getString(replaceRegex, contentStr)
contentStr = contentStr.split(AppPattern.LFRegex).joinToString("\n") { "  $it" }
}
Debug.log(bookSource.bookSourceUrl, "┌获取章节名称")
Debug.log(bookSource.bookSourceUrl, "${bookChapter.title}")