Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 12-31-2021, 03:20 PM   #1
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 10,974
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Table of Contents: Easy way to strip anchors?

Some books of mine, the ToC entries point to anchors at the beginning of the chapter, such as this:

Code:
<?xml version='1.0' encoding='utf-8'?>
<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" xmlns:calibre="http://calibre.kovidgoyal.net/2009/metadata" xml:lang="en">
  <head>
    <meta name="dtb:uid" content="af680924-8cd7-4751-bdc1-c3ba61017ec9"/>
    <meta name="dtb:depth" content="2"/>
    <meta name="dtb:generator" content="calibre (5.34.0)"/>
    <meta name="dtb:totalPageCount" content="0"/>
    <meta name="dtb:maxPageNumber" content="0"/>
  </head>
  <docTitle>
    <text>Table of Contents</text>
  </docTitle>
  <navMap>
    <navPoint id="num_1" playOrder="1">
      <navLabel>
        <text>Title Page</text>
      </navLabel>
      <content src="text/part0000.html#t1"/>
    </navPoint>
    <navPoint id="num_2" playOrder="2">
      <navLabel>
        <text>Copyright Page</text>
      </navLabel>
      <content src="text/part0001.html#x8267372"/>
    </navPoint>
    <navPoint id="num_3" playOrder="3">
      <navLabel>
        <text>Contents</text>
      </navLabel>
      <content src="text/part0002.html#x8267372"/>
    </navPoint>
    <navPoint id="num_4" playOrder="4">
      <navLabel>
        <text>Chapter One</text>
      </navLabel>
      <content src="text/part0003.html#x8267372"/>
    </navPoint>
    <navPoint id="num_5" playOrder="5">
      <navLabel>
        <text>Chapter Two</text>
      </navLabel>
      <content src="text/part0004.html#x8267372"/>
    </navPoint>
    <navPoint id="num_6" playOrder="6">
      <navLabel>
        <text>Chapter Three</text>
      </navLabel>
      <content src="text/part0005.html#x8267372"/>
    </navPoint>
    <navPoint id="num_7" playOrder="7">
      <navLabel>
        <text>Chapter Four</text>
      </navLabel>
      <content src="text/part0006.html#x8267372"/>
    </navPoint>
    <navPoint id="num_8" playOrder="8">
      <navLabel>
        <text>Chapter Five</text>
      </navLabel>
      <content src="text/part0007.html#x8267372"/>
    </navPoint>
    <navPoint id="num_9" playOrder="9">
      <navLabel>
        <text>Chapter Six</text>
      </navLabel>
      <content src="text/part0008.html#x8267372"/>
    </navPoint>
    <navPoint id="num_10" playOrder="10">
      <navLabel>
        <text>Chapter Seven</text>
      </navLabel>
      <content src="text/part0009.html#x8267372"/>
    </navPoint>
    <navPoint id="num_11" playOrder="11">
      <navLabel>
        <text>Chapter Eight</text>
      </navLabel>
      <content src="text/part0010.html#x8267372"/>
    </navPoint>
    <navPoint id="num_12" playOrder="12">
      <navLabel>
        <text>Chapter Nine</text>
      </navLabel>
      <content src="text/part0011.html#x8267372"/>
    </navPoint>
    <navPoint id="num_13" playOrder="13">
      <navLabel>
        <text>Chapter Ten</text>
      </navLabel>
      <content src="text/part0012.html#x8267372"/>
    </navPoint>
    <navPoint id="num_14" playOrder="14">
      <navLabel>
        <text>Chapter Eleven</text>
      </navLabel>
      <content src="text/part0013.html#x8267372"/>
    </navPoint>
    <navPoint id="num_15" playOrder="15">
      <navLabel>
        <text>Chapter Twelve</text>
      </navLabel>
      <content src="text/part0014.html#x8267372"/>
    </navPoint>
    <navPoint id="num_16" playOrder="16">
      <navLabel>
        <text>Chapter Thirteen</text>
      </navLabel>
      <content src="text/part0015.html#x8267372"/>
    </navPoint>
    <navPoint id="num_17" playOrder="17">
      <navLabel>
        <text>Chapter Fourteen</text>
      </navLabel>
      <content src="text/part0016.html#x8267372"/>
    </navPoint>
    <navPoint id="num_18" playOrder="18">
      <navLabel>
        <text>Chapter Fifteen</text>
      </navLabel>
      <content src="text/part0017.html#x8267372"/>
    </navPoint>
  </navMap>
</ncx>
I've noticed it mostly on books I purchased on Amazon, downloaded with Kindle 1.17 before importing into Calibre, and then converted to ePub. Though I did notice it on a few Kobo books too.

This causes a small glitch on Kobo where the chapter length chart shows gaps between each chapter. The easiest way to fix it is to strip the anchors from the NCX prior to sending, but this is a little time-consuming on longer books (or ones with hilariously disproportionate number of chapters for the length).

Is there an easier way to remove the anchors? I don't mind whether it's in editor or re-converting the ePubs.

Last edited by ownedbycats; 12-31-2021 at 03:28 PM.
ownedbycats is offline   Reply With Quote
Old 12-31-2021, 03:31 PM   #2
lomkiri
Groupie
lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.
 
lomkiri's Avatar
 
Posts: 167
Karma: 1497966
Join Date: Jul 2021
Device: N/A
In the editor, "mode regex", "current file", uncheck DOT-ALL :
Code:
search:
<content src="\K(.+(?=#))[^"]*("/>)
replace:
\1\2

Last edited by lomkiri; 12-31-2021 at 03:56 PM. Reason: better regex
lomkiri is offline   Reply With Quote
Advert
Old 12-31-2021, 06:45 PM   #3
retiredbiker
Evangelist
retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.
 
retiredbiker's Avatar
 
Posts: 450
Karma: 3886916
Join Date: May 2013
Location: Ontario, Canada
Device: Kindle KB, Oasis, Pop_Os!, Kobo Forma
I have a more dynamite approach. First, if there are any html-based toc files in the text area, I delete them--never use them on my Kobo. Then I go into the toc editor and empty it completely. Finally I rebuild the toc "from files", and maybe rename a few entries if they are not appropriate, usually front matter files. This rebuilds the ncx with "top of file" pointers and the Kobo loves it. (If there is an epub3 nav.html file, delete that and let it rebuild as well.)

The kind of book you describe almost always has chapters properly in files, so this works about as stated. If the chapters/files aren't properly done, or if there are other problems, that can take a while to correct, but I still find it the best way for reading.
retiredbiker is offline   Reply With Quote
Old 12-31-2021, 10:07 PM   #4
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
I do a couple of different things, depending on the book and how I feeling at the time.

If the calibre ToC generation adds the id to the heading, I will frequently change the existing heading to a paragraph and add a heading with a class to not display it at the top of the file. This usually happens when there is a bit of code at the start of the chapter to display an image or something.

Other times, I generate the ToC, open the NCX and remove the anchors with a search for:

Code:
\#.*?"
and replace with the double quote.

Of course, this doesn't work if there are headings elsewhere in the chapters.
davidfor is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Table of Contents not being identified as Table of Contents openletter Conversion 2 10-19-2012 12:54 AM
table of contents trocchietto Android Devices 0 08-21-2012 12:00 PM
Using Table of Contents sammieb77 enTourage Archive 7 01-14-2011 08:01 PM
Help with my Table of Contents Skylinefranc Calibre 0 03-19-2010 12:55 AM
only the table of contents wang960 Sony Reader 3 08-29-2008 12:45 PM


All times are GMT -4. The time now is 04:24 PM.


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