Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 08-25-2022, 02:22 AM   #1
kawaberitan
Junior Member
kawaberitan began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Aug 2022
Device: samsung s8
bridging endnotes in scanned document

have a scanned book, the author put the endnotes at the end of the chapter. but when converting to docx, endnotes bookmarks and hyperlinks are not created. There are close to 600 endnotes I don't want to do it manually Is there a macro or shortcut to link the endnotes?
Thanks in advance.
kawaberitan is offline   Reply With Quote
Old 08-25-2022, 06:14 AM   #2
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,312
Karma: 20171571
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
Welcome to MR!

Assuming there are no issues with copyright then the question is whether the notes have a standardized format that is distinct from surrounding text.
If they are then you can use regex to create them. Sigil or Calibre Editor have that functionality.
Turtle91 is offline   Reply With Quote
Advert
Old 08-29-2022, 04:25 PM   #3
Tex2002ans
Wizard
Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.
 
Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
Quote:
Originally Posted by Turtle91 View Post
Welcome to MR!
Same. Welcome to MR, kawaberitan!

Quote:
Originally Posted by kawaberitan View Post
I don't want to do it manually Is there a macro or shortcut to link the endnotes?
No.

But to speed things up, there are a few tricks you can do with:
  • Regular Expressions
  • + Merging, then splitting files

If the code in your EPUB is clean, it's relatively simple.

- - -

Let's say your book has footnotes in the form of:

Chapter1.xhtml:

Code:
<p>This is an example.<sup>1</sup></p>
Endnotes.xhtml:

Code:
<p>1. This is an endnote.</p>
See how all little note numbers have:
  • <sup>
  • + a number
  • </sup>

and all endnotes have:
  • <p>
  • + a number
  • + a period

Your book will probably have slightly different code/patterns...

But these will help when you create a regular expression!

What you ultimately want is something like this:

Code:
<p>This is an example.<a href="#fn1" id="ft1">[1]</a></p>

<hr />

<p class="footnote"><a href="#ft1" id="fn1">[1]</a> An example footnote.</p>
  • The first one says:
    • "go visit fn1" + "my id is ft1"
  • The second one says the opposite:
    • "go visit ft1" + "my id is fn1"

These are just 2 simple HTML links pointing back/forth!

So... How do we get there?

Step 1: Regular Expressions

- - -

Note: In Sigil/Calibre, make sure you put your search into "Regex" Mode.

After you are done, make sure you set it back to how it was.

- - -

Step 1.1: Change Superscript into Clickable Link

We want to change <sup>1</sup> into an actual link:

Search: <sup>(\d+)</sup>
Replace: <a href="#fn\1" id="ft\1">[\1]</a>

How does this search work?
  • <sup> = look for a superscript
  • \d+ = look for ONE OR MORE numbers
    • This has () wrapped around it.
    • Parentheses are special symbols in regular expressions they stand for a "Capture Group".
    • It says "Take whatever you found between these parentheses, and shove it into Group 1".
  • </sup> = look for a closing superscript

Replace says:
  • <a = Create a new link
  • href="#fn\1" = Point to "fn" + whatever we captured in Group 1
  • id="ft\1"> = Make my id "ft" + whatever we captured in Group 1
  • [\1] = Put a bracket, then whatever we captured, then a closing bracket.
  • </a> = Close the link.

- - -

Now, we just do the opposite.

Step 1.2: Change Footnote/Endnote into Clickable Link

Search: <p>(\d+)\.
Replace: <p class="footnote"><a href="#ft\1" id="fn\1">[\1]</a>

Again, this is very similar. The Search is doing:
  • <p> = Look for a paragraph.
  • (\d+) = Look for a ONE OR MORE numbers + toss it into "Group 1".
  • \. = Look for a period.
    • Note: The '.' is a very special symbol in Regular Expressions. Because we want to look for an actual PERIOD character, we need the slash.

Replace is very similar.

- - -

Step 1.3: Test Links Back/Forth

Open up the book in Preview, then click the links and see if they work!

If they send you to the proper location, great! You're all done.

- - -

Step 2 (Optional): Merge + Split Files

Honestly, I recommend footnotes at the end of each file... this:
  • makes the <a> code MUCH MUCH easier.
  • keeps each chapter as a standalone file.

If you want to have a separate endnotes file... you can follow the trick I wrote about in:

This combines all files into one "merged.xhtml" file, then splits them all back up.

This lets Sigil/Calibre take care of all the renaming of chapter links.

- - - - - - -

Side Note: If you want to learn even more about footnotes, I've written about this extensively over the years.

Type this in your favorite search engine:

Code:
footnotes tex2002ans site:mobileread.com
and there are over 500 topics which I've discussed this. Most recently:

And remember:

Get the notes into clean links.

And KISS (Keep It Simple, Stupid)!

The less complicated your make your code, the less likely things are going to go wrong.

Last edited by Tex2002ans; 08-29-2022 at 04:41 PM.
Tex2002ans is offline   Reply With Quote
Old 09-18-2022, 09:27 PM   #4
kawaberitan
Junior Member
kawaberitan began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Aug 2022
Device: samsung s8
Thank you so much friends.
kawaberitan is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Endnotes within Endnotes Alcuin7 Editor 22 11-30-2018 01:41 PM
Glo tapping on endnotes meneillosmr Kobo Reader 14 01-26-2016 10:14 AM
About pop-up endnotes roger64 Conversion 4 01-07-2016 07:15 PM
Endnotes Siam Sigil 14 03-17-2013 02:05 PM
How to convert a Word document into a Kindle document? PS Kindle Kindle Developer's Corner 2 12-08-2009 08:40 PM


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


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