Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Conversion

Notices

Reply
 
Thread Tools Search this Thread
Old 07-28-2024, 02:05 PM   #1
brendontowle
Junior Member
brendontowle began at the beginning.
 
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
Level 2 TOC : //h:h2
This will result in an automatically generated two level Table of Contents that looks like:
Chapter 1
Section 1.1
Section 1.2
Chapter 2
Section 2.1
Using those instructions, I do get a two level ToC that looks like that, but: all of the section links, when clicked on, send you to the start of the chapter, not the section itself. And, sure enough, when I look at the data in the generated toc.ncx file, I see this:

<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?
brendontowle is offline   Reply With Quote
Old 07-28-2024, 03:00 PM   #2
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 41,299
Karma: 158182188
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>
DNSB is offline   Reply With Quote
Advert
Old 07-28-2024, 03:04 PM   #3
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: 76,960
Karma: 138588794
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.
JSWolf is offline   Reply With Quote
Old 07-28-2024, 08:05 PM   #4
brendontowle
Junior Member
brendontowle began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Jul 2024
Device: iPad
Quote:
Originally Posted by DNSB View Post
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.
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.
brendontowle is offline   Reply With Quote
Old 07-28-2024, 08:11 PM   #5
brendontowle
Junior Member
brendontowle began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Jul 2024
Device: iPad
Quote:
Originally Posted by JSWolf View Post
Before posting an error report, make sure you are using the latest calibre in case the error has been fixed.
I just confirmed that the same issue is present in 7.15.

Last edited by brendontowle; 07-28-2024 at 08:13 PM.
brendontowle is offline   Reply With Quote
Advert
Old 07-28-2024, 08:19 PM   #6
brendontowle
Junior Member
brendontowle began at the beginning.
 
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.
Attached Files
File Type: epub Jin Ri dake.epub (1.36 MB, 63 views)
brendontowle is offline   Reply With Quote
Old 07-28-2024, 08:45 PM   #7
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 41,299
Karma: 158182188
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.
Attached Thumbnails
Click image for larger version

Name:	Screenshot 2024-07-28 164450.png
Views:	111
Size:	184.1 KB
ID:	209807  

Last edited by DNSB; 07-29-2024 at 12:46 AM.
DNSB is offline   Reply With Quote
Old 07-28-2024, 10:26 PM   #8
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,653
Karma: 24966646
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.
kovidgoyal is online now   Reply With Quote
Old 07-28-2024, 10:37 PM   #9
brendontowle
Junior Member
brendontowle began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Jul 2024
Device: iPad
Quote:
Originally Posted by kovidgoyal View Post
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.
Yes, I did check that option.
brendontowle is offline   Reply With Quote
Old 07-28-2024, 10:39 PM   #10
brendontowle
Junior Member
brendontowle began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Jul 2024
Device: iPad
Quote:
Originally Posted by DNSB View Post
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.
Interesting. The only way I know of to add the ToC in Calibre is to convert the book, so I was converting from ePub to ePub; the one I attached was the original, not the converted. Apparently, in that process Calibre split the files, but maybe forgot to adjust the links so that they pointed back to the split files?
Attached Thumbnails
Click image for larger version

Name:	Edit Book 2024-07-28 at 18.36.23.jpg
Views:	101
Size:	375.6 KB
ID:	209821  
brendontowle is offline   Reply With Quote
Old 07-28-2024, 10:40 PM   #11
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,653
Karma: 24966646
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
kovidgoyal is online now   Reply With Quote
Old 07-29-2024, 12:05 AM   #12
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 41,299
Karma: 158182188
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日" />
On a different note, Adobe Digital Editions is not happy with that ToC and I am not enthused enough to find out why. Sigil, calibre viewer and Thorium on my computer and my Kobo ereaders are happy with it.

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.
Attached Thumbnails
Click image for larger version

Name:	Screenshot 2024-07-28 204039.png
Views:	93
Size:	207.9 KB
ID:	209823  
Attached Files
File Type: epub Jin Ri dake - NA Japan.epub (1.36 MB, 55 views)

Last edited by DNSB; 07-29-2024 at 12:43 AM.
DNSB is offline   Reply With Quote
Old 07-29-2024, 12:21 AM   #13
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,653
Karma: 24966646
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.
kovidgoyal is online now   Reply With Quote
Old 07-29-2024, 12:42 AM   #14
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 41,299
Karma: 158182188
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.
DNSB is offline   Reply With Quote
Old 07-29-2024, 11:13 AM   #15
brendontowle
Junior Member
brendontowle began at the beginning.
 
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!
brendontowle is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
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 09:35 AM
PW3 5.12.3 Serial Jailbreak - generated root password is wrong texaspete Kindle Developer's Corner 2 07-27-2020 12:00 PM
TOC in wrong place? Cyberseeker Kobo Reader 2 07-07-2017 02:15 AM
TOC links point to wrong page! fluoresce ePub 12 05-24-2017 09:07 AM
Generated TOC links back to TOC page in the book Caleb666 Sigil 7 08-17-2011 12:58 PM


All times are GMT -4. The time now is 08:58 AM.


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