Convert Texinfo to MOBI

GNU software often comes with a large set of documents in texinfo format, which can be typesetted to a real book. For example the Gnus Manual has over 500 pages, full of fun and humor. Having a mobi version on my Kindle would be quite handy.

Gnus Manual on Kindle

This work involves two parts, first is to convert texinfo to docbook, second is to convert docbook to mobi. In fact the second part could be applied on all docbooks.

Convert Texinfo to DocBook

Texinfo has native support of converting texi file to docbook format:

$ makeinfo --docbook gnus.texi 

will output gnus.xml.

If the texi includes some other texis the the makeinfo command somehow doesn’t strip the @setfilename macro from the included file, so cluttered output. Use the following sed script to fix it:

$ sed -i -e 's#<para>&lt;setfilename&gt;.*&lt;/setfilename&gt;</para>##' gnus.xml 

Convert DocBook to MOBI

Since DocBook 1.74, they included a ruby script dbtoepub to convert xml file to epub format. Then we can use kindlegen or calibre to convert epub to mobi.

However the docbook xsl produces nested navPoints and <dl> formated TOC. Both aren’t handled very well by Kindle.

So I created a customized layer above the docbook.xsl for mobi creation. This mobi.xsl will flatten the navPoints and use <ul> formated TOC. The output mobi looked very nice on my Kindle.

All in one script

Download the texi2mobi.tar.gz, which contains the script and the style sheet used to create mobi friendly epub.

To use this script you have to install makeinfo, dbtoepub and kindlegen. I use kindlegen here because it creates better mobi at present.

$ apt-get install texinfo
$ apt-get install dbtoepub 

kindlegen could be downloaded form Amazon.

Untar the tarball then use


Create your mobi version! Have fun