wp-epub-gen 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/index.js +10 -5
- package/build/libs/safeFineName.d.ts +6 -0
- package/cpi.epub +0 -0
- package/package.json +1 -1
- /package/build/{utils.d.ts → libs/utils.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -80,7 +80,7 @@ epubGen(option).then(
|
|
|
80
80
|
- `appendChapterTitle`:
|
|
81
81
|
optional, Automatically append the chapter title at the beginning of current chapter, this value will overwrite the global `appendChapterTitles`.
|
|
82
82
|
- `verbose`:
|
|
83
|
-
specify whether
|
|
83
|
+
specify whether to console.log progress messages, default: false.
|
|
84
84
|
- `timeoutSeconds`:
|
|
85
85
|
specify timeout in seconds, `0` means no timeout, default: 0.
|
|
86
86
|
- `tocAutoNumber`:
|
package/build/index.js
CHANGED
|
@@ -43,20 +43,25 @@ const errors = {
|
|
|
43
43
|
no_title: "Title is required.",
|
|
44
44
|
no_content: "Content is required."
|
|
45
45
|
};
|
|
46
|
+
function safeFineName(name) {
|
|
47
|
+
return name.replace(/[/\\?%*:|"<>\t\r\n]/g, "_");
|
|
48
|
+
}
|
|
46
49
|
function parseContent(content, index, epubConfigs) {
|
|
47
50
|
let chapter = { ...content };
|
|
48
|
-
|
|
51
|
+
let { filename } = chapter;
|
|
52
|
+
if (!filename) {
|
|
49
53
|
let titleSlug = uslug(diacritics.remove(chapter.title || "no title"));
|
|
50
54
|
titleSlug = titleSlug.replace(/[\/\\]/g, "_");
|
|
51
55
|
chapter.href = `${index}_${titleSlug}.xhtml`;
|
|
52
56
|
chapter.filePath = path.join(epubConfigs.dir, "OEBPS", chapter.href);
|
|
53
57
|
} else {
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
filename = safeFineName(filename);
|
|
59
|
+
let is_xhtml = filename.endsWith(".xhtml");
|
|
60
|
+
chapter.href = is_xhtml ? filename : `${filename}.xhtml`;
|
|
56
61
|
if (is_xhtml) {
|
|
57
|
-
chapter.filePath = path.join(epubConfigs.dir, "OEBPS",
|
|
62
|
+
chapter.filePath = path.join(epubConfigs.dir, "OEBPS", filename);
|
|
58
63
|
} else {
|
|
59
|
-
chapter.filePath = path.join(epubConfigs.dir, "OEBPS", `${
|
|
64
|
+
chapter.filePath = path.join(epubConfigs.dir, "OEBPS", `${filename}.xhtml`);
|
|
60
65
|
}
|
|
61
66
|
}
|
|
62
67
|
chapter.id = `item_${index}`;
|
package/cpi.epub
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
File without changes
|