From 74754739480ae60e24f2ae91951f93e02e9604ec Mon Sep 17 00:00:00 2001 From: bushixuanqi <57338301+bushixuanqi@users.noreply.github.com> Date: Sat, 17 Jul 2021 04:37:20 +0800 Subject: [PATCH] Update HtmlFormatter.kt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化 --- .../main/java/io/legado/app/utils/HtmlFormatter.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt b/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt index 0f6aa3d71..5f69f5b9f 100644 --- a/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt +++ b/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt @@ -59,17 +59,17 @@ object HtmlFormatter { do{ val url = matcher.group(1)!! - val pos = url.indexOf(',') + val urlBefore = url.substringBefore(',') val beforeStr = keepImgHtml.substring(appendPos, matcher.start()) sb.append( if(beforeStr == "\n") '\n' else beforeStr.replace("\n","\n  ") ) //缩进换行下个非图片段落 sb.append( "" ) appendPos = matcher.end() @@ -79,7 +79,8 @@ object HtmlFormatter { } if (appendPos < keepImgHtml.length) { - sb.append(keepImgHtml.substring(appendPos, keepImgHtml.length).replace("\n","\n  ")) //非图片部分换行缩减 + val beforeStr = keepImgHtml.substring(appendPos, keepImgHtml.length) + sb.append( if(beforeStr == "\n") '\n' else beforeStr.replace("\n","\n  ") ) //缩进换行下个非图片段落 } return sb.toString() }