Giter Club home page Giter Club logo

ebook-boilerplate's Introduction

Ebook Boilerplate

A lightweight boilerplate for self-publishing ebooks with markdown and command line. The ebook boilerplate transforms markdown files into PDF, EPUB, MOBI, and HTML files, and provides a zipped version with all four.

Note: This works in MacOS, but has not been tested in Windows. At a minimum, the zip command will not work and will need to be set to false.

Download the Ebook Boilerplate

Quick Start

Make sure these are installed first.

In bash/terminal/command line, cd into your project directory. Then run:

sh build.sh

This will create your ebook files from your markdown files and assets.

Project Structure

  • Add your book title, subtitle, author info, and so on to the metadata.yml and title.md files in the assets directory. Fields that you need to update are in ALL CAPS so that you can easily find them.
  • Save your book content as markdown files in the chapters directory. I recommend prefixing chapter names with numbers to order them.
  • Book assets---CSS, metadata, etc.---go in the assets directory.
  • Save project images in the assets/img directory (or anywhere else that makes sense for you). These should be referenced in your chapters relative to the root directory: ![Image caption](assets/img/filename.jpg) or <img src="assets/img/filename.jpg">.
  • If you want a cover for your PDFs, include a cover.pdf file in the assets directory.

Configuration

There are two ways to configure the Ebook Boilerplate:

  1. Open up the build.sh file and change the defaults.
  2. Pass in flags with the sh build.sh command.

Defaults in build.sh

# Defaults
TITLE='ebook' # the title/filename
EPUB='false'  # if true, publish an EPUB version
PDF='false'   # if true, publish a PDF
MOBI='false'  # if true, publish a MOBI version
HTML='false'  # if true, public an HTML version
ZIP='false'   # if true, create a zip file
ALL='true'    # if true publish all formats (regardless of other settings)
COVER='false' # if true, add a cover for the PDF version

Flags

  • -t 'title' - The title/filename to use for your ebooks (defaults).
  • -e - If enabled, generate an EPUB.
  • -p - If enabled, generate a PDF.
  • -c - If enabled, add a cover to the PDF file.
  • -m - If enabled, generate a MOBI file.
  • -h - If enabled, generate an HTML file.
  • -z - If enabled, generate a zip file (requires all four other file types to work).
  • -a - If enabled, generate all file types (defaults to true).

Enabling individual file types (-e, -p, -m, or -h) will automatically set all file types (-a) to false.

Examples

Custom title

sh build.sh -t 'my-awesome-ebook'

Only generate a PDF and EPUB

sh build.sh -e -p

Only generate a PDF and EPUB with a custom title

sh build.sh -t 'my-awesome-ebook' -e -p

Use a cover with your PDFs

sh build.sh -c

Quirks and Other Issues

  1. I use wkhtmltopdf instead of LaTeX because it lets you style PDFs with CSS, giving you much more control over how things look.
  2. I don't apply any CSS to the EPUB and MOBI formats. I've had better support across a wider range of ereaders by letting them just use their default styles.
  3. wkhtmltopdf does not add page numbers to the generated PDF, and I've yet to find a way to make it do so.
  4. You must include an empty line before youR h2 page-level markdown headers (ex. ## Chapter Title) or Pandoc will just skip it when creating your file. No idea why.
  5. Break tags (<br/>) must include the self-closing slash (ie. don't do this: <br>) or they'll throw an error, even though slashless is valid HTML5.

License

The code is available under the MIT License.

ebook-boilerplate's People

Contributors

cferdinandi avatar pascallaliberte avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ebook-boilerplate's Issues

ebook-convert: command not found

I am getting the following error:
line 52: ebook-convert: command not found

I have installed Calibre. I am running the command on in a ZSH shell.

I can see that the executable file is there

Screenshot 2020-11-23 at 14 00 37

What am I missing?

Great tool btw!

Also: is there any guidelines on what proportions and file size the cover.png should be? Amazon has official guidelines but I don't know if they are the same for epub.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.