I recently discovered that you could read ebooks with the footnotes at the bottom of the page like in a real book (instead of a link to the end matter), and this lit my brain on fire. I've never seen this before, and it feels so obvious that it should just... be how it is for all books. This led me on a personal missing to convert all the footnotes for all of my ebooks into that properly formatted structure. I'm using KOReader as my ereader app of choice, and that's the one I'm testing with and want to make sure it works on.
Here's what I know so far.
1. The books have to be in EPUB3
2. The minimum effort required is to wrap the body of the footnote with an aside tag, like `<aside epub:type="footnote" id="[whatever the ID is]">`
3. This is complicated AF
I have two scripts (ChatGPT wrote them and I provided feedback and logs) that attempt to wrap the body of the footnote text with `<aside epub:type="footnote" id="[whatever the ID is]">`. Unfortunately, the footnotes are formatted differently from book to book (even with the same author and publisher), and the scripts have not worked consistently for most books, or even consistently within a single book.
For example, I bought 38 Terry Pratchett books from Humble Bundle. After converting the EPUB2 books to EPUB3, one of the scripts successfully converted around 20 books (although it left some nested footnotes that were not caught by the script), and the second script caught another 10 or so. In the end, there are 5 books that I have not been able to automatically convert.
At this point, I think there are two options; fix the scripts so that they wrap the footnotes in the aside tag, OR create a new script that scrapes the footnote text and completely rebuilds the footnotes using a cleaner format.
The new, cleaner format would look something like this:
Code:
<!--Converting to single lines-->
<!--Inline-->
<p>This is some text that needs a footnote.<a href="FN_Section0001.xhtml#fn1" epub:type="noteref" id="bookfn1">[1]</a></p>
<!-- Footnote content -->
<body>
<aside epub:type="footnote" id="fn1">
<p>This is the content of the footnote. <a href="9780061807145_Chapter_1_split_000.xhtml#bookfn1">↩</a></p>
</aside>
</body>
If you want to take a look, I have the two python scripts available for review, as well as 70 ebooks (About 109 MB) with the copywritten information scrambled for script development and testing, linked here:
Dropbox.
If anyone has any ideas or suggestions, I'm all ears; as it is, I will keep posting here as I experiment and make progress.