pull/32/head
kunfei 5 years ago
parent 354e00794e
commit 08867d1fa5
  1. 2
      app/build.gradle
  2. 23
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt

@ -82,7 +82,7 @@ dependencies {
implementation 'androidx.core:core-ktx:1.2.0-alpha02' implementation 'androidx.core:core-ktx:1.2.0-alpha02'
implementation 'androidx.appcompat:appcompat:1.1.0-rc01' implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.preference:preference:1.1.0-rc01' implementation 'androidx.preference:preference:1.1.0-rc01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2' implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta1'
implementation 'com.google.android.material:material:1.1.0-alpha07' implementation 'com.google.android.material:material:1.1.0-alpha07'
implementation 'com.google.android:flexbox:1.1.0' implementation 'com.google.android:flexbox:1.1.0'

@ -133,16 +133,6 @@ class AnalyzeByJSoup {
} }
} }
} }
if (!isEmpty(sourceRule.replaceRegex)) {
val tempList = ArrayList(textS)
textS.clear()
for (text in tempList) {
val tmpText = text.replace(sourceRule.replaceRegex.toRegex(), sourceRule.replacement)
if (tmpText.isNotEmpty()) {
textS.add(tmpText)
}
}
}
return textS return textS
} }
@ -409,24 +399,13 @@ class AnalyzeByJSoup {
internal inner class SourceRule(ruleStr: String) { internal inner class SourceRule(ruleStr: String) {
var isCss = false var isCss = false
var elementsRule: String var elementsRule: String
var replaceRegex = ""
var replacement = ""
init { init {
if (ruleStr.startsWith("@CSS:", true)) { if (ruleStr.startsWith("@CSS:", true)) {
isCss = true isCss = true
elementsRule = ruleStr.substring(5).trim { it <= ' ' } elementsRule = ruleStr.substring(5).trim { it <= ' ' }
} else { } else {
val ruleStrS: Array<String> = elementsRule = ruleStr
ruleStr.trim { it <= ' ' }.split("#".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
//分离正则表达式
elementsRule = ruleStrS[0]
if (ruleStrS.size > 1) {
replaceRegex = ruleStrS[1]
}
if (ruleStrS.size > 2) {
replacement = ruleStrS[2]
}
} }
} }
} }

Loading…
Cancel
Save