Simple minimalistic library for creating EPUB3 files
Project description
mkepub
mkepub is a minimalistic library for creating .epub files.
Pros:
- Easy to use, minimalistic API.
- Automatically generated TOC.
- Support for nested TOC of any depth.
- Support for embedded images.
- Support for embedded fonts.
- In-progress books are stored on disk rather than in memory, enabling creation of large (5000+ pages, 20+ MiBs) epub files.
- Adherence to the EPUB3 specs.
- Support for most of the EPUB metadata, including language, subject, description, and rights.
Cons:
- No support for custom page filenames or directory structure.
- No support for reading or editing epub files.
- No content validation - using broken or unsupported html code as page content will lead to mkepub successfully creating a .epub file that does not meet EPUB3 specifications.
- Probably other issues.
Basic Usage
import mkepub
book = mkepub.Book(title='An Example')
book.add_page(title='First Page', content='Lorem Ipsum etcetera.')
book.save('example.epub')
Advanced Usage
import mkepub
book = mkepub.Book(title='Advanced Example', author='The Author')
# multiple authors can be specified as a list:
# mkepub.Book(title='Advanced Example', authors=['The First Author', 'The Second Author'])
book.set_cover_from_file('cover.jpg')
book.set_stylesheet_from_file('style.css')
first = book.add_page('Chapter 1', 'And so the book begins.')
child = book.add_page('Chapter 1.1', 'Nested TOC is supported.', parent=first)
book.add_page('Chapter 1.1.1', 'Infinite nesting levels', parent=child)
book.add_page('Chapter 1.2', 'In any order you wish.', parent=first)
book.add_page('Chapter 2', 'Use <b>html</b> to make your text <span class="pink">prettier</span>')
book.add_page('Chapter 3: Images', '<img src="images/chapter3.png" alt="You can use images as well">')
# as long as you add them to the book:
with open('chapter3.png', 'rb') as file:
book.add_image('chapter3.png', file.read())
# you can also add custom fonts to the book
book.add_font_from_file('your_font.woff')
book.save('advanced.epub')
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mkepub-1.2.2.tar.gz
(8.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mkepub-1.2.2.tar.gz.
File metadata
- Download URL: mkepub-1.2.2.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8a38cccb6100f452074b2bf6789e3cbd3e3fe41173764df74ae4c5fd79c574e
|
|
| MD5 |
483eba9321b850095cb8bc9a16bec84b
|
|
| BLAKE2b-256 |
54e7660a77ce993719d8afd9adda862aa467770b90061c9c6b37ecf50fcc7266
|
File details
Details for the file mkepub-1.2.2-py3-none-any.whl.
File metadata
- Download URL: mkepub-1.2.2-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ccdf41f614fdb2a709b3a4aa664edb6d795438896a21bfaabfbdf7b773b9b4f
|
|
| MD5 |
1fd385527a320c16c0080a5f0c4294bc
|
|
| BLAKE2b-256 |
7d82a8ed5e82dbbd687b9689b1785d52e877a06a6ea87831858e1c2ff9b8d469
|