Update HtmlFormatter.kt

优化
pull/1126/head
bushixuanqi 3 years ago committed by GitHub
parent bde4480190
commit 9bbcb6b64b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/src/main/java/io/legado/app/utils/HtmlFormatter.kt

@ -23,7 +23,7 @@ object HtmlFormatter {
html ?: return "" html ?: return ""
val keepImgHtml = html.replace(wrapHtmlRegex, "\n") val keepImgHtml = html.replace(wrapHtmlRegex, "\n")
.replace(notImgHtmlRegex, "") .replace(notImgHtmlRegex, "")
.replace("[\\n\\s]+\$|^[\\n\\s]*".toRegex(), "") .replace("[\\n\\s]+\$|^[\\n\\s]+".toRegex(), "")
.replace("\\s*\\n+\\s*".toRegex(), "\n") .replace("\\s*\\n+\\s*".toRegex(), "\n")
val sb = StringBuffer() val sb = StringBuffer()
@ -36,7 +36,7 @@ object HtmlFormatter {
val urlBefore = url.substringBefore(',') val urlBefore = url.substringBefore(',')
val strBefore = keepImgHtml.substring(appendPos, matcher.start()) val strBefore = keepImgHtml.substring(appendPos, matcher.start())
sb.append( sb.append(
if(strBefore.isBlank()) '\n' else strBefore.replace("\n", "\n  ") //缩进图片之间的非空白段落 if(strBefore.isBlank()) strBefore else strBefore.replace("\n", "\n  ") //缩进图片之间的非空白段落
) )
sb.append( sb.append(
"<img src=\"${ "<img src=\"${

Loading…
Cancel
Save