pull/423/head
gedoor 4 years ago
parent b67bb916ef
commit d42d738d67
  1. 5
      app/src/main/java/io/legado/app/help/BookHelp.kt
  2. 2
      app/src/main/java/io/legado/app/model/localBook/AnalyzeTxtFile.kt

@ -322,11 +322,10 @@ object BookHelp {
} }
val contents = arrayListOf<String>() val contents = arrayListOf<String>()
c.split("\n").forEach { c.split("\n").forEach {
val str = it.replace("^\\s+".toRegex(), "") val str = it.replace("^[\\n\\s\\r]+".toRegex(), "")
.replace("\r", "")
if (contents.isEmpty()) { if (contents.isEmpty()) {
contents.add(title) contents.add(title)
if (str != title && it.isNotEmpty()) { if (str != title && str.isNotEmpty()) {
contents.add("${ReadBookConfig.paragraphIndent}$str") contents.add("${ReadBookConfig.paragraphIndent}$str")
} }
} else if (str.isNotEmpty()) { } else if (str.isNotEmpty()) {

@ -261,6 +261,8 @@ class AnalyzeTxtFile {
bookStream.seek(bookChapter.start!!) bookStream.seek(bookChapter.start!!)
bookStream.read(content) bookStream.read(content)
return String(content, book.fileCharset()) return String(content, book.fileCharset())
.substringAfter(bookChapter.title)
.replace("^[\\n\\s]+".toRegex(), "  ")
} }
private fun getBookFile(book: Book): File { private fun getBookFile(book: Book): File {

Loading…
Cancel
Save