Skip to content

spajak/epub3-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

epub3-boilerplate – e-book template

EPUB version 3.2 template, including simplistic, yet universal css stylesheet.

Building EPUB file

I made a PowerShell script build-epub.ps1 to build an epub package file from a given source directory. In order to do so, place the script in PATH and execute this command from a PowerShell to build "template.epub" from the template:

$ build-epub.ps1 ".\template"

It can also be done using 7za command line tool. In PowerShell, execute build.ps1 script from within this repo:

$ .\build.ps1

Kindle

Kindle does not support EPUB e-books yet. Using kindlegen*, here is the command to build .mobi file from .epub:

& kindlegen -dont_append_source "template.epub"

* kindlegen has been discontinued, but Windows binary is provided in the releases of this repo.

Validation

Always validate resulting EPUB (.epub) file with epubcheck:

$ java -jar "/path/to/epubcheck.jar" "template.epub"

Words per page & word count metadata

I use schema.org numberOfPages and wordCount fields in package metadata:

<meta property="schema:numberOfPages">{{number_of_pages}}</meta>
<meta property="schema:wordCount">{{word_count}}</meta>

To get the number of words from html source use the provided PHP script:

$ php ./count-words.php "./template/Content/ch*.xhtml"

Did you know?

  • An average reading speed is 250 words per minute for an adult.
  • In a novel there are around 250-350 words per page.

Common sections (epub:type) quick reference

frontmatter bodymatter backmatter notes
titlepage foreword appendix footnote(s)
halftitlepage abstract endnote(s) noteref
acknowledgments preface glossary backlink
contributors preamble bibliography
toc introduction seriespage
dedication epigraph
prologue
part
chapter
epilogue
conclusion
afterword

Full rerefence: EPUB Structural Semantics Vocabulary.

Fonts

My favourite serif fonts for long reading:

  • Bookerly – Default Kindle font;
  • Literata – Google font (free);
  • Crimson Pro – Sebastian Kosch & Jacques Le Bailly (free);
  • Newsreader – an original typeface designed by Production Type (free);
  • Cochineal – a fork from the Crimson fonts (free);
  • Source Serif – a free font from Adobe;
  • Libertinus – a fork of Linux Libertine (free);
  • Georgia – classic font from Microsoft;

The difference between foreword, preface and introduction

  • A foreword is written by someone other than the author and tells the readers why they should read the book.
  • A preface is written by the author and tells readers how and why the book came into being.
  • An introduction introduces readers to the main topics of the manuscript and prepares readers for what they can expect.

Useful links