ePub generation with Middleman

I’m currently using Middleman to generate HTML files for a book (you can look at our repo here, if anybody’s interested).

I then take these HTML files and run them through Calibre to generate an ePub file.

This works well enough, but it’s a manual process, and plus I have to look at Calibre’s awful UI every time. So I was wondering if there were any resources/gems/blog posts out there for automating the whole process?

Has anybody ever done something similar?

Have you looks at the calibre command line interface?

http://manual.calibre-ebook.com/cli/cli-index.html

I hadn’t, thanks! That might definitely make things easier.

Although ideally I was thinking more of a workflow that would be integrated right into Middleman, i.e. middleman build epub or something… One can always dream!

Epub is basically xhtml and css + some conventions on how the documents are to be organized, so it should be quite possible to build.

Starting point: http://www.hxa.name/articles/content/epub-guide_hxa7241_2007.html

The tricky part is probably encryption, if you want to protect the book from being copied.

I’ve been wondering about this myself, thinking that I might go the Pandoc route. I haven’t been able to find anybody who’s built a middleman-specific pandoc integration yet. One older forum question discusses some approaches a bit.