Joho the Blogxhtml Archives - Joho the Blog

June 9, 2010

Getting EPub wrong every possible way

I spent too much of yesterday and today trying to placate EPub, the God of Finickiness.

EPub (which the creators would prefer I spelled EPUB, but I figure there’s no need to shout) is the ebook format that iPad and many other readers like. I have a young adult novel that I give away in html, pdf, and Word .doc, but I figured I should modernize it up to the EPub standard.

First, I converted all 26 chapters to XHTML. XHTML is HTML’s obsessive-compulsive younger brother. The sloppiness that made HTML a success — you could sling together code of the ugliest sort and browsers would still display it for you with red blush and lipstick — drives XHTML nuts. So, you’d better close every tag and make sure you don’t start any of your inner ID tags with a number. The W3C has a useful validator that will tell you every thing you’re doing wrong. (Under options, turn on “Show source” and it will show you your original text with the mistakes flagged.)

I downloaded a bunch of automatic EPub creators, many of them listed at JediSabre, but I couldn’t get any of them to do what I wanted. A lot of people really like Calibre, which does much more than just compile EPub files, but I couldn’t figure out how to get it to treat 26 chapters as one book; dumb of me, I know, but I didn’t see that basic point covered in the documentation, and I was too embarrassed to ask it in the user forum where the creator generously responds.

I also tried eCub. I couldn’t remember why I gave up on it, so I just now tried it again, and of course it worked perfectly. Instantly. Easily. Dammit! It must have been something wrong in the XHTML files that I fixed after I’d given up on it.

I also tried Sigil, which is quite full-featured, but it kept crashing before making it through all 26 chapters, very likely because of the same irregularities in those files. So, try the automated systems before you venture down the hand-coding path.

I spent many hours with TextWrangler — a text editor that can do search and replace across multiple files is a requirement if you’re going to end up doing this somewhat by hand. EPub files are actually zip files, and, astoundingly, the files in them have to be in the proper order. Why ebooks are too dumb to be able to randomly access the contents of a zip file is beyond me, but then, so is using an easy-to-use EPub compiler. So, you need to download a sample (I used Sigil to create one), unzip it, put in your content, and zip it back up. WebVivant tells us the three magic command-line commands to get the zip file to rezip itself correctly. I did that dozens of times today. Now it’s time to test the resulting file…

ThreePress has an online EPub validator that shows you what you did wrong this time. Very helpful, although the error messages can be a bit cryptic, mainly because there are so many freaking ways to go wrong.

If you need to handcode how to get your EPub to display your cover, here’s a very helpful step-by-step guide to cover markup, by Keith Fahlgren at ThreePress.

The upshot? Make sure your XHTML is valid, and that your id values do not begin with numerals, and then try the automated systems. The one’s I’ve mentioned are free. (Thank you!) (Bowerbird posted a comment to my earlier post about EPub about a system Bowerbird is developing that outputs lots of book/document formats.) If you find yourself preparing or tweaking it by hand, expect to spend some time at it.

The upshot’s upshot? I spent a day creating a crappy version of my YA adult in EPub format that I’m not even sure works beyond with Wordplayer on my Droid. If you care to try it and let me know if it works on your device or software ebook, let me know? (You can get the pdf and .doc versions here, and here’s Bowerbird’s epub version.)

78 Comments »