07-12-2011, 06:55 AM | #1 |
Junior Member
Posts: 3
Karma: 514
Join Date: Jul 2011
Device: Kindle 3G
|
NCX file generator (and html ToC and opf)
Hi, everybody!
I've just joined the forum and I would like to point out my little command line tool to generate the NCX, the html ToC and the opf from an XHTML source. You can find it here. I tried to follow as much as possible the Kindle Publishing Guidelines and it should work without many problems with the kindlegen tool from Amazon (ToC at the beginning, "text" guide to mark the beginning of the text). You can choose how many levels in the table of contents as you want. The items in each level are chosen using the -q option followed by an XPath expression. You can add more levels by simply add more '-q XPath' options. Code:
-q "//h1" -q "//h2[@class='toc']" Using the parameter -l VALUE you can also collapse the NCX structure to the desired amount: your book has 2 main parts divided in chapters. You want the chapters to be properly indented in the html toc, but you also want to see each chapter mark in the bottom of the Kindle screen. You can use this tool with the option -l 2 to put both parts and chapters at the same navigation level (the html toc will still be properly indented). The tool is still in alfa so very likely after you generate the files you still have to edit the opf file to set the cover name (it defaults to Cover.jpg). And remember to backup your files! I'm not a programmer so the code is quite a mess and there space for a lot of improvements, if anybody find it useful... |
Tags |
kindle, mobi, ncx, opf |
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Old Thread] calibre not creating content.opf or toc.ncx files during conversion | foxxywith2xs | Calibre | 7 | 12-16-2012 07:49 PM |
NCX From Html TOC | Unno | Kindle Formats | 20 | 09-16-2011 09:31 AM |
Saving with old toc.ncx file | Haderlump | Sigil | 1 | 12-28-2010 12:11 PM |
Compiling HTML,NCX and OPF file | pakiyabhai | Calibre | 8 | 12-25-2009 11:12 AM |
HTML, NCX & OPF --> MESS | pakiyabhai | Workshop | 2 | 12-22-2009 10:43 AM |