Definite's Extractor

My findings on Life, Linux, Open Source, and so on.

Tag Archives: ebook-convert

calibre: How to convert and bind multiple html pages for kindle?

I tried to put  dive in python 3 on my kindle. Firstly I download sample from Amazon. The book is quite cheap, but well, … I would have bought it if it’s code blocks are actually represented as text (not as graph).

Then I tried calibre. Calibre is quite easy of use, but it keep telling me that

  1. html files should be known as “zip”
  2. The chapters should be ordered by chapter titles alphabetically, instead of original chapter number.

Luckily, calibre does provide command line too, namely, ebook-convert. It can automatically follow the hyperlinks and append the content of referenced local html files. However, it failed to recognize html files if they don’t actually have “<html>” tags (browsers render them fine, though). Well, inserting <html> and </html> on multiple files are not hard if you know sed and bash.

Are we done yet? No.  option “–breadth-first” is required, otherwise the chapter order is still messed up, as the latter chapters might inserted in the front just because they are referred first.

Are we there yet ? Well, yes. But of course, there are many knobs that can be tuned if you want better result.