From d42d738d676627b562b3b7ed3d5de874b6c4cb43 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 14 Oct 2020 21:13:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/BookHelp.kt | 5 ++--- .../java/io/legado/app/model/localBook/AnalyzeTxtFile.kt | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/BookHelp.kt b/app/src/main/java/io/legado/app/help/BookHelp.kt index 36a193fa0..ae992e696 100644 --- a/app/src/main/java/io/legado/app/help/BookHelp.kt +++ b/app/src/main/java/io/legado/app/help/BookHelp.kt @@ -322,11 +322,10 @@ object BookHelp { } val contents = arrayListOf() c.split("\n").forEach { - val str = it.replace("^\\s+".toRegex(), "") - .replace("\r", "") + val str = it.replace("^[\\n\\s\\r]+".toRegex(), "") if (contents.isEmpty()) { contents.add(title) - if (str != title && it.isNotEmpty()) { + if (str != title && str.isNotEmpty()) { contents.add("${ReadBookConfig.paragraphIndent}$str") } } else if (str.isNotEmpty()) { diff --git a/app/src/main/java/io/legado/app/model/localBook/AnalyzeTxtFile.kt b/app/src/main/java/io/legado/app/model/localBook/AnalyzeTxtFile.kt index b7f1b015e..6dfa74594 100644 --- a/app/src/main/java/io/legado/app/model/localBook/AnalyzeTxtFile.kt +++ b/app/src/main/java/io/legado/app/model/localBook/AnalyzeTxtFile.kt @@ -261,6 +261,8 @@ class AnalyzeTxtFile { bookStream.seek(bookChapter.start!!) bookStream.read(content) return String(content, book.fileCharset()) + .substringAfter(bookChapter.title) + .replace("^[\\n\\s]+".toRegex(), "  ") } private fun getBookFile(book: Book): File {