Merge pull request #1079 from ag2s20150909/master

fix:修复一些书籍导出epub失败
pull/1090/head
kunfei 4 years ago committed by GitHub
commit 2ef9b1d40b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      app/src/main/assets/epub/chapter.html
  2. 3
      app/src/main/assets/epub/cover.html
  3. 3
      app/src/main/assets/epub/intro.html
  4. 5
      app/src/main/java/io/legado/app/model/localBook/EpubFile.kt
  5. 2
      app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt
  6. 14
      epublib/src/main/java/me/ag2s/epublib/util/ResourceUtil.java

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Chapter</title>

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Cover</title>

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN">
<head>
<title>Intro</title>

@ -30,10 +30,11 @@ class EpubFile(var book: Book) {
@Synchronized
private fun getEFile(book: Book): EpubFile {
BookHelp.getEpubFile(book)
//对于Epub文件默认不启用替换
book.setUseReplaceRule(false)
if (eFile == null || eFile?.book?.bookUrl != book.bookUrl) {
eFile = EpubFile(book)
//对于Epub文件默认不启用替换
book.setUseReplaceRule(false)
return eFile!!
}
eFile?.book = book

@ -233,7 +233,7 @@ class CacheViewModel(application: Application) : BaseViewModel(application) {
}
private fun setAssets(doc: DocumentFile, book: Book, epubBook: EpubBook): String {
if(!AppConfig.isGooglePlay) return setAssets(book, epubBook)
if(!(AppConfig.isGooglePlay|| appCtx.packageName.contains("debug",true))) return setAssets(book, epubBook)
var contentModel = ""
DocumentUtils.getDirDocument(doc, "Asset").let { customPath ->

@ -43,17 +43,17 @@ public class ResourceUtil {
if (title.contains("</span>"))
title = "<span class=\"chapter-sequence-number\">" + title;
}
String html = model.replaceAll("\\{title\\}", title)
.replaceAll("\\{content\\}", StringUtil.formatHtml(txt));
String html = model.replace("{title}", title)
.replace("{content}", StringUtil.formatHtml(txt));
return new Resource(html.getBytes(), href);
}
public static Resource createPublicResource(String name, String author, String intro, String kind, String wordCount, String model, String href) {
String html = model.replaceAll("\\{name\\}", name)
.replaceAll("\\{author\\}", author)
.replaceAll("\\{kind\\}", kind)
.replaceAll("\\{wordCount\\}", wordCount)
.replaceAll("\\{intro\\}", StringUtil.formatHtml(intro));
String html = model.replace("{name}", name)
.replace("{author}", author)
.replace("{kind}", kind)
.replace("{wordCount}", wordCount)
.replace("{intro}", StringUtil.formatHtml(intro));
return new Resource(html.getBytes(), href);
}

Loading…
Cancel
Save