File last modified on August 18, 2022

toc.ncx

A toc.ncx should be included in every ePub for backwards compatibility and the toc.ncx template should be placed in BBEdit stationary. If you're wanting to test nesting or rendering from the toc.ncx file this can be done in Adobe Digital Editions.

To automate the build of the NCX use the ncx-creator.app. This application assumes that the toc.xhtml file was used and the toc.ncx template exists is in BBEdit's stationary. This application should be scoped to the toc.xhtml and when ran it will replace the existing toc.ncx with the template and build the file. This application will not nest the children and would need to be completed manually.

Duplicate Src

epubcheck does require that the NCX have unique src refs and this application does check for that and prompt if any are found. If the src ref is needing to be changed it should be done in the toc.xhml and ncx-creator.app should be ran again, example:

html
1
<docTitle><text>ePub Documentation</text></docTitle>
2
<navMap>
3
<navPoint id="navPoint-1" playOrder="1"><navLabel><text>Foo</text></navLabel><content src="text/SC02_chapter01.xhtml#page1"/>
4
<navPoint id="navPoint-2" playOrder="2"><navLabel><text>Bar</text></navLabel><content src="text/SC02_chapter01.xhtml#page1"/></navPoint></navPoint>
5
</navMap>
6
</ncx>

it should be coded as:

html
1
<docTitle><text>ePub Documentation</text></docTitle>
2
<navMap>
3
<navPoint id="navPoint-1" playOrder="1"><navLabel><text>Foo</text></navLabel><content src="text/SC02_chapter01.xhtml"/>
4
<navPoint id="navPoint-2" playOrder="2"><navLabel><text>Bar</text></navLabel><content src="text/SC02_chapter01.xhtml#page1"/></navPoint></navPoint>
5
</navMap>
6
</ncx>

Span

Span tags should not exist in the NCX, example:

html
1
<docTitle><text>ePub Documentation</text></docTitle>
2
<navMap>
3
<navPoint id="navPoint-1" playOrder="1"><navLabel><text><span class="foo">Foo</span></text></navLabel><content src="text/SC02_chapter01.xhtml#page1"/></navPoint>
4
<navPoint id="navPoint-2" playOrder="2"><navLabel><text>Bar</text></navLabel><content src="text/SC02_chapter01.xhtml#page1"/></navPoint>
5
</navMap>
6
</ncx>

Parent elements of children should have their </navPoint> moved to the last navPoint of that child, example:

html
1
<docTitle><text>ePub Documentation</text></docTitle>
2
<navMap>
3
<navPoint id="navPoint-1" playOrder="1"><navLabel><text><spanFoo</text></navLabel><content src="text/SC02_chapter01.xhtml#page1"/>
4
<navPoint id="navPoint-2" playOrder="2"><navLabel><text>Bar</text></navLabel><content src="text/SC02_chapter01.xhtml#page1"/></navPoint></navPoint>
5
</navMap>
6
</ncx>

If content is referenced in the TOC but can't be modified to reference the file then code it as:

html
1
<docTitle><text>ePub Documentation</text></docTitle>
2
<navMap>
3
<navPoint id="navPoint-1" playOrder="1"><navLabel><text>Foo</text></navLabel><content src="text/SC02_chapter01.xhtml#page1"/></navPoint>
4
<navPoint id="navPoint-2" playOrder="2"><navLabel><text>Bar</text></navLabel><content src="text/SC02_chapter01.xhtml#page1b"/></navPoint>
5
</navMap>
6
</ncx>
Last build: Thursday, 08/18/2022, 01:01:08 AM