Building electronic books using ANT

It’s been a while now since I wrote about my first meeting with electronic literature. Since then a lot has happened in the e-book world and I’ve been bit by the bug. As many others I now read most of my books, newspapers and magazines using a Kindle, iPad or some of the other reader tablets. So I thought it’s only appropriate that I should use my knowledge to help creating such publications from a programmers perspective. Several tools are already available, but I could not find any that can be used as part of a continuos integration build.

The basic idea is described in Eclipse bug 332122. Wiki markup converted to HTML (using Mylyn WikiText) or pre-existing HTML files is processed by a ANT script and a EPUB file is created as a result. I initially thought it would be a good idea to use Xtext for creating a DSL that could be used to describe the publication. I’m not so sure about that any more, as it would create some extra overhead and it is strictly not required. Maybe at a later stage.

There are several e-book formats available, but I chose EPUB (version 2.0.1) as it is open, free and based on existing standards such as HTML and CSS. It also appears to be quite popular although it’s currently not supported on the Amazon Kindle which is currently the most popular reader tablet.

iBooks on iPad

So far I have Ecore models representing the Open Packaging Format (OPF), a subset of Dublin Core and the Navigation Control File (NCX). All required parts of a properly assembled EPUB file. In addition there is a helper type that is used for composing and creating the EPUB file without having to paying attention to all the details (and there are quite a few). There is still a lot of work remaining but it seems my approach is sound. I am easily able to create readable content as the illustration shows (screenshots from iBooks on iPad). The book I made for testing is based on the “Development Conventions and Guidelines” page on the Eclipse wiki.

If you have any ideas on how to make this a even more useful tool please feel free to add them to the mentioned bug report, or comment on this blog. I’ll keep you posted on the progress.