Pandoc:引用完整来源

问题描述

为了创建教学大纲,我想知道是否可以插入引文作为完整引文。现在,我有以下降价代码

# Session 1

@zhu2015.

这会将 pdf 中的 (pandoc "document.md" -o "document.pdf" --from markdown --template "eisvogel" --listings --citeproc) 转换为


会话 1

朱和巴萨 (2015)。

参考书目

朱、权彦和塔梅尔巴萨。 2015. “信息物理控制系统的鲁棒性、安全性和弹性的博弈论方法:最佳跨层弹性控制系统的博弈中原则。” 控制系统,IEEE 35 (1):46–65。


但是,是否可以将参考文献作为全文引用插入文本中?

例如:


会话 1

朱、权彦和塔梅尔巴萨。 2015. “信息物理控制系统的鲁棒性、安全性和弹性的博弈论方法:最佳跨层弹性控制系统的博弈中原则。” 控制系统,IEEE 35 (1):46–65。


感谢您的帮助!

解决方法

以下是使用 Lua filter 执行此操作的方法:首先,过滤器查找生成的参考书目条目并将其保存到表中,由引用键索引。然后查找引文并将其替换为完整条目。

local refs = {}

local function store_refs (div)
  local ref_id = div.identifier:match 'ref%-(.*)$'
  if ref_id then
    refs[ref_id] = div.content
  end
end

local function replace_cite (cite)
  local citation = cite.citations[1]
  if citation and refs[citation.id] and #cite.citations == 1 then
    return pandoc.utils.blocks_to_inlines(refs[citation.id])
  end
end

return {
  {Div = store_refs},{Cite = replace_cite},}

将上述内容保存到一个文件中,然后使用 --lua-filter 命令行选项将该文件传递给 pandoc。过滤器必须在 citeproc 处理器完成其工作后运行,因此它应该是最后一个命令行参数。使用最新的 pandoc 2.12 版进行了测试(不再需要 pandoc-citeproc,但它应该可以工作)。