pull/1303/head
gedoor 3 years ago
parent be74d3dd8b
commit 9ea725b2ca
  1. 5
      app/src/main/java/io/legado/app/help/ContentProcessor.kt
  2. 9
      app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt

@ -56,6 +56,7 @@ class ContentProcessor private constructor(
title: String, //已经经过简繁转换 title: String, //已经经过简繁转换
content: String, content: String,
isRead: Boolean = true, isRead: Boolean = true,
includeTitle: Boolean = true,
useReplace: Boolean = book.getUseReplaceRule() useReplace: Boolean = book.getUseReplaceRule()
): List<String> { ): List<String> {
var content1 = content var content1 = content
@ -91,7 +92,9 @@ class ContentProcessor private constructor(
content1.split("\n").forEach { str -> content1.split("\n").forEach { str ->
val paragraph = str.replace("^[\\n\\r]+".toRegex(), "").trim() val paragraph = str.replace("^[\\n\\r]+".toRegex(), "").trim()
if (contents.isEmpty()) { if (contents.isEmpty()) {
contents.add(title) if (includeTitle) {
contents.add(title)
}
if (paragraph != title && paragraph.isNotEmpty()) { if (paragraph != title && paragraph.isNotEmpty()) {
contents.add("${ReadBookConfig.paragraphIndent}$paragraph") contents.add("${ReadBookConfig.paragraphIndent}$paragraph")
} }

@ -139,18 +139,15 @@ class CacheViewModel(application: Application) : BaseViewModel(application) {
) )
appDb.bookChapterDao.getChapterList(book.bookUrl).forEach { chapter -> appDb.bookChapterDao.getChapterList(book.bookUrl).forEach { chapter ->
BookHelp.getContent(book, chapter).let { content -> BookHelp.getContent(book, chapter).let { content ->
var content1 = contentProcessor val content1 = contentProcessor
.getContent( .getContent(
book, book,
chapter.title.replace("\\r?\\n".toRegex(), " "), chapter.title.replace("\\r?\\n".toRegex(), " "),
content ?: "null", content ?: "null",
false, false,
!AppConfig.exportNoChapterName,
useReplace useReplace
) ).joinToString("\n")
.joinToString("\n")
if(AppConfig.exportNoChapterName){
content1 = content.toString()
}
append.invoke("\n\n$content1") append.invoke("\n\n$content1")
} }
} }

Loading…
Cancel
Save