View Single Post
Old 11-26-2023, 08:27 PM   #2
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
This is a question with a very tricky technical solution, so if you have never used regex it will be a great learning experience! It will also involve some pretty tedious editing (at first, anyway) unless you like the adrenaline rush of hitting "replace all" and watching your book dissolve. (No, of course you're working on a copy.) With that warning, here is a start:

If you look at the html coding for footnotes and endnotes inside an ebook, you will find a lot of this sort of thing:

<a id="page_11">...</a>
and
<a href="page_11">something like <sup>1</sup></a>

Where "a" means attribute, "id" is of course an identifier, and "href" gives a link's destination...in the case of an ebook the href means go to the id. There is a lot more to it, and it can get very complicated, but these are the basic codes to look for.

Unfortunately, tables of content, bibliographies, web links and other things you might want to keep use the same codes.

So some simple search and replace to blow all these things away is possible, but very dangerous, depending on the book. I have blown them all away in novels because I don't use a textual table of contents, only to find I've spoiled something unexpected.

Using regex in the editor is indeed the way to go, but be super careful of any "replace all" actions.

For the sake of your sanity, start on a simple book, not something with 500 pages of reference notes!

Just for a starter, set the editor search box to "regex" and look for <a id=.*?> and <a href=.*?>. Go through the book with find, find, find...see how it is structured. Then you can figure out what will need replacing. It may be simple and obvious. But if you have some new epub3 horror from a publisher showing off useless coding, good luck figuring it out.

A good tutorial on regex in Calibre is here: https://manual.calibre-ebook.com/regexp.html

Last edited by retiredbiker; 11-26-2023 at 08:40 PM.
retiredbiker is offline   Reply With Quote