Lately I published a node module on npmjs.com:

https://www.npmjs.com/package/epub-gen

It's a nodejs library for generating Epub book in a simpe way. It's quite fast and cost less compute resource. By the way, it can auto download remote images within source html.

Demo Preview:

Sample html from Learning JavaScript Design Patterns - by Addy Osmani

Making a Epub ebook is much easier than mobi ebook, If you want to generate a mobi Ebook, you have several options:

All of them need to install third party library and cost a quite mount cpu and memeries, especialy kindlegen, it sucks.

But up to epub, it's a open document, an Epub file is essentially a zip file. You can extract a epub file with zip software, then you'll get a folder like following files:

  | mimetype
  |--META-INF
  |    container.xml
  \–-OEBPS
      |  content.opf
      |  toc.ncx
      |--images
      |    cover.png
      |    image_1.jpg
      |    image_2.jpg
      \--text
           chapter_1.html
           chapter_2.html
           chapter_3.html
           .....

Oppositely, you can compress a directory comtaining those files in to a .epub file. hover, if you compress zip file with maximum compression option, some ebook reader will fail to open it. It's because of the mimetype file in the root directry shouldn't be compressed, this file should be simply saved into the generated file. So you can compress the direcory in this way:

$ zip -X -0 book.epub mimetype
$ zip -X -9 -r book.epub * -x mimetype

All source file like chapter_1.html and cover.png should be decleared in content.opf with media-type. if you specify the html file type as “application/xhtml+xml”, you may run into some format issues like unclosed tag, because xhtml is a strict file format. to solve this, you can specify html file type as "text/html", so that generated epub file could be rendered correctly in most of the ebook readers. toc.ncx is a optional file used to specify the table of content of the book, so that you can see the index of the book in ebook readers.

That's it, generating an Epub ebook is much easier than a Mobi ebook. I have a kindle(paperwhite), it works. Yes, it just works, but it's not a quite good book reader to me. It's slow and with blank-to-black flash every time I turn a page which contains images. but the iBook on iPad is really good. It smooth and elegant. The only one defect is I can't sync my books in iBook between iPad and Mac automaticly, if you want to sync your books, you have to use the buggy iTunes. However, overlook this issue, iBook on iPad is still a good reader to me. So, throw away your kindle, let's read on ipad.

That's all for this week, have a nice day.

[Updated 2015-3-1:]

The only notable e-reader lacking support for the EPUB format is the Amazon Kindle. http://www.wikiwand.com/en/Comparison_of_e-book_formats#/EPUB