Search code examples
regexmarkdownpandocfootnotes

Generate inline rather than list-style footnotes in Pandoc Markdown output?


When converting from some format (say, HTML or Docx) to Markdown in Pandoc, is it possible to render all footnotes in the inline style ("this is the main text^[this is a footnote]") rather than as numbered references with a corresponding list at the end of the document? I want to work on my Markdown documents (converted from a Docx of my thesis) as master texts, but now if I add a new footnote it messes up the numbering.

Alternatively, is there another convenient way (i.e. not Pandoc) that this could be done? Cutting text in one part of a file and adding corresponding text in another part seems a bit beyond a simple regex.

Thanks in advance for any help.

EDIT: I've just hacked up an extremely simple Python script to do this, in case anyone else has the same issue.


Solution

  • Pandoc's Markdown syntax is quite flexible about footnotes:

    The footnotes themselves need not be placed at the end of the document. They may appear anywhere except inside other block elements (lists, block quotes, tables, etc.).

    Like:

    Here is a footnote reference[^1] and some more text.
    
    [^1]: Here is the footnote.
    
    Here's the next paragraph.
    

    However, the Markdown Writer (the module that generates markdown files, as opposed to reading them) currently simply places all of them at the end of the document. But this could be implemented behind a flag, similar to the --reference-links flag. Feel free to submit an issue or pull request!