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

自作多情 提交于 2019-12-10 19:43:01

问题


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.


回答1:


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!




回答2:


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.



来源:https://stackoverflow.com/questions/33984689/generate-inline-rather-than-list-style-footnotes-in-pandoc-markdown-output

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!