正文增加合并后替换规则

pull/279/head
gedoor 4 years ago
parent 3009513585
commit b741b83d66
  1. 18
      app/src/main/java/io/legado/app/model/webBook/BookContent.kt
  2. 2
      app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt
  3. 1
      app/src/main/res/values-zh-rHK/strings.xml
  4. 1
      app/src/main/res/values-zh-rTW/strings.xml
  5. 1
      app/src/main/res/values-zh/strings.xml
  6. 1
      app/src/main/res/values/strings.xml

@ -87,21 +87,27 @@ object BookContent {
analyzeContent( analyzeContent(
book, item.nextUrl, it, contentRule, bookChapter, bookSource, false book, item.nextUrl, it, contentRule, bookChapter, bookSource, false
) )
item.content = contentData.content item.content = contentData.content
} }
} }
} }
for (item in contentDataList) { for (item in contentDataList) {
content.append(item.content).append("\n") content.append(item.content).append("\n")
} }
} }
content.deleteCharAt(content.length - 1) 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, "┌获取章节名称")
Debug.log(bookSource.bookSourceUrl, "${bookChapter.title}") Debug.log(bookSource.bookSourceUrl, "${bookChapter.title}")
Debug.log(bookSource.bookSourceUrl, "┌获取正文内容") Debug.log(bookSource.bookSourceUrl, "┌获取正文内容")
Debug.log(bookSource.bookSourceUrl, "\n$content") Debug.log(bookSource.bookSourceUrl, "\n$contentStr")
return content.toString() return contentStr
} }
@Throws(Exception::class) @Throws(Exception::class)
@ -126,7 +132,7 @@ object BookContent {
} }
Debug.log(bookSource.bookSourceUrl, "" + nextUrlList.joinToString(""), printLog) Debug.log(bookSource.bookSourceUrl, "" + nextUrlList.joinToString(""), printLog)
} }
val content = analyzeRule.getString(contentRule.content).htmlFormat() val content = analyzeRule.getString(contentRule.content)
return ContentData(content, nextUrlList) return ContentData(content, nextUrlList)
} }
} }

@ -233,7 +233,7 @@ class BookSourceEditActivity :
add(EditEntity("nextContentUrl", cr?.nextContentUrl, R.string.rule_next_content)) add(EditEntity("nextContentUrl", cr?.nextContentUrl, R.string.rule_next_content))
add(EditEntity("webJs", cr?.webJs, R.string.rule_web_js)) add(EditEntity("webJs", cr?.webJs, R.string.rule_web_js))
add(EditEntity("sourceRegex", cr?.sourceRegex, R.string.rule_source_regex)) 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)) add(EditEntity("imageStyle", cr?.imageStyle, R.string.rule_image_style))
} }
//发现 //发现

@ -725,4 +725,5 @@
<string name="restore_ignore_summary">恢复时忽略一些内容不恢复,方便不同手机配置不同</string> <string name="restore_ignore_summary">恢复时忽略一些内容不恢复,方便不同手机配置不同</string>
<string name="read_config">阅读界面设置</string> <string name="read_config">阅读界面设置</string>
<string name="rule_image_style">图片样式(imageStyle)</string> <string name="rule_image_style">图片样式(imageStyle)</string>
<string name="rule_replace_regex">替换规则(replaceRegex)</string>
</resources> </resources>

@ -725,5 +725,6 @@
<string name="restore_ignore_summary">恢复时忽略一些内容不恢复,方便不同手机配置不同</string> <string name="restore_ignore_summary">恢复时忽略一些内容不恢复,方便不同手机配置不同</string>
<string name="read_config">阅读界面设置</string> <string name="read_config">阅读界面设置</string>
<string name="rule_image_style">图片样式(imageStyle)</string> <string name="rule_image_style">图片样式(imageStyle)</string>
<string name="rule_replace_regex">替换规则(replaceRegex)</string>
</resources> </resources>

@ -725,4 +725,5 @@
<string name="restore_ignore_summary">恢复时忽略一些内容不恢复,方便不同手机配置不同</string> <string name="restore_ignore_summary">恢复时忽略一些内容不恢复,方便不同手机配置不同</string>
<string name="read_config">阅读界面设置</string> <string name="read_config">阅读界面设置</string>
<string name="rule_image_style">图片样式(imageStyle)</string> <string name="rule_image_style">图片样式(imageStyle)</string>
<string name="rule_replace_regex">替换规则(replaceRegex)</string>
</resources> </resources>

@ -410,6 +410,7 @@
<string name="rule_next_content">正文下一页URL规则(nextContentUrl)</string> <string name="rule_next_content">正文下一页URL规则(nextContentUrl)</string>
<string name="rule_web_js">webJs</string> <string name="rule_web_js">webJs</string>
<string name="rule_source_regex">资源正则(sourceRegex)</string> <string name="rule_source_regex">资源正则(sourceRegex)</string>
<string name="rule_replace_regex">替换规则(replaceRegex)</string>
<string name="rule_image_style">图片样式(imageStyle)</string> <string name="rule_image_style">图片样式(imageStyle)</string>
<string name="source_icon">图标(sourceIcon)</string> <string name="source_icon">图标(sourceIcon)</string>

Loading…
Cancel
Save