I'm working with Dreamweaver, InDesign and BBEdit, so a solution that works with any of these programs would be great.

I'm converting a book that's in the public domain to an ebook. Each chapter has a series of superscript numbers that reference footnotes at the bottom of each page. I'm going to move all the footnotes to an appendix at the end of the book, then hyperlink the superscripts to the appropriate location.

Each chapter's footnotes begin with 1, 2, 3, etc. So I'll probably need to distinguish between chapters by linking to something like #1-1 and #2-1 for the first footnote in chapters 1 and 2, for example.

Anyway, I'd like to know if there's a way to automate the hyperlinking process. Some typical text would look like this:

<p>Some authorities reported greater casualties <sup>4</sup>, while at least one reported fewer <sup>5</sup>.</p>

After I finish linking to my footnotes, that text would probably look something like this:

<p>Some authorities reported greater casualties <sup><a href="#1-4" title="1-4">4</a></sup>, while at least one reported fewer <sup><a href="#1-5" title="1-5">5</a></sup>.</p>

I just wondered if anyone knows of a way to automate the linking process, using regular expressions, or one of the software programs I'm using. Each chapter is in a separate HTML file, and I can process one chapter at a time. I should also note that some footnotes are irregular, including letters (e.g. 14, 14a, 14b).

1 Answer 1


First, I don't think footnotes translate easily to HTML. Endnotes are way easier and more appropriate.

The problem here is that HTML isn't semantically rich enough to do these things automatically. You need to manually do the numbering.

I use docbook XML to create citations and endnotes. Very easy to do. Then I use docbook XSLT to output everything in clean HTML. That is a powerful solution, especially if you are comfortable using XSLT. http://www.sagehill.net/docbookxsl/Footnotes.html

Another out of the box solution is to edit source in Markdown language and then convert everything to HTML. I see that Pandoc has a footnote solution http://rmarkdown.rstudio.com/authoring_pandoc_markdown.html#footnotes

It would be worth looking into what capabilities Adobe Indesign has for creating footnotes/endnotes. They have an Export-to-epub capability, and maybe the output renders the footnotes/endnotes in a nonsucky way.

Failing that, regular expressions are the way to go. But you might look into this: https://www.w3.org/TR/html5/common-idioms.html#footnotes

At the risk of trying to simplify your need, a lot can be said for just doing it manually rather than trying to change your production process. This is true especially if you already know the number for each footnote -- like, are you just reproducing the footnote number from a public domain work? Maintaining under 100 citations manually might be less trouble than you think.

  • Actually, I have over a thousand citations to manage. Still, I think you're right - it might be easiest in the long run to just do it manually and get it right. Your other tips are awesome; they give me a lot of possibilities to explore.
    – WordBear
    Jan 26, 2017 at 16:51
  • I didn't look into all the variations of markdown; it might be worthwhile for you to do so. It's hard to do proper numbering if you have each chapter as an html file. I bet though that the latest versions of CSS let you continue numbering at an arbitrary number . Aha, I'm right. w3schools.com/css/css_counters.asp (very useful!) Not sure if it's supported on epub and mobi though. Jan 26, 2017 at 17:11
  • I now am liking the idea of using css counters to auto-increment numbering on footnotes/endnotes for a chapter. Jan 26, 2017 at 17:13
  • I should have mentioned that my first ebook is going to simply be a revision of a classic reference that's in the public domain. The first chapter has over 300 superscripts (beginning with 1) referencing footnotes at the bottom of each page. The other chapters have anywhere from a couple dozen to 200-300 superscripts, each one beginning with one. I'd like to make the ebook similar to the original, except that I want to group all the footnotes together at the end of the book.
    – WordBear
    Jan 26, 2017 at 17:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.