Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Formats > Workshop

Notices

Reply
 
Thread Tools Search this Thread
Old 07-12-2011, 07:55 AM   #1
GiorgioC
Junior Member
GiorgioC will become famous soon enoughGiorgioC will become famous soon enoughGiorgioC will become famous soon enoughGiorgioC will become famous soon enoughGiorgioC will become famous soon enoughGiorgioC will become famous soon enough
 
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']"
The XPath query are quite simple: the //h1 will select all the h1 headers he finds and the second query looks for all the h2 tag headers with the attribute class set to "toc" (or you can use != instead of = to select all headers with the class attribute not equal to "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...
GiorgioC is offline   Reply With Quote
Reply

Tags
kindle, mobi, ncx, opf

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

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 08:49 PM
NCX From Html TOC Unno Kindle Formats 20 09-16-2011 10:31 AM
Saving with old toc.ncx file Haderlump Sigil 1 12-28-2010 01:11 PM
Compiling HTML,NCX and OPF file pakiyabhai Calibre 8 12-25-2009 12:12 PM
HTML, NCX & OPF --> MESS pakiyabhai Workshop 2 12-22-2009 11:43 AM


All times are GMT -4. The time now is 12:06 PM.


MobileRead.com is a privately owned, operated and funded community.