Most of the stuff is done in a shell script (bash). The script uses two sofware packages that need to be installed:
- pandoc (sudo apt-get pandoc)
- 7zip (sudo apt-get 7zip)
It also uses java and the official epubcheck jar; see the last line of create_epub.sh to change the path to your installation of epubcheck, or delete the check
You can basically edit all files in the ./templates folder; although the file you really need to edit is ./templates/novel.opf.1 - to change Author, Title, Description; link to your fonts (if you want some).
And maybe you want to change ./fixed/css/novel.css — especially if you want to use other fonts and stuff. Also, that file tells you a bit about stuff.
Most of your writing will be done in the ./md folder.
These are the templates for the content and the navigation file; changes are you don't need to change anything.
is used to preface all chapter files; it's the head, the css, everything before the real content
closes the chapter file; the section, the body
The start of the navigation file; it opens the navigation file and starts the list that will be generated from your MD files.
After the generated content from your files, the user-visible list is closed and a new list is started; it's the landmarks list, which will point to cover, frontmatter, backmatter, and the start of the real content. That list is also auto-generated.
The end of the navigation file; simply closes the landmarks list and the file.
This is where you want to do some edits; at least in the first file. Better leave 2 and 3 like they are, unless you know what you're doing.
The most important metadata file; title of the novel, author, description, identifier. You probably only need to edit this once. It also links to all resources that are NOT generated from Markdown files. So everything in the manifest that does not come from a markdown file needs to go here. The navigation file is already linked here; but if you change content in the ./fixed folder, remember to link it here (and remember that in the final book, the ./fixed folder will be named ./EPUB - so that's the path you need to use).
This is important to link stuff like fonts, cover, etc. - take a look at how the cover picture is linked, so reader systems know how to use the cover
This closes the manifes and opens the spine; this is where you integrate content that should be shown BEFORE your chapters; so title page, foreword, that goes here. This file is followed in the build process by a list of all files that where generated from markdown files starting with ch (for example, ch001.md to ch007.md) in the naturally order by the filename.
This closes the spine and the package file. If you have an afterword that should be linked in the spine AFTER your chapters, this goes here.
You can put context in ./fixed - everything in this folder will be first copied over the generated EPUB content. THAT INCLUDES GRAPHICS, FONTS, CSS FILES!
If you put an xhtml file into ./fixed/xhtml, it, too, will be copied
This template comes with: ./fixed/css/novel.css : a Stylesheet that looks nice and is a good start
./fixed/font : a folder containing two fonts
./fixed/img/cover.jpg : a cover you absolutely do not want to use. But you can just overwrite it with your graphic; now you know where it goes!
That all goes in the ./md folder. Chapter files should have names that are alphabetically sorted correct, as their order on the disk will be the order used in the navigation and the spine.
I've added a couple of files for you; take especial notice of the title, foreword and afterword pages, as they also use markdown fenced blocks to apply styles like legalnotice.
Generally: The first heading in the file is used as the title for the page, when it comes to linking the page in the navigation. Every *.md file should contain one line like this:
# Title of the page
That will be, for instance, the chapter title.
Your document can contain a line (ideally, at the start) like this:
[type]: backmatter
This is like a comment that won't be shown in the final output. But a line like this tells the script if this file is a frontmatter or backmatter type. Default, if no line is given, is bodymatter; bodymatter are your chapters, so no need to to give them a comment like that.
Possible values for the type that are recognized are (case-sensitive!):
cover : This will be put first in the navigation and the spine; you should only have one of those files, and "Title page" will be used as the name for the navigation file
frontmatter : This can be a foreword, and you can have multiple ones. They will be put after a cover (if existing), and before the chapters; multiple files will be used in the order the files are on the disk, so the filename drives the order
backmatter : This can be an afterword, an appendix, anything, and you can have multiple ones. They will be put after the chapters; multiple files will be used in the order the files are on the disk, so the filename drives the order
there is an example css file in fixed/css - take a look into that. It does stuff like formating the first paragraph after a heading (chapter title!) different, and even the first letter in that paragraph is formatted different.
Feel free to change that stylesheet.
If you want, you can run this script at the end of every day full of writing:
./logwork.sh -cs
It will show you how many words there are in your md files, and how many NEW words you have written since you've last run this script. No need to do it, but it might be nice?
just run
./create_epub.sh
when you're done writing your md files.