Pandoc过滤器将脚注添加到链接 [英] Pandoc Filter to add footnotes to links

查看:121
本文介绍了Pandoc过滤器将脚注添加到链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想问问是否有人知道Pandoc可以自动将脚注添加到任何链接的简短过滤器.我只想在我的打印文档中拥有可读的链接源. 因此,我想从

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

[link](url)

类似

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

因此,在印刷的PDF中,我所引用的链接的URL应该在页面底部可见.

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

推荐答案

尝试

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

这仅在PDF输出中有效,但是很简单,不需要过滤器. 请参阅"LaTeX的变量"下的用户指南/自述文件.

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."

使用这种方法,您不再在正文中具有超链接,而只有带有URL的注释.因此,这不完全是您要的,但是也许就够了.

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.

使用 pandoc过滤器的方法如下,并保留链接(未经测试,但应该靠近):

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

import Text.Pandoc.JSON

main = toJSONFilter go
  where go (Link attr lab (src, tit)) = Span ("",[],[]) [Link attr lab (src, tit), Note [Plain [Str src]]]
        go x = x

这篇关于Pandoc过滤器将脚注添加到链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆