Roundtripping endnotes for EPUB from InDesign
Have you poured a long, complex Word file with hyperlinked endnotes into InDesign only to find their interactivity disappeared? Or maybe you managed to salvage the link to the endnotes but now you are wondering why there is no backlink from the endnote back to it’s reference point in the text in the EPUB?
I came up against this recently and felt very dumb. This can’t be that tricky to accomplish, can it? It’s not, but it took a fair bit of research, frustration, and whining to figure out a solution. I am going to explain my process but please tell me about yours. I am eager to find new efficiencies if at all possible.
A central character in this story is Peter Kahrel, scripter extraordinaire. A quick Google search about footnotes endnotes hyperlinking InDesign returns links to his website. He has already thought this question through and is, in fact, the hero of this story.
The first step is to make sure that the notes in your source Word file are footnotes, not endnotes. If they are endnotes, convert them to footnotes in a duped file that is for InDesign import only. The process is explained in detail here, but briefly:
- In “draft” view, go into View –> Footnotes
- Select all footnotes, then control-click opting for “Convert to Endnote”
It may take a minute depending on how big your document is and how strong your Word-fu is (mine isn’t), but that’s it.
Step Next is to install these two InDesign scripts in the scripts folder of whichever version of InDesign you are running. On this page, down at the bottom, you will find two scripts: “Footnote-to-endnote” script, and the “Return Links” script. You will need both.
Once the source Word file is imported into an InDesign template, running the first script will change the footnotes to endnotes, creating one-way hyperlinks via InDesign’s cross-referencing function, which you can see via the Cross References panel. The endnotes will be in a numbered list now.
Pay attention to the numbering of these references and mind any whose link has gone red. They must be sequential, and must be green in order for the next step to work without a hitch.
The second script will convert the list to live text and create return hyperlinks around the live note number. It needs consistently and cleanly applied style sheets in order to work well, in addition to no gaps at all in the footnote number sequence. Important caution: duplicate the file before you run the return link script. As someone who worked on a file with 641 endnotes who ran the script without a backup file and with gaps in the sequential order of the notes, I can tell you that this is not a mistake you want to make. Please learn from my terrible error.
Once boths scripts are run, the EPUB that you create from this file will have two-way endnote links. You won’t have to bend your mind to run fancy RegEx strings in order to add backlinks.
One final note: Peter Kahrel has generously made these scripts available for free. Please consider making a donation to him for his time and know-how via the PayPal link at the very bottom of the script page.