ePub — manual coding is the way

I posted this on my social media feeds today:

> Just discovered how hand-coding #epub is far easier than using InDesign, once you know how. #ebooks

> My mind is still boggling from earlier #epub epiphany. InDesign does it so WRONG!

One of my friends in publishing asked me for more information. “Do tell!” she said.

Well, ePub, like most documents in the age of the web, should separate content from layout. And it’s best not to expect fine control over things like line breaks etc., because what you are creating is *structure*, and leaving presentation in large part to the reading device.

I hadn’t taken the time to delve into the hand-coding side of things before, since most of the ePubs I’ve made have been conversions from old QXDs and I had to use InDesign to open them anyway. I’d used a couple of other graphical ebook tools (Jutoh, mainly), but InDesign gave me the best results once CS5.5 came out.

Okay, so here’s the thing. Once you start doing it by hand, using some command-line tools, and editing the code directly, you realize that InDesign’s layout orientation puts a lot of user interface cruft in the way of your creating an ePub quickly.

I had an MS that had been through a variety of transformations (it’s been in Word and LaTeX), and to clean things up I used pandoc (a command-line tool) to convert it to Markdown and finalize the copy.

Taking it from there to ePub takes just one command in the terminal, and to fix the things that still aren’t to my liking, I can manually tweak the CSS in a text editor (or in Sigil), do some find and replaces to do things like add new paragraph classes to paragraphs that begin after a blockquote or a heading, and just save the whole epub again without recompiling (since it’s just a bunch of files and folders in a ZIP).

And I can do all this without having a whole bunch of useless things like text frames and pages in my way (don’t even get me started on how it works once images are in the mix). Will save me, probably, several hours of work for each ePub I have to do, while giving me more consistent results and liberating me from the bloat and cost of InDesign (shame I still need it to open those QXDs).

Of course I’ve got a lot to learn. There’s all kinds of cool things I could do with CSS, I’ll bet, and then there’s horrible things like fixed-layout ePub around (thanks, Apple). I can probably even script some of the workflow that I started devising today. But I feel like I’ve reached the next level with my understanding of ebooks.

That, reader, is my story.

Author: Ben Hourigan

Ben Hourigan is a novelist from Melbourne, Australia. His books Kiss Me, Genius Boy and My Generation’s Lament are Amazon category bestsellers, and are available wherever good books are sold online. Ben also works as an editor, copywriter, and self-publishing consultant at his own firm, Hourigan & Co. For news and book release updates, sign up to his email newsletter.