19 January 2012

The iBooks 2.0 textbook format

Today, Apple released both iBooks 2.0 and an authoring app called iBooks Author. The new iBooks, the authoring app, and Apple’s new textbook category are all based on a new ebook format Apple has invented.

I’ve spent a few hours staring at the innards of a file exported from iBooks Author in an attempt to understand what it going on. I still only grasp a fraction of what they are doing, but I figured I might share my theories at this point.

The good

Apple’s new format is mostly ePub3. It has valid NCX and OPF files. The XHTML files are all XHTML5. It uses SVG extensively. Promising.

The meh

The XHTML files all use declarations of the form

<?xml-stylesheet href='*' type='text/css' media='*'?>

to link to CSS files, instead of the more usual (and certainly more standard way, since they’re using the HTML5 doctype) link element.

The mimetype iBooks uses for these files is application/x-ibooks+zip. In and of itself not bad news, but it is a clear indicator that Apple doesn’t want this to be treated like ePub. That is, they do not want to have to worry about making sure that the output of iBooks Author is readable in ePub reading systems.

Yup, that’s a cue for ominous music.

The bad

The CSS files are full of undocumented extensions to the CSS standard, few of which seem to be from any version of any spec I could find on the W3.org website. Things like:

Apple has chosen to use custom properties to define strikethroughs, underlines, margins, and heights in various contexts, with no standards-compliant fallbacks, to get a level of control over the visual design that standard CSS does not offer.

The ugly

A lot of the layout and text-wrapping features of an iBooks 2.0 file are defined in non-standard ways.

The XHTML files contain object elements with types such as application/x-ibooks+flowhead and application/x-ibooks+shape that tie in with the way the file is laid out in undocumented ways. The CSS link to .plist files with properties called -ibooks-line-hints. Your guess as to what that’s for is as good as mine.

This piece of code is going to be gobbledygook to all web browsers and all ePub reading systems. I don’t see an easy or straightforward way of converting this piece of CSS into anything understandable by other apps.

It is one thing to deliver a format that is ePub3 in all but name. The differences between the iBooks 2.0 format and ePub3 seem all but trivial. But when that format is built around non-standard extensions to the CSS rendering model and all of the XHTML and the CSS are built around that extended model, the file is likely to forever be useless and unreadable in other reading systems.

The work involved in converting an iBooks 2.0 file to a standard ePub3 is likely to be easy.

The work involved in converting the iBooks 2.0 CSS to something ePub3 reading systems or browsers, however, is likely to be too great to be worthwhile.

Rewriting the CSS for a complex, intricately designed, book from one layout model to another is also probably impossible. The reason why Apple chose a non-standard layout model is probably because the ones currently standardised and proposed by the W3 cannot deliver the designs Apple is aiming for.