mirror of
https://github.com/gedoor/legado.git
synced 2024-07-06 23:47:49 +08:00
优化
This commit is contained in:
parent
6979054a57
commit
88476f7a82
@ -45,9 +45,20 @@ class AnalyzeByJSoup(doc: Any) {
|
||||
/**
|
||||
* 合并内容列表,得到内容
|
||||
*/
|
||||
internal fun getString(ruleStr: String) =
|
||||
if (ruleStr.isEmpty()) null
|
||||
else getStringList(ruleStr).takeIf { it.isNotEmpty() }?.joinToString("\n")
|
||||
internal fun getString(ruleStr: String): String? {
|
||||
if (ruleStr.isEmpty()) {
|
||||
return null
|
||||
}
|
||||
val list = getStringList(ruleStr)
|
||||
if (list.isEmpty()) {
|
||||
return null
|
||||
}
|
||||
if (list.size == 1){
|
||||
return list.first()
|
||||
}
|
||||
return list.joinToString("\n")
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取一个字符串
|
||||
|
@ -295,9 +295,12 @@ class AnalyzeRule(
|
||||
}
|
||||
}
|
||||
if (result == null) result = ""
|
||||
val str = if (unescape) {
|
||||
StringEscapeUtils.unescapeHtml4(result.toString())
|
||||
} else result.toString()
|
||||
val resultStr = result.toString()
|
||||
val str = if (unescape && resultStr.indexOf('&') > -1) {
|
||||
StringEscapeUtils.unescapeHtml4(resultStr)
|
||||
} else {
|
||||
resultStr
|
||||
}
|
||||
if (isUrl) {
|
||||
return if (str.isBlank()) {
|
||||
baseUrl ?: ""
|
||||
|
@ -137,8 +137,11 @@ object LocalBook {
|
||||
"获取本地书籍内容失败\n${e.localizedMessage}"
|
||||
}
|
||||
if (book.isEpub) {
|
||||
content = content?.replace("<img", "< img", true) ?: return null
|
||||
return StringEscapeUtils.unescapeHtml4(content)
|
||||
content ?: return null
|
||||
if (content.indexOf('&') > -1) {
|
||||
content = content.replace("<img", "< img", true)
|
||||
return StringEscapeUtils.unescapeHtml4(content)
|
||||
}
|
||||
}
|
||||
return content
|
||||
}
|
||||
|
@ -169,7 +169,9 @@ object BookContent {
|
||||
//获取正文
|
||||
var content = analyzeRule.getString(contentRule.content, unescape = false)
|
||||
content = HtmlFormatter.formatKeepImg(content, rUrl)
|
||||
content = StringEscapeUtils.unescapeHtml4(content)
|
||||
if (content.indexOf('&') > -1) {
|
||||
content = StringEscapeUtils.unescapeHtml4(content)
|
||||
}
|
||||
//获取下一页链接
|
||||
if (getNextPageUrl) {
|
||||
val nextUrlRule = contentRule.nextContentUrl
|
||||
|
Loading…
Reference in New Issue
Block a user