替换净化应该在简繁转换之后进行

This commit is contained in:
Xwite
2022-02-07 09:22:28 +08:00
parent acec89dd69
commit accc62e0b8
2 changed files with 10 additions and 10 deletions
@@ -81,6 +81,12 @@ data class BookChapter(
): String { ): String {
var displayTitle = title.replace(AppPattern.rnRegex, "") var displayTitle = title.replace(AppPattern.rnRegex, "")
val mDisplayTitle = displayTitle val mDisplayTitle = displayTitle
if (chineseConvert) {
when (AppConfig.chineseConverterType) {
1 -> displayTitle = ChineseUtils.t2s(displayTitle)
2 -> displayTitle = ChineseUtils.s2t(displayTitle)
}
}
if (useReplace && replaceRules != null) { if (useReplace && replaceRules != null) {
replaceRules.forEach { item -> replaceRules.forEach { item ->
if (item.pattern.isNotEmpty()) { if (item.pattern.isNotEmpty()) {
@@ -97,12 +103,6 @@ data class BookChapter(
} }
} }
if (displayTitle.isBlank()) displayTitle = mDisplayTitle if (displayTitle.isBlank()) displayTitle = mDisplayTitle
if (chineseConvert) {
when (AppConfig.chineseConverterType) {
1 -> displayTitle = ChineseUtils.t2s(displayTitle)
2 -> displayTitle = ChineseUtils.s2t(displayTitle)
}
}
return when { return when {
!isVip -> displayTitle !isVip -> displayTitle
isPay -> appCtx.getString(R.string.payed_title, displayTitle) isPay -> appCtx.getString(R.string.payed_title, displayTitle)
@@ -77,10 +77,6 @@ class ContentProcessor private constructor(
//重新分段 //重新分段
mContent = ContentHelp.reSegment(mContent, chapter.title) mContent = ContentHelp.reSegment(mContent, chapter.title)
} }
if (useReplace && book.getUseReplaceRule()) {
//替换
mContent = replaceContent(mContent)
}
if (chineseConvert) { if (chineseConvert) {
//简繁转换 //简繁转换
try { try {
@@ -92,6 +88,10 @@ class ContentProcessor private constructor(
appCtx.toastOnUi("简繁转换出错") appCtx.toastOnUi("简繁转换出错")
} }
} }
if (useReplace && book.getUseReplaceRule()) {
//替换
mContent = replaceContent(mContent)
}
if (includeTitle) { if (includeTitle) {
//重新添加标题 //重新添加标题
mContent = chapter.getDisplayTitle(getReplaceRules()) + "\n" + mContent mContent = chapter.getDisplayTitle(getReplaceRules()) + "\n" + mContent