fix:修复一些书籍导出epub失败

这里没必要使用正则表达式替换。
pull/1079/head
ag2s20150909 4 years ago
parent b2ef18b5a9
commit e73bcc65b9
  1. 5
      app/src/main/java/io/legado/app/model/localBook/EpubFile.kt
  2. 14
      epublib/src/main/java/me/ag2s/epublib/util/ResourceUtil.java

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

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

Loading…
Cancel
Save