Asbjorn Grandt - 2011-09-23 14:21:27 - In reply to message 8 from Mark Wu
Starting from the 2.04 version currently on this site, rather than the 2.10 release candidate simply because this is the version I could drop into an editor here :)
Lines 228 and 250, in the addChapter function, are adding entries to the navmap on the fly. So there aren't really an array being filled up, and used to build the actual structure during the finalize stage.
This is the problem that needs fixing, preferably while maintaining backwards compatibility.
The solution, may be to add a pair of functions to set the navmap level. (incrNavMapLevel and decrNavMapLevel?) along with a variables to maintain the current and the deepest level used. The second variable is needed for the navmap header.
I must admit that I haven't done much work on the navmaps, as I've so far never had to go beyond one level.
Using methods to push and pull the navmap levels in this matter would also make it a bit easier to build several books into the ePub, as the builder don't have to bother with the current level it's at, when it start adding a book.
The first step will definitely be to extract the navmap building code as seen in the two lines mentioned above, into separate functions, as the content src links in these can point to fragment id's (apart from the top level, though that is a restriction in books based on ADE it seems, and not really a specification limitation)
At this time I think the better solution will be to make a NavPoint class with the variables needed to hold the attributes, as well as an array to hold it's children, as writing a multilevel navMap on the fly is going to get very interesting very fast :)
That of course means another step to perform during finalization.