0

使用此a2x命令会创建一个有效的 .epub 文件 (book.epub):

$ a2x -v -k -f epub -d book book.asc
a2x: archiving: mimetype
a2x: archiving: META-INF/container.xml
a2x: archiving: OEBPS/ch01.html
a2x: archiving: OEBPS/ch02.html
a2x: archiving: OEBPS/content.opf
a2x: archiving: OEBPS/docbook-xsl.css
a2x: archiving: OEBPS/index.html
a2x: archiving: OEBPS/pr01.html
a2x: archiving: OEBPS/toc.ncx

但是,如果我尝试使用命令和命令的工件(包含在book.epub.d中)手动创建 .epub 存档,则生成的 .epub 文件无效:a2xzip

$ zip -vr book.epub book.epub.d/ -x "*.DS_Store"
  adding: book.epub.d/  (in=0) (out=0) (stored 0%)
  adding: book.epub.d/META-INF/ (in=0) (out=0) (stored 0%)
  adding: book.epub.d/META-INF/container.xml    (in=255) (out=175) (deflated 31%)
  adding: book.epub.d/mimetype  (in=20) (out=20) (stored 0%)
  adding: book.epub.d/OEBPS/    (in=0) (out=0) (stored 0%)
  adding: book.epub.d/OEBPS/ch01.html   (in=1161) (out=686) (deflated 41%)
  adding: book.epub.d/OEBPS/ch02.html   (in=679) (out=414) (deflated 39%)
  adding: book.epub.d/OEBPS/content.opf (in=1288) (out=476) (deflated 63%)
  adding: book.epub.d/OEBPS/docbook-xsl.css (in=5738) (out=1518) (deflated 74%)
  adding: book.epub.d/OEBPS/index.html  (in=1156) (out=590) (deflated 49%)
  adding: book.epub.d/OEBPS/pr01.html   (in=770) (out=485) (deflated 37%)
  adding: book.epub.d/OEBPS/toc.ncx (in=772) (out=325) (deflated 58%)

我怀疑这是因为存档的文件包含book.epub.d在路径中。有没有办法排除这个?

4

2 回答 2

2

我执行一系列 zip 命令来压缩 EPUB:

cd /home/bookdirectory (where mimetype, OEBPS and META-INF are subdirectories)
zip -X book.epub mimetype
zip -r book.epub META-INF
zip -r book.epub OEBPS

我遇到了很长时间的麻烦,直到我发现拉链-X上必不可少。mimetype

我注意到您的 zip exclude 是小写字母x..maybe 将其切换为大写字母?

于 2014-03-25T10:21:19.927 回答
2

这是我成功使用的命令:

zip -Xr epubfilename.ePUB mimetype  META-INF OEBPS -x \*.DS_Store

这会以正确的顺序放置文件(首先是 mime 类型,然后是 META-INF 和 container.xml,最后是其他所有文件)并排除 .DS_store,因为它看起来像在 Mac 上。

请注意,您需要在示例中的 book.epub.d 目录中执行此操作以生成正确的输出。

如果您还没有这样做,我还建议您使用 epubcheck(https://github.com/IDPF/epubcheckhttp://validator.idpf.org )仔细检查结果。

于 2014-03-25T11:03:18.313 回答