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

Go Back   MobileRead Forums > E-Book Formats > Kindle Formats

Notices

Reply
 
Thread Tools Search this Thread
Old 01-03-2011, 02:56 PM   #1
Unno
Junior Member
Unno began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Jan 2011
Device: Kindle 2 & 3
NCX From Html TOC

Ok, I've got a bunch of mobi ebooks that work fine on my Kindle, except that they are missing the .ncx toc, and therefore do not have the tick marks in the progress bar or the ability to flip through chapters. This is functionality that I really want out of my Kindle. I've done some searching, and I understand the syntax and stuff for writing an .ncx toc for scratch, but I've got so many books missing ncx files that it would take a very long time for me to manually write ncx files for them all. I assumed that my problem was not unique...in fact, I think it's probably fairly common, so I went looking for an app to auto-generate .ncx files for me. I can't seem to find one. The closest I could get was converting my mobi to epub in calibre, but that messed up the html formatting, and it split the chapters into seperate files, so I couldn't just scavenge the ncx file from the conversion. Does everyone out there manually create ncx files themselves? Or is there a program for doing it that I just don't know about?
Unno is offline   Reply With Quote
Old 01-03-2011, 03:39 PM   #2
ATDrake
Wizzard
ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.
 
Posts: 6,024
Karma: 14748740
Join Date: Mar 2010
Location: Roundworld
Device: Kindle 2 International & Sony PRS-T1
There is no program yet, though in theory, one could without too much difficulty write a script to just extract the filepos and proximate chapter headers in the unpacked mobi files and generate an NCX from that. And possibly this might be something Sigil could auto-generate from an ePub/HTML source, though I'm not familiar enough with that program to say for sure.

I do it manually for my own books which I mostly reconstruct and convert from ePub anyway and tweak the formatting along the way. I use a simple template in conjunction with a regexp which does most of the work for me.

Hope this helps and welcome to MobileRead!
ATDrake is offline   Reply With Quote
Old 01-03-2011, 04:07 PM   #3
Unno
Junior Member
Unno began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Jan 2011
Device: Kindle 2 & 3
Thanks for getting back to me so quickly. Unfortunately, my knowledge of both scripting and regular expressions is so limited that I don't think I could possibly get an even slightly automated system in place for doing this. Maybe I'll just have to do without ncx files until a program for this is written.
Unno is offline   Reply With Quote
Old 01-03-2011, 05:03 PM   #4
ATDrake
Wizzard
ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.
 
Posts: 6,024
Karma: 14748740
Join Date: Mar 2010
Location: Roundworld
Device: Kindle 2 International & Sony PRS-T1
Well, I just tested a couple of my own Mobi books, and it turns out that most of them which have existing TOCs in the actual text can be easily regexp'd to give you an easy base NCX to start with. Enough so that most of the work is done for you and you only have to do minor clean up.

So, provided someone properly filled out the HTML TOC on your Mobi, unpack the entire book using the Python utility in this post here, copy all the <p><a href="#filepos">Chapter X</a></p> stuff in the TOC section into a new text document, and run some variant of the following regexp upon it:
Code:
<p><a href="\#(filepos\d+)"><font color="inherit">([0-9a-zA-z|,| |:|?|!]+)</font></a></p>
to
Code:
<navPoint id="$1" playOrder="">
	<navLabel><text>$2</text></navLabel>
	<content src="\#$1" />
	</navPoint>
Some unpacked mobi files don't use the <font> tag, some add other cruft, so adjust the first example as necessary. The important parts are the #filepos and the chapter name.

Then do a search/replace on the <content src> to reference your unpacked file, add in the appropriate headers and such to the NCX, fill in the PlayOrder numbers, reference the new NCX in the extracted OPF, regenerate the Mobi, and you should be good to go.

Last edited by ATDrake; 01-03-2011 at 05:44 PM. Reason: Forgot a trailing slash.
ATDrake is offline   Reply With Quote
Old 01-03-2011, 08:01 PM   #5
Unno
Junior Member
Unno began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Jan 2011
Device: Kindle 2 & 3
I'm still playing with different regexp-supporting apps to try to get this working exactly right, but I think it'll do what I want. Thanks a lot!
Unno is offline   Reply With Quote
Old 01-03-2011, 09:17 PM   #6
ATDrake
Wizzard
ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.ATDrake ought to be getting tired of karma fortunes by now.
 
Posts: 6,024
Karma: 14748740
Join Date: Mar 2010
Location: Roundworld
Device: Kindle 2 International & Sony PRS-T1
Great! Glad it's (sort of) working for you.

If it's any help, the text editor I mostly use on the Mac, Smultron, says that it uses ICU Regular Expressions, which are apparently quite common and used in many platforms/apps.

ICU have a kind of user guide (well, more like tersely commented documentation on what stuff does, but there's a couple of examples and tips on how to get the result you want) on their website.

And you might have to tweak the stuff in the [] range brackets if you're reading a language with accents, or something with fancy punctuation in the titles. I tried to put in all the stuff I could reasonably think of that people would put into English-language chapter names.
ATDrake is offline   Reply With Quote
Old 01-13-2011, 10:16 AM   #7
peegee
Enthusiast
peegee will become famous soon enoughpeegee will become famous soon enoughpeegee will become famous soon enoughpeegee will become famous soon enoughpeegee will become famous soon enoughpeegee will become famous soon enough
 
Posts: 27
Karma: 574
Join Date: Nov 2010
Device: kindle
I've had reasonable success getting Calibre to create a version with chapter markers etc for me by using the ebook-convert command-line program that comes with Calibre to convert from mobi to mobi, using a command-line like this:
"C:\Program Files\Calibre2\ebook-convert.exe" "input-file.mobi" "output-file.mobi"

It sounds a bit odd, you might expect ebook-convert to do nothing, but it does actually go through the steps of converting from the input to the output and in the process it seems to build a toc.ncx in most cases, so the output file has chapter markers and a ToC.
peegee is offline   Reply With Quote
Old 07-12-2011, 04:51 AM   #8
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
I've just made little command line open source tool NcxGen (.NET 4) to create NCX, OPF and html table of contents from an XHTML file, following (as much as possible) the Amazon Publishing Guidelines. The tools has few options right now but if it is of some interest to the community I'm available to any suggestion. See the Getting Started wiki page for the available commands.

One thing that I can't found in Calibre is the ability to "collapse" the desired amount of levels in the NCX, keeping the proper indentation in the html ToC, that's why I started writing this tool.

The tool will modify the "id" attribute of some tags, so if you have already a TOC and want to generate just the ncx file, there may be a chance that you broke the hrefs links in the original TOC. (This is a solution that works for me... but if it is a problem I can try to find another solution)

Also, consider the tool slightly buggy, so always keep a backup of your original files!

I hope it can be helpful
GiorgioC is offline   Reply With Quote
Old 08-02-2011, 03:05 PM   #9
sueneu
eBook Designer
sueneu began at the beginning.
 
sueneu's Avatar
 
Posts: 26
Karma: 10
Join Date: Jun 2010
Location: New Jersey
Device: ipad, nook, kindle
Hi everybody,
I'm on a Mac, so I can't use GiorgioC's open source tool. sigh.
Terminal will give me a list of files:
cd /filepath/myoebpsfolder
ls > whateverfilename.txt

I arrange them in order & regex them into my TOC, spine and manifest. But I still have to put in the NavPoint numbers by hand.

Anyone solved that bit yet? Terminal or my html editor should know the line numbers . . .
sueneu is offline   Reply With Quote
Old 08-02-2011, 03:41 PM   #10
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 36,215
Karma: 17169472
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Sony Reader PRS-650, iPad, nook STR
Give Sigil a go.
JSWolf is offline   Reply With Quote
Old 08-02-2011, 10:01 PM   #11
sueneu
eBook Designer
sueneu began at the beginning.
 
sueneu's Avatar
 
Posts: 26
Karma: 10
Join Date: Jun 2010
Location: New Jersey
Device: ipad, nook, kindle
Thanks. I'll do that!
sueneu is offline   Reply With Quote
Old 08-25-2011, 07:35 AM   #12
DanBenton
Member
DanBenton began at the beginning.
 
Posts: 17
Karma: 20
Join Date: Feb 2010
Location: London
Device: Kindle
Hi

An alternative, lower-tech way to make an ncx is using Excel (bear with me).
So with a straight chapter structure, the basic TOC line is
<navPoint id="1" playOrder=""><navLabel><text>Chapter 1</text></navLabel><content src="chapter1.html" /></navPoint>

And in Excel I split that out using text to columns so it becomes

<navPoint id=" 1 " playOrder=" 1 "><navLabel><text> Chapter 1 </text></navLabel><content src=" chapter1 .html" /></navPoint>

The main advantage of this for me is that for Excel I can then select each 1 and drag it down to automatically make numbers 2, 3, etc - and the same with the chapter filenames if they follow a standard structure.
So yeah, there's my boring Excel NCX tip.

www.craig-thrillers.com
DanBenton is offline   Reply With Quote
Old 08-25-2011, 08:27 AM   #13
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 36,215
Karma: 17169472
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Sony Reader PRS-650, iPad, nook STR
Dan, I just noticed that your link to your your site that advertises your books for the Kindle. Where's the versions for the rest of us? You know, those of us that don't do Kindle eBooks and instead prefer ePub.

You're giving a tip on the NCX which is part of ePub and yet you have no ePub for sale.
JSWolf is offline   Reply With Quote
Old 08-25-2011, 10:54 AM   #14
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 8,767
Karma: 39536849
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by JSWolf View Post
You're giving a tip on the NCX which is part of ePub and yet you have no ePub for sale.
Actually, this thread is in the Mobi section and is about how to automate the process of creating an NCX file for use in creating MOBI files.
DiapDealer is offline   Reply With Quote
Old 08-26-2011, 05:25 AM   #15
DanBenton
Member
DanBenton began at the beginning.
 
Posts: 17
Karma: 20
Join Date: Feb 2010
Location: London
Device: Kindle
Thanks DiapDealer... yeah, I work with epubs too but for my own books I'm concentrating on Kindle at the moment. If there's significant demand for an epub version then I'll get on it, but frankly there isn't.

www.craig-thrillers.com
DanBenton is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a size limit for TOC.ncx? osnova Kindle Formats 10 10-21-2011 01:41 AM
Syntax for toc.ncx Levels 1 and 2? NewDay ePub 7 04-04-2011 04:09 PM
Saving with old toc.ncx file Haderlump Sigil 1 12-28-2010 12:11 PM
Page Mapping Using toc.ncx lorddon ePub 6 07-22-2010 08:59 AM
Can you bypass first two items in TOC.ncx? sueneu Kindle Formats 4 07-14-2010 08:36 AM


All times are GMT -4. The time now is 07:19 PM.


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