Merge pull request #1129 from bushixuanqi/master

Update HtmlFormatter.kt
pull/1132/head
kunfei 3 years ago committed by GitHub
commit 722325fcca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      app/src/main/java/io/legado/app/utils/HtmlFormatter.kt

@ -50,10 +50,10 @@ object HtmlFormatter {
var appendPos0 = 0 var appendPos0 = 0
val matcher0 = Pattern.compile("<img[^>]*src *= *\"([^\"]+)\"[^>]*>", Pattern.CASE_INSENSITIVE).matcher(strBefore) //格式化普通图片标签 val matcher0 = Pattern.compile("<img[^>]*src *= *\"([^\"]+)\"[^>]*>", Pattern.CASE_INSENSITIVE).matcher(strBefore) //格式化普通图片标签
while (matcher0.find()) { while (matcher0.find()) {
val strBefore0 = strBefore.substring(appendPos0, matcher.start()) val strBefore0 = strBefore.substring(appendPos0, matcher0.start())
sb.append( if (strBefore0.isBlank()) strBefore0 else strBefore0.replace("\n","\n  ")) sb.append( if (strBefore0.isBlank()) strBefore0 else strBefore0.replace("\n","\n  "))
sb.append("<img src=\"${NetworkUtils.getAbsoluteURL(redirectUrl,matcher.group(1)!!)}\">") sb.append("<img src=\"${NetworkUtils.getAbsoluteURL(redirectUrl,matcher0.group(1)!!)}\">")
appendPos0 = matcher.end() appendPos0 = matcher0.end()
} }
strBefore = if (appendPos0 < strBefore.length) strBefore.substring(appendPos0, strBefore.length) else "" strBefore = if (appendPos0 < strBefore.length) strBefore.substring(appendPos0, strBefore.length) else ""
} }

Loading…
Cancel
Save