|
|
@ -124,8 +124,11 @@ object BookHelp { |
|
|
|
var bookOrigin: String? = null |
|
|
|
var bookOrigin: String? = null |
|
|
|
var replaceRules: List<ReplaceRule> = arrayListOf() |
|
|
|
var replaceRules: List<ReplaceRule> = arrayListOf() |
|
|
|
|
|
|
|
|
|
|
|
fun disposeContent(name: String, origin: String?, content: String, enableReplace: Boolean) |
|
|
|
fun disposeContent( |
|
|
|
: String { |
|
|
|
name: String, origin: String?, |
|
|
|
|
|
|
|
content: String, |
|
|
|
|
|
|
|
enableReplace: Boolean |
|
|
|
|
|
|
|
): String { |
|
|
|
var c = content |
|
|
|
var c = content |
|
|
|
synchronized(this) { |
|
|
|
synchronized(this) { |
|
|
|
if (enableReplace && (bookName != name || bookOrigin != origin)) { |
|
|
|
if (enableReplace && (bookName != name || bookOrigin != origin)) { |
|
|
@ -137,12 +140,12 @@ object BookHelp { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
for (item in replaceRules) { |
|
|
|
for (item in replaceRules) { |
|
|
|
item.pattern?.let { |
|
|
|
item.pattern.let { |
|
|
|
if (it.isNotEmpty()) { |
|
|
|
if (it.isNotEmpty()) { |
|
|
|
c = if (item.isRegex) { |
|
|
|
c = if (item.isRegex) { |
|
|
|
c.replace(it.toRegex(), item.replacement ?: "") |
|
|
|
c.replace(it.toRegex(), item.replacement) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
c.replace(it, item.replacement ?: "") |
|
|
|
c.replace(it, item.replacement) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|