修复xpath获取alt属性规则

pull/1653/head
syomie 3 years ago
parent de41eac7a1
commit 510ee30f44
  1. 5
      app/src/main/java/io/legado/app/help/ruleComplete.kt

@ -26,18 +26,21 @@ fun ruleComplete(rule:String?,preRule:String?="",type:Int=1):String?{
var textRule:String var textRule:String
var linkRule:String var linkRule:String
var imgRule:String var imgRule:String
var imgText:String
if (rule.contains(Regex("/[^@]+$"))){ if (rule.contains(Regex("/[^@]+$"))){
textRule="/text()" textRule="/text()"
linkRule="/@href" linkRule="/@href"
imgRule="/@src" imgRule="/@src"
imgText="img/@alt"
}else{ }else{
textRule="@text" textRule="@text"
linkRule="@href" linkRule="@href"
imgRule="@src" imgRule="@src"
imgText="img@alt"
} }
var ret:String=rule var ret:String=rule
when(type){ when(type){
1 -> ret = rule.replace(Regex("$"),textRule).replace(imgComplete,"img@alt") 1 -> ret = rule.replace(Regex("$"),textRule).replace(imgComplete,imgText)
2 -> ret = rule.replace(Regex("$"),linkRule) 2 -> ret = rule.replace(Regex("$"),linkRule)
3 -> ret = rule.replace(Regex("$"),imgRule) 3 -> ret = rule.replace(Regex("$"),imgRule)
} }

Loading…
Cancel
Save