![]() |
#1 |
Junior Member
![]() Posts: 5
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?
|
![]() |
![]() |
![]() |
#2 |
Wizzard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,517
Karma: 33048258
Join Date: Mar 2010
Location: Roundworld
Device: Kindle 2 International, Sony PRS-T1, BlackBerry PlayBook, Acer Iconia
|
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! |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Junior Member
![]() Posts: 5
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.
|
![]() |
![]() |
![]() |
#4 |
Wizzard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,517
Karma: 33048258
Join Date: Mar 2010
Location: Roundworld
Device: Kindle 2 International, Sony PRS-T1, BlackBerry PlayBook, Acer Iconia
|
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> Code:
<navPoint id="$1" playOrder=""> <navLabel><text>$2</text></navLabel> <content src="\#$1" /> </navPoint> 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. |
![]() |
![]() |
![]() |
#5 |
Junior Member
![]() Posts: 5
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!
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Wizzard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,517
Karma: 33048258
Join Date: Mar 2010
Location: Roundworld
Device: Kindle 2 International, Sony PRS-T1, BlackBerry PlayBook, Acer Iconia
|
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. |
![]() |
![]() |
![]() |
#7 |
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() 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. |
![]() |
![]() |
![]() |
#8 |
Junior Member
![]() ![]() ![]() ![]() ![]() ![]() 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 ![]() |
![]() |
![]() |
![]() |
#9 |
eBook Designer
![]() 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 . . . |
![]() |
![]() |
![]() |
#10 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 75,656
Karma: 134319570
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Give Sigil a go.
|
![]() |
![]() |
![]() |
#11 |
eBook Designer
![]() Posts: 26
Karma: 10
Join Date: Jun 2010
Location: New Jersey
Device: ipad, nook, kindle
|
![]() |
![]() |
![]() |
![]() |
#12 |
Member
![]() 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 |
![]() |
![]() |
![]() |
#13 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 75,656
Karma: 134319570
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
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. |
![]() |
![]() |
![]() |
#14 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 27,814
Karma: 198099188
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
|
![]() |
![]() |
![]() |
#15 |
Member
![]() 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 |
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Page Mapping Using toc.ncx | lorddon | ePub | 35 | 01-16-2018 12:18 PM |
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 |
Can you bypass first two items in TOC.ncx? | sueneu | Kindle Formats | 4 | 07-14-2010 08:36 AM |