制作简单 EPUB 包的工具。
项目描述
小出版商
一个轻松制作简单 epub 包的工具。
安装
pip install tinypublisher
用法
快速使用
在下文中,该tinypublish命令test.epub从 jpeg 文件列表中生成文件。
% ls examples/foo/*.jpg
examples/foo/00 a.jpg examples/foo/02 c.jpg examples/foo/04 e.jpg
examples/foo/01 b.jpg examples/foo/03 d.jpg
% ls -1 examples/foo/*.jpg | tinypublish test
tinypublisher.builder.INFO: making a build dir
-- build
tinypublisher.builder.INFO: making a Package Document
-- build/test/book/package.opf
tinypublisher.builder.INFO: making a Navigation Document
-- build/test/book/navigation.xhtml
tinypublisher.builder.INFO: copying "examples/foo/00 a.jpg" to
-- build/test/book/items/examples/foo/00 a.jpg
tinypublisher.builder.INFO: making a page
-- build/test/book/items/examples/foo/00 a.jpg.xhtml
tinypublisher.builder.INFO: copying "examples/foo/01 b.jpg" to
-- build/test/book/items/examples/foo/01 b.jpg
tinypublisher.builder.INFO: making a page
-- build/test/book/items/examples/foo/01 b.jpg.xhtml
tinypublisher.builder.INFO: copying "examples/foo/02 c.jpg" to
-- build/test/book/items/examples/foo/02 c.jpg
tinypublisher.builder.INFO: making a page
-- build/test/book/items/examples/foo/02 c.jpg.xhtml
tinypublisher.builder.INFO: copying "examples/foo/03 d.jpg" to
-- build/test/book/items/examples/foo/03 d.jpg
tinypublisher.builder.INFO: making a page
-- build/test/book/items/examples/foo/03 d.jpg.xhtml
tinypublisher.builder.INFO: copying "examples/foo/04 e.jpg" to
-- build/test/book/items/examples/foo/04 e.jpg
tinypublisher.builder.INFO: making a page
-- build/test/book/items/examples/foo/04 e.jpg.xhtml
tinypublisher.builder.INFO: making a EPUB package
-- build/test.epub
tinypublish --帮助
usage: tinypublish [-h] [--unzipped] [-c cover-image] [-t title]
[-l language-tag] [-a author-name] [--id identifier]
[--uuid dns-name] [-s file-list]
package-name
A tool to buid a EPUB package easily.
positional arguments:
package-name EPUB Package directory and make the file
<package-name>.epub
optional arguments:
-h, --help show this help message and exit
--unzipped make the package unzipped
-c cover-image, --cover cover-image
used for <item properties="cover-image"
href="<cover-image>"/>
-t title, --title title
if not, <package-name> is used for the book title
-l language-tag, --language language-tag
if not, use the `lang` attribute of the content
documents. if there is no `lang` attribute, use the
`os.environ["LANG"]`
-a author-name, --author author-name
used for <dc:creator> element of the package document
--id identifier used for <dc:identifier> element of the package document
--uuid dns-name if the <identifier> is not specified, use this value for
generate the package unique identifier with
`uuid5(NAMESPACE_DNS, <dns-name>)`. if both are not
specified, generated by `uuid4()`
-s file-list, --spine file-list
a tab-separated-values file that each line is the spine
element for the package. you can also read this list
from the standard input
File-list format:
<file-list> ::= <entry>+
<entry> ::= <path> [ "\t" <use-nav> [ "\t" <caption> ] ] "\n"
<use-nav> ::= <index-title> | "-" | ""
<caption> ::= <content-caption> | "-"
<path>
A path to XHTML, SVG, or image file. The path should be relative to this
file list.
That XHTML and SVG files are used as content documents (EPUB 3.2). Other
media files are embedded in a XHTML file for each. If you want to embed
that SVG into XHTML, you should add a <content-caption>.
<index-title>
Indicates that document linked from a table of contents.
If it is specified to "-", the title of content document, text contents,
or the basename of the file is used as the index title.
<content-caption>
When the <path>'s media type is image type, this value used as a content
of figcaption tag of the wrapping XHTML.
if the <path> points to an SVG and this cell is specified, the SVG is
embedded in a XHTML file. Then, if it is "-", this value is the SVG's
title data or the basename of the file.
文件列表格式示例
以下示例是一个制表符分隔值文件(制表符表示[_TAB_]可见性):
01.png[_TAB_]The first page
02.xhtml
03.svg[_TAB_]-
04.svg[_TAB_][_______TAB________]-
05.jpg[_TAB_]The last page[_TAB_]Goodbye<br/>Sayoonara
第一列是书脊内容的路径,第二列是用于目录的标题,第三列是图像内容的标题。
该文件存在于tests/assets/spine.tsv中。您可以按以下方式构建它:
% tinypublish test -t "my test" -c tests/assets/cover.png -s tests/assets/spine.tsv
然后 EPUB 包将在tests/assets/build/test.epub.
包装文件
包装文件在tests/assets/build/test/book/package.opf. 其内容如下:
...
<manifest>
<item href="navigation.xhtml" id="navigation" media-type="application/xhtml+xml" properties="nav"/>
<item href="items/01.png" id="item1" media-type="image/png"/>
<item href="items/01.png.xhtml" id="item3" media-type="application/xhtml+xml"/>
<item href="items/02.xhtml" id="item4" media-type="application/xhtml+xml"/>
<item href="items/03.svg" id="item5" media-type="image/svg+xml"/>
<item href="items/04.svg.xhtml" id="item7" media-type="application/xhtml+xml"/>
<item href="items/05.jpg" id="item8" media-type="image/jpeg"/>
<item href="items/05.jpg.xhtml" id="item10" media-type="application/xhtml+xml"/>
<item href="items/02.js" id="item11" media-type="application/javascript"/>
<item href="items/mark3.svg" id="item12" media-type="image/svg+xml"/>
<item href="items/style.css" id="item13" media-type="text/css"/>
<item href="items/star2.gif" id="item14" media-type="image/gif"/>
<item href="items/star1.gif" id="item15" media-type="image/gif"/>
<item href="items/cover.png" id="item16" media-type="image/png" properties="cover-image"/>
</manifest>
<spine>
<itemref idref="item3"/>
<itemref idref="item4"/>
<itemref idref="item5"/>
<itemref idref="item7"/>
<itemref idref="item10"/>
</spine>
...
由于文件列表的第三个条目 ( 03.svg) 没有标题,03.svg因此用于内容文档。另一方面,第四个条目 ( 04.svg) 有一个标题 ( -),因此04.svg嵌入到书脊项04.svg.xhtml中。
导航文件
导航文档在tests/assets/build/test/book/navigation.xhtml. 其内容如下:
...
<nav epub:type="toc" id="toc">
<ol>
<li><a href="items/01.png.xhtml">The first page</a></li>
<li><a href="items/03.svg">03.svg: This is a co…</a></li>
<li><a href="items/05.jpg.xhtml">The last page</a></li>
</ol>
</nav>
...
在文件列表中,三个条目 ( 01.png, 03.svg, 05.jpg) 具有索引标题,因此目录具有指向每个内容文档 ( 01.png.xhtml, 03.svg, 05.jpg.xhtml) 的三个链接。但是如果没有书脊内容有索引标题,就像上面的快速使用示例一样,那么每个书脊内容文档都会被列出并标记其文件名。
未来考虑
- 使图像布局看起来不错
- 使用 svg 包装图像
- 指定阅读方向
- 处理涉外资源怎么办
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
tinypublisher-0.3.2.tar.gz
(16.3 kB
查看哈希)
内置分布
tinypublisher-0.3.2-py3-none-any.whl
(17.3 kB
查看哈希)
关
tinypublisher -0.3.2.tar.gz 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | 394cda6ee22b47a768fcee8cf4d999cf85620d1da90efb153633ba2799e5095d |
|
| MD5 | 88e86f013e3bf3c118d9ebfa8e58550d |
|
| 布莱克2-256 | da379a7ae4839438e0727cb078573f3a5cc4a3bec030063af13e2e6c5a1fbe02 |
关
tinypublisher -0.3.2-py3-none-any.whl 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | bdd7dfe1e3501e676c2e01a64a8b05bfdec99647863a546b91ca378a488a7157 |
|
| MD5 | d538b4460d0b32349e76b40bf3665f32 |
|
| 布莱克2-256 | b652bd5d8978c697ba913aa239d6c6a2fc5032f99cf6bd6c26e9168ea85ecc2b |