使用a2x和ZIP创建epub [英] Creating epub with a2x versus ZIP

查看:84
本文介绍了使用a2x和ZIP创建epub的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

  $ a2x -v -k -f epub -d book book.asca2x:存档:mimetypea2x:归档:META-INF/container.xmla2x:归档:OEBPS/ch01.htmla2x:归档:OEBPS/ch02.htmla2x:归档:OEBPS/content.opfa2x:归档:OEBPS/docbook-xsl.cssa2x:归档:OEBPS/index.htmla2x:归档:OEBPS/pr01.htmla2x:归档:OEBPS/toc.ncx 

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

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

我怀疑这是因为档案文件的路径中包含 book.epub.d .有办法排除这种情况吗?

解决方案

这是我成功使用的命令:

  zip -Xr epubfilename.ePUB模仿类型META-INF OEBPS -x \ *.DS_Store 

这将以正确的顺序放置文件(首先是MIME类型,然后是带有容器.xml的META-INF,最后是其他所有文件),并且排除了.DS_store,因为它看起来就像在Mac上一样.

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

我还建议使用epubcheck( https://github.com/IDPF/epubcheck 仔细检查结果或 http://validator.idpf.org )(如果尚未这样做的话).

Using this a2x command creates a valid .epub file (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

However, if I try to manually create an .epub archive using the artifacts (contained in book.epub.d) of the a2x command and zip command, the resulting .epub file is not valid:

$ 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%)

I suspect this is because the archive's files include book.epub.d in the paths. Is there a way to exclude this?

解决方案

Here is the command I have used successfully:

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

This places files in the right order (mime type first, then META-INF with container.xml next, finally everything else) and excludes .DS_store since it looks like you are on a Mac.

Note that you will need to do this from within the book.epub.d directory in your example to produce the correct output.

I also recommend double checking results with epubcheck (https://github.com/IDPF/epubcheck or http://validator.idpf.org) if you are not already doing so.

这篇关于使用a2x和ZIP创建epub的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆