![]() |
#1 |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Jul 2024
Device: iPad
|
Generated TOC links go to wrong place
I'm told that this is user error (https://bugs.launchpad.net/calibre/+bug/2074284), so I'm checking here.
I'm trying to generate a TOC using Calibre 7.10, for an ePub that has very well-formed chapters and chapter/section headings. In the tutorial at https://manual.calibre-ebook.com/con...le-of-contents, I found these instructions: Then, we set the options as: Level 1 TOC : //h:h1 This will result in an automatically generated two level Table of Contents that looks like:Level 2 TOC : //h:h2 Chapter 1 Section 1.1 Chapter 2Section 1.2 Section 2.1 <navPoint id="uIXA2jfX6ChloBsjmNnSAg9" playOrder="2" class="chapter"> <navLabel> <text>1月</text> </navLabel> <content src="OPS/chapter-2_split_000.xhtml"/> <navPoint id="uqfPktaL93cTQmqLLO4idQ3" playOrder="2" class="chapter"> <navLabel> <text>1月1日</text> </navLabel> <content src="OPS/chapter-2_split_000.xhtml"/> </navPoint> <navPoint id="utq9DOX7bB9u69KAIm5i7y2" playOrder="2" class="chapter"> <navLabel> <text>1月2日</text> </navLabel> <content src="OPS/chapter-2_split_000.xhtml"/> </navPoint> Note that the src link for each of the contained navLabels points to ...split_000.xhtml. But, the actual header elements for the contained navLabels are not in ...split_000; they're in ...split_001, ...split_002, etc. So. What do I need to do to convince Calibre that I actually want the section links to point to the sections themselves, and not to the chapter? |
![]() |
![]() |
![]() |
#2 |
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 38,995
Karma: 153098470
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
You will need to either split the files at the sections or use IDs to locate the section headers. All your current links are pointing to the same file which suggests that your sections are in the same file as the chapter header with no way to differentiate them.
Code:
<h1>Chapter 1</h1> <h2 id="section0001">Section 1</h2> <h2 id="section0002">Section 2</h2> <h2 id="section0003">Section 3</h2> <h2 id="section0004">Section 4</h2> <h2 id="section0005">Section 5</h2> <h2 id="section0006">Section 6</h2> Code:
<navMap> <navPoint id="navPoint1"> <navLabel> <text>Chapter 1</text> </navLabel> <content src="Text/Section0001.xhtml" /> <navPoint id="navPoint2"> <navLabel> <text>Section 1</text> </navLabel> <content src="Text/Section0001.xhtml#section0001" /> </navPoint> <navPoint id="navPoint3"> <navLabel> <text>Section 2</text> </navLabel> <content src="Text/Section0001.xhtml#section0002" /> </navPoint> <navPoint id="navPoint4"> <navLabel> <text>Section 3</text> </navLabel> <content src="Text/Section0001.xhtml#section0003" /> </navPoint> <navPoint id="navPoint5"> <navLabel> <text>Section 4</text> </navLabel> <content src="Text/Section0001.xhtml#section0004" /> </navPoint> <navPoint id="navPoint6"> <navLabel> <text>Section 5</text> </navLabel> <content src="Text/Section0001.xhtml#section0005" /> </navPoint> <navPoint id="navPoint7"> <navLabel> <text>Section 6</text> </navLabel> <content src="Text/Section0001.xhtml#section0006" /> </navPoint> </navPoint> </navMap> |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 75,702
Karma: 134319572
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Before posting an error report, make sure you are using the latest calibre in case the error has been fixed.
|
![]() |
![]() |
![]() |
#4 |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Jul 2024
Device: iPad
|
The whole point of my post is that they're not in the same file; all of them are in different files. See what I said about ...split_000, split_001, etc.
|
![]() |
![]() |
![]() |
#5 |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Jul 2024
Device: iPad
|
I just confirmed that the same issue is present in 7.15.
Last edited by brendontowle; 07-28-2024 at 07:13 PM. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Jul 2024
Device: iPad
|
I've attached the .epub I'm trying to convert if that's helpful to anyone.
|
![]() |
![]() |
![]() |
#7 |
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 38,995
Karma: 153098470
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
For what it may be worth, your ePub did not contain any section files with names such as whatever_split_0001, see the attached image. I took a couple of seconds to open the file in Sigil and use it's ToC tool to regenerate the ePub3 nav document and the ncx ePub2 nav document for the h1/h2 header items. It seems to move to the section headers now in Sigil and calibre's viewer.
Last edited by DNSB; 07-28-2024 at 11:46 PM. |
![]() |
![]() |
![]() |
#8 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 44,272
Karma: 23661992
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Your EPUB already has a table of contents, did you check the option to "Force use of auto-generated table of contents" without that the existing table of contents will be used.
|
![]() |
![]() |
![]() |
#9 |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Jul 2024
Device: iPad
|
|
![]() |
![]() |
![]() |
#10 | |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Jul 2024
Device: iPad
|
Quote:
|
|
![]() |
![]() |
![]() |
#11 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 44,272
Karma: 23661992
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
It's because your EPUB file is using chinese characters in id attributes. These break with some EPUB renderers like adobe digital editions. If you look at the conversion log it will be full of messgaes like
Removing fragment identifier '4月10日' from TOC as Adobe Digital Editions cannot handle it |
![]() |
![]() |
![]() |
#12 |
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 38,995
Karma: 153098470
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Kovid is both correct and incorrect. You can use UTF-8 characters in the IDs including Kanji but the IDs may not start with a number. If you edit the IDs to add say, 'x' after the id=" and then regenerate the table of contents (both the ePub3 nav document and the ePub2 ncx document), your ePub is valid. The three lines below are the XHTML code, the reference from nav.xhtml and the reference from toc.ncx
. Code:
<h2 class="section-title" id="x2月1日">x1月1日</h2> Code:
<a href="chapter-3.xhtml#x2月1日">x2月1日</a> Code:
<content src="Text/chapter-3.xhtml#x2月1日" /> And here's another copy of your file where I changed the ID to use month/day which seems to make ADE 4.5 happy with using the ToC though the heading may end up part way down the page. Last edited by DNSB; 07-28-2024 at 11:43 PM. |
![]() |
![]() |
![]() |
#13 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 44,272
Karma: 23661992
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
I didnt say you cant use them, I said some renderers dont like them, principally Adobe Digital Editions. If you are using a halfway decent renderer, then they work fine, but conversion will strip them out because it tried to produce EPUBs that work on the widest variety of places possible. Having them in the ToC causes ADE to actually refuse to open the file.
|
![]() |
![]() |
![]() |
#14 |
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 38,995
Karma: 153098470
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
And my disagreement was that since the IDs started with a numeral, they were not valid XML ids.
|
![]() |
![]() |
![]() |
#15 |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Jul 2024
Device: iPad
|
Thanks, guys -- this is very helpful. I'm using Ulysses to generate the ePub, and apparently it's using the section header text directly as the ID; I'll talk to the developers there. If that doesn't pan out, I can use regex to do a one-time change of the IDs.
Thanks again for your help! |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Need help figuring out what's wrong with an ePub I generated | Angius | ePub | 5 | 07-25-2024 08:35 AM |
PW3 5.12.3 Serial Jailbreak - generated root password is wrong | texaspete | Kindle Developer's Corner | 2 | 07-27-2020 11:00 AM |
TOC in wrong place? | Cyberseeker | Kobo Reader | 2 | 07-07-2017 01:15 AM |
TOC links point to wrong page! | fluoresce | ePub | 12 | 05-24-2017 08:07 AM |
Generated TOC links back to TOC page in the book | Caleb666 | Sigil | 7 | 08-17-2011 11:58 AM |