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

2

3

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.

Pronominal answered 29/11, 2015 at 15:51 Comment(1)
Hmm, I was going to say that your desired output is not even a valid footnote in Markdown, but then I checked and Pandoc actually accepts that as a footnote. As Pandoc is the only Markdown implementation that I am aware of which accepts that syntax, I would avoid it if at all possible. It seems like a bad design decision to begin with.Leverick
E
4

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!

Episode answered 30/11, 2015 at 9:16 Comment(0)
S
0

Inline footnotes and references are quite nice for writing and editing markdown documents, but cumbersome for reading them.

I used ltrgoddard's inliner with success to process several files that I use with pandoc and latexmk to produce PDF. inliner works well for transforming end-style references to inline style references in an already-written document.

Cross references to other questions and clues for posterity:

Convert markdown links from inline to reference

Vim plugin for adding external links

Also see http://drbunsen.github.io/formd/ and https://instant-thinking.de/2014/02/20/markdown-footnotes-with-vim/ for more info re: formd, which should work for converting inline references end-style references, and vice-versa.

Note that formd works on URLs and ignores footnotes, so this may be seen as a similar project (with different goals) but not an alternative.

Saum answered 30/4, 2018 at 21:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.