Kindle Publishing in Three Simple Steps
Sometimes I search for something really simple, but I takes me time to figure it out. And once I find out, I'm really happy. Maybe this recipe is too simple minded, but maybe not: it might be I'm just an average solution-seeker, and there is a host of people, who are looking exactly for the same thing. That's a reason why I want to share it here. Today about how to create mobi file out of your own content.
I'm happy user of Kindle, it increased dramatically my reading capacity. Mostly I read a books, usually bought directly from publishers like PragPub or O'Reilly. Sometimes I want to read web pages, and various "Send to Kindle" browser plugins, like Send to Kindle, are working just fine. Sometimes I want to read document in DOC or DOCX format, and I've found Amazon's own "Send to Kindle" context-menu extension can make it. But sometimes I want to author my own content for Kindle or prepare for Kindle some content, available in raw format. And I was searching for the tooling to help me to do so.
I tried various established available tools like Calibre or Jutoh, but I was not getting happy about it. I was looking for something with more automation capability and with more control over format. Maybe I'm paranoid, but I do not believe much the tools doing too smart things with too intransparent formats, like all these wysiwyg files.
Finally I found out and here are my three steps to make it possible:
- author the content as TXT file in notepad (or any other text editor of your preference)
- use Pandoc tool to convert TXT to ePUB
- use Amazon's Kindlegen tool to convert ePUB to Mobi
And that's it...
I can't really help you with the first one, but here are some hints about second and third steps...
Markdown authoring for Pandoc
If you want to author TXT file to produce reasonable structured ebook, you need to follow only few simple rules:
- use Markdown for formatting
- for chapter headers, which you want to mark new sections in ebook, use single hash mark #
- put ebook metadata at the top of the file, using notation with % (this is not part of Markdown format, but extra Pandoc extension, but very useful and straighforward)
Pandoc is great and simple open source tool, written in Haskell (wow!) and able to convert between many different formats. It supports OpenDocument, LaTex and many others. But I found Markdown the most convenient starting format (which probably has something to do with my recent content authoring experiences, which happens mostly on wikis).
You can run Pandoc with the single command:
pandoc -f markdown -t epub -o your_file.epub your_file.txt
This is it. Just replace "your_file" with your content file, TXT is the file you have, and EPUB is the file you want to create.
Turning ePUB into MOBI
This is easy one: you need Amazon's tool called Kindlegen, which does exactly that. It is understandable, that Amazon feels bad about no-support for ePUB as standard, so they are trying to make the ePUB->MOBI step as easy as possible.
You just call it as follows:
and soon you find your_file.mobi in the same folder.
Well, I do not like Calibre or Jutoh, because it is too much rambling with the mouse around, before you get your ebook. The approach above is just text editor and command line. - And that opens an opportunity for some automation.
Thus my favorite "publishing system" would consist of text editor, with integrated git or mercurial, and running pandoc, kindlegen and mobi-preview-tool as "build and run" command, and as commit hook. And then having some unit tests (any idea, how ebook unit tests could look like?). And running all that "in cloud", of course...
Update: well, because the idea above seems so obvious, it is clear that it exists already. The thing is called Leanpub.com and it works exactly as you would expect: they take a book, which you author in markdown (plus some bits of metadata) and share with them through git repo or shared folder on Dropbox, and they make PDF, ePUB and MOBI for you. And even better, they can run the page for you to sell the book, including all the goodies like voluntarily-set prices and distribution of updated versions to all the people, who has purchased your book.