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 {