HTML to EPUB: Calibre Conversion Settings and How to Preserve Indents

Chapter One: HTML

In which the protagonist prepares an HTML document for Calibre conversion to EPUB format. Our story begins as the hero has completed the treacherous journey from InDesign, which is not designed to design ebooks at all, to clean, ebook-worthy HTML and CSS. And what a journey it has been, with action and romance and stylesheet declarations and dragons.

The first step to any good ebook is a clean, well-formatted source document. In my previous post, which was specifically about creating an EPUB from InDesign, I make the argument that the best way to generate an ebook is from HTML. This is because EPUB files are, at the core, HTML, and Kindle MOBI markup is supposedly not far removed from HTML either. This facilitates good, clean conversions, and when you do find formatting problems, they are easy to troubleshoot–if you know just a little HTML/CSS.

Here we will use Calibre to create an ebook from an HTML document and its resources. Calibre is a free tool and you can get it from http://calibre-ebook.com. Though Calibre was designed primarily for personal use, I think it is very handy for professional ebook creation when it is not being done in-bulk. (However, Calibre does offer command-line tools for automated conversions–but we’re not getting into that today.)

Chapter Two: Calibre Settings

In which the protagonist fights to preserve his friggin indents, etc.

Having bulldozed my way through numerous Calibre ebook conversions, I’ve picked up a few tricks to make a better product and/or to streamline the process.

The Conversion Settings, pt. 1

There are some general settings you will want for most ebooks designed for distribution. If I don’t mention a setting, take the default value unless you know that you need otherwise. You may only figure this out through repeated conversion and testing (see chapter three, next post).

The Metadata

  • Attach the cover in the form of a high-quality jpg at least 1400 px wide. See our prior post solely on the topic of the ebook cover. 
  • Enter the exact, publishable metadata. Information must match what is on the cover, what is inside the book, and what will be listed in online marketplaces.
  • “Book 1.00” means first in a series, not version 1.0.

Look & Feel

  • Settings here are very situation-dependent. In general I don’t have to do much here, but it depends largely on the quality and specificity of your CSS. You may or may not have to tinker with these settings, and I cannot tell you what to do until you try it yourself. But there is one counter-intuitive issue I want to give its own section:

Preserving Indents

Want to preserve the indents from your source without removing blank lines between the paragraphs? Calibre is set up so that the option to set the paragraph indents is disabled until you check “Remove blank lines between paragraphs.” This makes sense normally, because with indented paragraphs, you don’t usually want blank spaces. Alternatively, with block paragraphs, you want spaces but not indents.

But what do you do when you have a manuscript that mixes the two, or that uses indented paragraphs but also uses line spaces for formatting? If only it weren’t an either-or decision! Fortunately, it’s not–Calibre just makes it seem like it is. You can check “Remove spacing between paragraphs” just to change the indent size to “No change.”

Screen shot 2013-10-24 at 4.19.00 PM

To set it to “No change,” you must hit the down arrow until it goes past 0.0, past -0.0 (it actually says this), until it says “No change.” This is a little counter-intuitive. I, at least, didn’t know you could do this until I stumbled upon it in frustration.

Having set the indents to “No change,” you can then uncheck “Remove spacing,” and it should still honor your specification for indents. Hurray!

The Conversion Settings, pt. 2

Page Setup

  • Generally, you will want to select “Default Output Profile.” This is because it optimizes images for larger screens. In this way, your ebook images will be good enough for large displays as well as mobile devices. It ensures the widest range of compatibility. Of course, this is only possible if your images are starting out at a sufficiently high quality. If the are too small to start off, this setting won’t help you, but it won’t hurt either.

Structure Detection

  • If you know that you want all level-one headers to be chapterbreaks, you have it easy. Use //h:h1 for “Detect chapters at (XPath expression).” If not, use the magic wizard wand to figure out what you need, and consult Calibre’s documentation.
  • If all your desired pagebreaks are taken care of between your CSS declarations and your Calibre chapter-detection, disable “Insert page breaks before” by entering just a forward slash in the field.

Table of Contents

  • Set “Number of links to add to the Table of Contents” to 0.

EPUB Output

  • It is important that you select “Preserve cover aspect ratio” every time unless you particularly want your cover to suffer an unflattering funhouse mirror effect every time someone opens your book.

MOBI Output

  • Delete the PDOC tag. Leaving it will cause your book to appear under “documents” on Kindle devices, rather than in “books.”

This is where you hit “Okay.” Then comes the first viewing of the book. Good luck. Odds are you aren’t done yet, my friend.

See our next post: Chapter Three: Reconverting Using Merge Book Records (Testing and Tweaking with Calibre)

Leave a Reply

Your email address will not be published. Required fields are marked *