Skip to content

EPUB and other package formats

joseph edited this page Jan 22, 2013 · 6 revisions

Monocle is designed to be format-agnostic. This means you have to do a bit of work to get it to support a given ebook package format, like EPUB, MOBI, Zhook, etc.

The reason for this is not philosophical. We'd love to save you the work. The reason is practical: removing the packaging of an ebook (typically by unzipping it) and then parsing its internal structure is way too slow and wasteful of resources to be performed client-side. This is more than ever the case with low-specification mobile devices. Those devices are key target platforms for Monocle.

You may want to go ahead regardless, serving EPUB files to the client for extraction. @rschroll has created a JavaScript library that processes EPUBs for Monocle called efm. This is an excellent place to start if you want to take this approach.

Otherwise, you're going to pre-process EPUB files on the server-side. That's where you gather the raw data needed to define a book data object. There's a bunch of libraries that exist to do this sort of thing in various languages. If you're using Ruby, take a look at Peregrin.

What about EPUB3?

All of the above still applies. If you identify a point of incompatibility, please lodge an issue in the Monocle bug tracker.

Be aware that EPUB3 is a deeply problematic specification. "Scripted documents" introduce serious problems of security and user interface conflict that Monocle is unable to completely mitigate, sadly. We generally advise you to strip JavaScript from all components before loading them. More discussion in Issue 40 and at blog.booki.sh.

Clone this wiki locally