When I worked with LaTeX I used a lot of footnotes. I don't know why but I love them!
Manually taking care of the numbering can be tedious and I felt like I should learn a little bit more m4. So I added two macros#0 to my Static Site Generator that I use to build my blog.
Let's have a look:
In a nutshell: We have two counter variables
$ nl stddef.m4 | grep __fn 15 define(`__fnc', 0) 16 define(`FN', `$1<a href=`#'__fnc>`#'__fnc</a>define(`__fnc', incr(__fnc))') 17 define(`__fnlc', 0) 18 define(`FNL', `<li id=__fnlc>__fnlc: $1</li>define(`__fnlc', incr(__fnlc))')
__fnlcand two macros
FNis used to mark the word the footnote is attached to and
FNLto create a list entry at bottom of the page.
I don't want a space between the word and the footnote marker. m4 would not recognize the macro if I would write
<p>Some text inside a HTML document that needs a footnote`'FN.</p> ... <ul> FNL(Nothing to see here) </ul>
footnoteFN. One way to circumvent this is to use an empty quoted string like you see above. As I did design the macro to take a parameter you could also use
The trick is that the macro we call contains a redefinition of the counter variable in which we increase the counter variable every time we invoke the macro. That way I only#1 need to keep the actual foot note entries in the correct order.