优化
This commit is contained in:
@@ -11,6 +11,21 @@
|
|||||||
* 正文出现缺字漏字、内容缺失、排版错乱等情况,有可能是净化规则或简繁转换出现问题。
|
* 正文出现缺字漏字、内容缺失、排版错乱等情况,有可能是净化规则或简繁转换出现问题。
|
||||||
* 漫画源看书显示乱码,**阅读与其他软件的源并不通用**,请导入阅读的支持的漫画源!
|
* 漫画源看书显示乱码,**阅读与其他软件的源并不通用**,请导入阅读的支持的漫画源!
|
||||||
|
|
||||||
|
**2022/02/27**
|
||||||
|
|
||||||
|
* APP内编写规则时,对由XPath|JSOUP|CSS组成的规则进行简单的默认补全。
|
||||||
|
|
||||||
|
```
|
||||||
|
对需求文本的获取text
|
||||||
|
对需求文本的img元素(以img结尾)的获取alt属性
|
||||||
|
对需求链接的获取href属性
|
||||||
|
对需求图片的获取src属性
|
||||||
|
详情页预处理存在js/json/正则的不对详情页规则进行补全
|
||||||
|
多条规则只补全最后一条规则
|
||||||
|
书源编辑页点击调试/保存时补全开始生效
|
||||||
|
注意:不改变编辑框内容显示,保存后再次编辑可查看补全后的规则,方便调试时快速修改规则
|
||||||
|
```
|
||||||
|
|
||||||
**2022/02/26**
|
**2022/02/26**
|
||||||
|
|
||||||
* 自动备份检测到webDav已有备份时不会重复备份
|
* 自动备份检测到webDav已有备份时不会重复备份
|
||||||
|
|||||||
@@ -1,17 +1,24 @@
|
|||||||
package io.legado.app.help
|
package io.legado.app.help
|
||||||
|
|
||||||
// 补全时忽略匹配规则
|
// 补全时忽略匹配规则
|
||||||
val completeIgnore=Regex("""\\n|##|@js:|<js>|@Json:|\$.|(text|ownText|textNodes|href|content|html|alt|all|value|src)(\(\)|##.*)?\s*$""")
|
val completeIgnore =
|
||||||
|
Regex("""\\n|##|@js:|<js>|@Json:|\$.|(text|ownText|textNodes|href|content|html|alt|all|value|src)(\(\)|##.*)?\s*$""")
|
||||||
|
|
||||||
// 补全时忽略匹配的规则(仅对详情页预处理规则生效)
|
// 补全时忽略匹配的规则(仅对详情页预处理规则生效)
|
||||||
val completeIgnorePreRule = Regex("""^:|##|@js:|<js>|@Json:|\$.""")
|
val completeIgnorePreRule = Regex("""^:|##|@js:|<js>|@Json:|\$.""")
|
||||||
|
|
||||||
// 匹配从图片获取信息的规则
|
// 匹配从图片获取信息的规则
|
||||||
val imgComplete=Regex("""(?<=(tag\.|[\+/@~>\| \&]))img[@/]text(\(\))?$|^img[@/]text(\(\))?$""",RegexOption.IGNORE_CASE)
|
val imgComplete = Regex(
|
||||||
|
"""(?<=(tag\.|[+/@~>| &]))img[@/]text(\(\))?$|^img[@/]text(\(\))?$""",
|
||||||
|
RegexOption.IGNORE_CASE
|
||||||
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对简单规则进行补全,简化部分书源规则的编写
|
* 对简单规则进行补全,简化部分书源规则的编写
|
||||||
* 该方法仅对对JSOUP/XPath/CSS规则生效
|
* 该方法仅对对JSOUP/XPath/CSS规则生效
|
||||||
* @author 希弥
|
* @author 希弥
|
||||||
* @return 补全后的规则 或 原规则
|
* @return 补全后的规则 或 原规则
|
||||||
* @param rules 需要补全的规则
|
* @param rule 需要补全的规则
|
||||||
* @param preRule 预处理规则
|
* @param preRule 预处理规则
|
||||||
* 用于分析详情页预处理规则
|
* 用于分析详情页预处理规则
|
||||||
* @param type 补全结果的类型,可选的值有:
|
* @param type 补全结果的类型,可选的值有:
|
||||||
@@ -20,13 +27,15 @@ val imgComplete=Regex("""(?<=(tag\.|[\+/@~>\| \&]))img[@/]text(\(\))?$|^img[@/]t
|
|||||||
* 3 图片
|
* 3 图片
|
||||||
*/
|
*/
|
||||||
fun ruleComplete(rule: String?, preRule: String? = "", type: Int = 1): String? {
|
fun ruleComplete(rule: String?, preRule: String? = "", type: Int = 1): String? {
|
||||||
if (rule.isNullOrEmpty()||rule.contains(completeIgnore)||preRule?.contains(completeIgnorePreRule)?:false){
|
if (rule.isNullOrEmpty() || rule.contains(completeIgnore)
|
||||||
|
|| preRule?.contains(completeIgnorePreRule) == true
|
||||||
|
) {
|
||||||
return rule
|
return rule
|
||||||
}
|
}
|
||||||
var textRule:String
|
val textRule: String
|
||||||
var linkRule:String
|
val linkRule: String
|
||||||
var imgRule:String
|
val imgRule: String
|
||||||
var imgText:String
|
val imgText: String
|
||||||
if (rule.contains(Regex("/[^@]+$"))) {
|
if (rule.contains(Regex("/[^@]+$"))) {
|
||||||
textRule = "/text()"
|
textRule = "/text()"
|
||||||
linkRule = "/@href"
|
linkRule = "/@href"
|
||||||
|
|||||||
@@ -363,7 +363,8 @@ class BookSourceEditActivity :
|
|||||||
"intro" -> bookInfoRule.intro = ruleComplete(it.value, bookInfoRule.init)
|
"intro" -> bookInfoRule.intro = ruleComplete(it.value, bookInfoRule.init)
|
||||||
"updateTime" -> bookInfoRule.updateTime = ruleComplete(it.value, bookInfoRule.init)
|
"updateTime" -> bookInfoRule.updateTime = ruleComplete(it.value, bookInfoRule.init)
|
||||||
"wordCount" -> bookInfoRule.wordCount = ruleComplete(it.value, bookInfoRule.init)
|
"wordCount" -> bookInfoRule.wordCount = ruleComplete(it.value, bookInfoRule.init)
|
||||||
"lastChapter" -> bookInfoRule.lastChapter = ruleComplete(it.value,bookInfoRule.init)
|
"lastChapter" -> bookInfoRule.lastChapter =
|
||||||
|
ruleComplete(it.value, bookInfoRule.init)
|
||||||
"coverUrl" -> bookInfoRule.coverUrl = ruleComplete(it.value, bookInfoRule.init, 3)
|
"coverUrl" -> bookInfoRule.coverUrl = ruleComplete(it.value, bookInfoRule.init, 3)
|
||||||
"tocUrl" -> bookInfoRule.tocUrl = ruleComplete(it.value, bookInfoRule.init, 2)
|
"tocUrl" -> bookInfoRule.tocUrl = ruleComplete(it.value, bookInfoRule.init, 2)
|
||||||
"canReName" -> bookInfoRule.canReName = it.value
|
"canReName" -> bookInfoRule.canReName = it.value
|
||||||
|
|||||||
Reference in New Issue
Block a user