Kageetai Kageetai - 1 year ago 152
Markdown Question

Pandoc Filter to add footnotes to links

I just wanted to ask if anyone knows a short filter for Pandoc to automatically add footnotes to any links. I just want to have readable link source in my printed documents.
So to specify, I'd like to go from


To something like

[link](url)[^link: url]

So in the printed PDF the URL of the links I am referring to, should be visible at the bottom of the page.

Answer Source


pandoc -o myfile.pdf -V links-as-notes=true myfile.md

This only works in PDF output, but it's simple and doesn't require a filter. See the User's Guide/README under "Variables for LaTeX."

Edit: with this approach, you no longer have a hyperlink in the main text, just a note with the URL. So it's not exactly what you were asking for, but maybe it's enough.

Edit: here's how you could do it with a filter, retaining the link (untested, but should be close):

import Text.Pandoc.JSON

main = toJSONFilter go
  where go (Link lab (src, tit)) = Span ("",[],[]) [Link lab (src, tit), Note [Plain [Str src]]]
        go x = x
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download