gen-epub-book is a loose file to ePub assembly/conversion tool for everyone not afraid of not using Word.
gen-epub-book allows you to assemble ePub e-books using an easy-to-read, easy-to-write plaintext format.
gen-epub-book" is two things:
(1) a plaintext descriptor syntax; and
(2) a (set of) software tool(s), written in a multitude of languages, that assemble that descriptor and files referenced thereby into an ePub e-book.
See the Getting the gist heading for details pertaining to
gen-epub-book's descriptor syntax.
The "design goal" of
gen-epub-book’s descriptor syntax is to make it as consistent and obvious at the first sight as possible.
The idea is that a
gen-epub-book descriptor should be writable by any person with minimal technical knowledge.
gen-epub-book is free software, available under the MIT open source license.
See the License heading for more information.
Any topic related to
gen-epub-book – both the descriptor syntax and the software –
is fair game for discussion over at the
gen-epub-book issue trackers
and this site's issue tracker
I've also set up a GitHub issue for simple questions and clarifications.
I hope that GitHub issue system will lead to good ideas for future improvements to
gen-epub-bookis actually also a set of software tools each of which performing mostly the same function, but being written in a different language. Here is the current list of
gen-epub-book's variations, chronologically:
These variations have mostly the same features, and all differences will be highlighted in this document as they come up.
All compiled variations of
gen-epub-book are stand-alone in that they don't depend on any files other than themselves.
Some of them, however, require additional software during building/installation.
gen-epub-book.awk does not require compilation, which makes it require external binary tools.
Here's the list outlining them, their uses, and where to get them:
|Downloading Network-* data.
Getting random UUID.
|Linux: usually shipped with system, package manager, binary releases.|
Windows: binary releases.
||Packing ePub.||Binary releases.|
||Pre-generation cleanup.||Shipped with system.|
||Assembling e-book in temporary directory.||Shipped with system.|
||Creating temporary directories.||Available everywhere.|
||Proper relative paths for
These tools need to be callable as in the first column – in $PATH or otherwise.
gen-epub-book.awk, of course, requires an implementation of
Each implementation of
has its own quirks and therefore might not work as well as other implementations.
Here's the list outlining some tested
implementations and their support:
||No.||Max supported string length exceeded. |
Not sure if your preferred implementation's supported? Drop a question over at one of the issue trackers – A w k !
gen-epub-book.rsjust requires a roughly modern version of the Rust compiler. Since
gen-epub-book.rsis uploaded to crates.io , you need simply run
$ cargo install gen-epub-book
The resulting executable is fully stand-alone and available in your $PATH if installed via cargo install.
gen-epub-book.scala requires the Scala compiler.
.jars depend only on the Scala runtime library.
Due to the specificity of the Node.js environment,
gen-epub-book.js depends on about 110 other packages. To install it, simply run
$ npm install -g epubify
The resulting "executable" will be in your $PATH.
The same descriptor syntax put into any
gen-epub-book variant with any options passed shall produce (functionally) the same e-book
(if they support a compatible featureset), but some
gen-epub-book variants are configurable in their non–e-book output.
Subheadings include links to manpages with more information.
A temp variable passed from the commandline containing the desired temporary directory (usually $TEMP). This usually yields for -v temp="$TEMP" full argument.
--verbose flag makes
gen-epub-book.rs print information about what it's currently doing.
gen-epub-book's descriptor syntax
This section offers a complete, detailed documentation for the descriptor syntax.
gen-epub-book's descriptor syntax can be divided into lines. Each line is either (a) comprised of three elements:
key: value # ^ separatoror (b) is a comment if that format is not met for the line.
key is any sequence of characters up to the separator.
separator is just :, unless the custom separator feature is enabled.
value is any sequence of characters till the end of line.
All whitespace before and after every element is stripped (removed).
Name: The Taste of MI Name:The Taste of MI Name : The Taste of MI All these lines are comments:
# A marked comment (not that it changes much) An unmarked comment (what) Name The Taste of MI ^ missing separator Name: ^ missing value : The Taste of MI ^ missing key
Each non-comment line forms is an element – a (key, value) pair.
The following table enumerates supported keys and their properties:
|Name||Plain text.||Sets book name/title tag.||Yes.||1|
|Author||Plain text.||Sets book author tag.||Yes.||1|
|Date||RFC3339-compliant date.||Sets book authoring/publishing date.||Yes.||1|
|Language||BCP47-compliant language code.||Sets book language tag.||Yes.||1|
|Content||Path to HTML file.||Includes specified file in e-book.||No.||Any.||See additional content processing.|
|String-Content||HTML text.||Includes raw HTML in e-book.||No.||Any.|
|Image-Content||Path to image file.||Packs specified image file in the e-book and includes centered content therewith.||No.||Any.|
|Network-Image-Content||URL to remote image file.||Downloads and packs specified image file in the e-book and adds centered content therewith.||No.||Any.|
|Cover||Path to image file.||Packs specified image and sets cover to content pointing thereat.||No.||0-1||Exclusive with Network-Cover.|
|Network-Cover||URL to remote image file.||Downloads and packs specified image and sets cover to content pointing thereat.||No.||0-1||Exclusive with Cover.|
|Include||File path.||Packs specified file.||No.||Any.|
|Network-Include||Remote file URL.||Downloads and packs specified file.||No.||Any.|
|Description||File path.||Sets the book's description to the specified file's contents.||No.||0-1||Exclusive with String-Description and Network-Description.|
|String-Description||HTML text.||Sets the book's description to the specified string.||No.||0-1||Exclusive with Description and Network-Description.|
|Network-Description||URL to remote HTML file.||Sets the book's description to the remote file's contents.||No.||0-1||Exclusive with Description and String-Description.|
All local paths are relative to the descriptor file.
This can be changed with the
-Include dirs feature.
simple-content.html => simple-content_html ../cover.jpg => cover.jpg .\../books/../covers/cover.jpg => books-covers-cover.jpg
The included remote files' packed names are the last segment (i.e. the filename) of their URL.
In addition, all Content files are checked for the <!-- ePub title: "TOC_NAME" --> sequence, where TOC_NAME is a sequence of any character except " which is the name to give the content in the Table of Contents.
Features are extensions to the
gen-epub-book descriptor syntax, modifying the behaviour and validity of some lines.
Name: The Taste of MI # With custom separator set to "=" becomes Name = The Taste of MI # Or, with custom separator set to "INCREDIBLE COMMUNISM" becomes Name INCREDIBLE COMMUNISM The Taste of MI
gen-epub-bookto accept non-RFC3339 date formats, whichever it can. For example, with free date format feature on these can become equivalent:
Date: 2017-08-19T21:22:31+0200 Date: Sat, 19 Aug 2017 21:22:31 +02:00 Date: 1503177751
This feature allows for specifying more root directories for finding local files.
An include directory can be named or unnamed, which affects their packed name: unnamed directories act transparently – their packed name is exactly as specified and transformed, while named directories put their files in a dedicated subdirectory named themafter, then their specified path transformed.
special_book ├── rendered │ └── output │ ├── intro.html │ ├── main.html │ └── ending.html ├── previews │ └── generated │ └── out │ ├── intro.html │ └── main.html └── geb └── special ├── intro.html └── book.epuppIf
ending.htmlis built with
../../previews/generated/out, then an
book.epub ├── intro.html # From geb/special/ ├── previews │ └── main.html # From previews/generated/out/ └── ending.html # From rendered/output/
|Free date format||No.||
The MIT License (MIT) Copyright (c) 2017 nabijaczleweli Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Thank you for making it this far. I hope that this document is clear and/or informative, if not, why don't you pop into the issues and help yourself, others and me?