Turn a text file into an epub chapter
Project description
ebukafy
The ebukafy
utility will convert a plain text file into a nicely
formatted html file to be used as a chapter in an epub.
Usage
It is recommended that you use ebukafy
in conjunction with Calibre. If
you do, read the Use with Calibre section first.
Usage: ebukafy [-h] [-p paragraph-separator] [-s section-separator] filename...
Options
-
paragraph-separator
: sequence of characters that will delimit paragraphs. Default value: "\t". -
section-seperator
: the sequence of characters that will delimit a section (the things I'm calling 'sections' are usually delimited by an empty line in paper books. In other words, sections are the chunks bigger than paragraphs and smaller than chapters). Default value: "\n\n". If the text only has one section, just make this something random that won't appear in the text.
NOTE: If you want to change these two separators, make sure to use ANSI
C like strings. These are used like so: $'string'
. For example: if you
want to use ebukafy
with \n\n
as the paragraph-separator
and
\n\n\n
as the section-separator
, you would call it like so:
ebukafy -p $'\n\n' -s $'\n\n\n' filename...
-h
: print out usage statement
Args
After these options, include as many files as you want to ebukafy
.
Output
The output of this utility will be a folder called ebukafy_index
filled with files named index_n.html
, with n starting at 1 and
incrementing for each filename
you include when calling ebukafy
.
These are the nicely formatted html files that you can use in your
epub. Additionally, the folder will include a copy of
stylesheet_additions.css
that you can find in this repository.
Use with Calibre
This utility is meant to be used in conjunction with Calibre.
-
Create an empty txt file anywhere.
-
In Calibre, in the upper left corner, click "Add books", which should open a file selector.
-
In the file selector, navigate to the empty txt file you created, and open it.
-
This should create a new empty book in Calibre. If you want to, you can add the metadata for the book such as the title, author, cover, etc.
-
In Calibre, convert the book you created to an EPUB.
-
After converting, select the book in the library and click "Edit book" in the top right corner.
-
On the left side you'll see the files that were created. Remove the one called index.html, if one exists. You probably want to keep the title page (titlepage.xhtml) since most books need a cover.
-
IMPORTANT: All EPUBs use a css file called stylesheet.css to give greater control over the formatting of the book.
ebukafy
uses its own stylesheet to format the html. To find it, look at thestylesheet_additions.css
file in this repo (or in theebukafy_index
folder created byebukafy
after you run it) and add its contents to the stylesheet.css of the EPUB. In Calibre, you can find this stylesheet in the "Edit book" editor. -
At this point, the boilerplate code is set up and you need to run
ebukafy
. Look at Usage section. -
Click the "Add file" button in the top left of the "Edit book" editor. You should name it
index_n.html
where n is a number that increments with each file you add (first file isindex_1.html
, second file isindex_2.html
, etc.). Into each file, you put the html created byebukafy
.
Use without Calibre
ebukafy
generates nicely formatted html documents based on a provided
txt file. Though it is much easier to put these files into an actual
epub with Calibre, it is not necessary if you know what you're doing.
Just make sure to read the Usage section.
IMPORTANT: All EPUBs use a css file called stylesheet.css to give
greater control over the formatting of the book. ebukafy
uses its own
stylesheet to format the html. To find it, look at the
stylesheet_additions.css
file in this repo (or in theebukafy_index
folder created by ebukafy
after you run it) and add its contents to
the stylesheet.css of the EPUB.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.