title_body: Automating Footnote Links 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:
  
  &lt;p&gt;Some authorities reported greater casualties &lt;sup&gt;4&lt;/sup&gt;, while at least one reported fewer &lt;sup&gt;5&lt;/sup&gt;.&lt;/p&gt;
  
  
  After I finish linking to my footnotes, that text would probably look something like this:
  
  &lt;p&gt;Some authorities reported greater casualties &lt;sup&gt;&lt;a href="#1-4" title="1-4"&gt;4&lt;/a&gt;&lt;/sup&gt;, while at least one reported fewer &lt;sup&gt;&lt;a href="#1-5" title="1-5"&gt;5&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;
  
  
  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).
upvoted_answer: 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.