Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/anqxyr/mkepub
Simple minimalistic library for creating EPUB3 files
https://github.com/anqxyr/mkepub
epub epub-files epub-generation minimalist-library
Last synced: about 1 month ago
JSON representation
Simple minimalistic library for creating EPUB3 files
- Host: GitHub
- URL: https://github.com/anqxyr/mkepub
- Owner: anqxyr
- License: mit
- Created: 2016-10-31T19:08:01.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-07-21T16:54:02.000Z (over 1 year ago)
- Last Synced: 2024-10-01T20:17:36.973Z (2 months ago)
- Topics: epub, epub-files, epub-generation, minimalist-library
- Language: Python
- Size: 188 KB
- Stars: 73
- Watchers: 7
- Forks: 16
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- my-awesome-github-stars - anqxyr/mkepub - Simple minimalistic library for creating EPUB3 files (Python)
README
[![Build Status](https://travis-ci.org/anqxyr/mkepub.svg?branch=master)](https://travis-ci.org/anqxyr/mkepub)
[![Coverage Status](https://coveralls.io/repos/github/anqxyr/mkepub/badge.svg?branch=master)](https://coveralls.io/github/anqxyr/mkepub?branch=master)
[![license](https://img.shields.io/github/license/anqxyr/mkepub.svg?maxAge=2592000)](https://github.com/anqxyr/mkepub/LICENSE)# 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
```python
import mkepubbook = mkepub.Book(title='An Example')
book.add_page(title='First Page', content='Lorem Ipsum etcetera.')
book.save('example.epub')
```### Advanced Usage
```python
import mkepubbook = 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'])
with open('cover.jpg', 'rb') as file:
book.set_cover(file.read())
with open('style.css') as file:
book.set_stylesheet(file.read())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 html to make your text prettier')
book.add_page('Chapter 3: Images', '')
# as long as you add them to the book:
with open('chapter3.png', 'rb') as file:
book.add_image('chapter3.png', file.read())book.save('advanced.epub')
```