From da9fe5d8cd6b85d6913dbf2d9a369f5b0560a8dc Mon Sep 17 00:00:00 2001 From: celetor <86599970+celetor@users.noreply.github.com> Date: Tue, 20 Sep 2022 10:14:49 +0800 Subject: [PATCH] =?UTF-8?q?epub=E6=A8=A1=E6=9D=BF=E5=A2=9E=E5=8A=A0ori=5Ft?= =?UTF-8?q?itle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit title: 标题有空格会自动分割,如:"第一章 楔子"会变成"第一章
楔子" ori_title: 原始标题 --- .../me/ag2s/epublib/util/ResourceUtil.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/epublib/src/main/java/me/ag2s/epublib/util/ResourceUtil.java b/epublib/src/main/java/me/ag2s/epublib/util/ResourceUtil.java index ad8ecab91..faf074333 100644 --- a/epublib/src/main/java/me/ag2s/epublib/util/ResourceUtil.java +++ b/epublib/src/main/java/me/ag2s/epublib/util/ResourceUtil.java @@ -36,14 +36,21 @@ public class ResourceUtil { * @return 返回Resource */ public static Resource createChapterResource(String title, String txt, String model, String href) { - if (title.contains("\n")) { - title = "" + title.replaceFirst("\\s*\\n\\s*", "
"); - } else { - title = title.replaceFirst("\\s+", "
"); - if (title.contains("")) - title = "" + title; + //String[] title_list = title.split("\\s+", 2); + //String title_part1 = title_list[0]; + //String title_part2 = ""; + //if (title_list.length == 2) { + // title_part2 = title_list[1]; + //} + String ori_title = title; + title = title.replaceFirst("\\s+", "
"); + if (title.contains("")) { + title = "" + title; } String html = model.replace("{title}", title) + .replace("{ori_title}", ori_title) + //.replace("{title_part1}", title_part1) + //.replace("{title_part2}", title_part2) .replace("{content}", StringUtil.formatHtml(txt)); return new Resource(html.getBytes(), href); }