Adventures in ePublishing

For several years now I've been a frequent contributor to the Cheetah 3D forums, and I've been toying with writing a book about it for some time. The main thing stopping me was the obvious commercial impracticality. Martin Wengenmayer, the developer, won't even divulge how many licenses he's sold, or how many people use the current version, but based on the number of members of the forums, I guesstimate the maximum plausible audience at between 1000 and 10000 people.

I finally decided to collect my notes together and cobble together a book when I saw the iBooks Author announcement. It's a fantastic program — although given it seems to be built on the Pages codebase, I wonder if it also scales badly (I suspect it might). In the end I can't limit myself to the intersection of my already tiny potential audience and people who have iPads, so I decided to create a generic ePub and publish through Lulu.com (which I had considered using to distribute the newest edition of ForeSight a few years earlier).

I wrote the book in Pages. It looked lovely. I figured I'd have to convert it to Word and then allow Lulu.com to convert it to an ePub. Then — after investigating far more convoluted options — I noticed Pages can export direct to ePub. D'oh! In hindsight, I wish Pages didn't have this feature, because I could and would have written my own ePub Tool in the time I've wasted trying to get Pages to work properly.

The sad thing is that Pages creates ePubs almost perfectly and with very little fuss — but in the case of Learn 3D with Cheetah 3D it inverts chapter breakdowns and inverts the style hierarchy in the table of contents if I include more than one heading style  in the table of contents. (And I tried rebuilding the book entirely using Apple's "best practices" document — it doesn't help, and other people on Apple's Support Forums have the same problem. And, yes, I reported the bug.) Pages appears to be having problems because I broke my book into a lot of chapters.I broke my book into a lot of chapters because it has a lot of images in it and if a chapter has more than some unknown number or amount or something of images, it iBooks starts ignoring them. So I got burned by a horrible bug in Pages because of a horrible bug in iBooks.

No sign of any help from Apple on this, so the question was: InDesign CS5? Word? Word + some weird third-party converter? (I tried both Sigil and Calibre — they're both free as in who designed this godforsaken interface? And Calibre is over 200MB.) Maybe try to fix it from scratch? How about some kind of quasi-automatic hack?

I considered trying to hand tweak the ePub's created by Pages.

I actually tried fixing apparent errors in the stylesheets in my Pages document (which is, at its heard, a giant XML file) but the tiniest change caused Pages to crash on launching.

Eventually, I got it sort of working by only using one level of heading in the table of contents, and uploaded the ePubs I created. (I overrode major headings with a character style and numbered them, but it's still a horrible kludge.) Sigh.

All Word-Processors Suck

It's not like I can switch to a different word-processor. Pages is the least bad word-processor I've used.

I think the ultimate solution is to take my Pages XML and convert it to a bunch of clean HTML or — better — Markdown files, and then make a tool that turns a bunch of Markdown files into an ePub, and then give up on Pages altogether. It could actually be a feature of Folder.mark. It might be a nice Cocoa desktop hobby project. As an experiment in this direction I've written some XSL that pulls all the text, style names, and image links from a Pages document (which is well-organized XML). There's a bunch of missing functionality (e.g. I don't handle footnote support) but so far the biggest issue is that Pages seems suppress spaces after spans and then use some kind of heuristic to insert them again. Imagine if each occurrence of "span" in "Spanning a Spanish span in a short timespan." is a span. Aside from not inserting spaces before punctuation, I'm stuck…  It's infuriating.

I did learn about the wonderful XSL "key" tag and function though — I wish I'd learned about that three years ago. (You can build lookup tables with one line of XSL. As you might imagine, it speeds up and simplifies a lot of nasty stuff.)

Approval Processes

Summary: Within minutes of uploading my ePub to Lulu.com it was available for sale direct from them (it's DRMed, so it can only be read using Adobe Editions). After a day it's still in the approval queue for Barnes & Noble (Nook) and iBooks. After discovering that self-publishing on Kindle is easy, I decided to try and, about twelve hours later (as advertised!) it's available for sale in the Kindle Store (albeit the color images are now monochrome, rendering it pretty much useless — I can't tell from their preview Web App if this is non-issue on the [color] Kindle Fire.)

— Tonio Loewald,