Pandoc Lua 过滤器:如何访问标题变量?

Pandoc Lua Filter: How to access the title variable?

我的文档是这样的

---
title: 'Test'
---

lorem ipsum

我想访问标题变量以像这样打印它:

function Image (elem)
elem.attributes.caption = 'Image of chapter ' .. title
return elem

所有图片的标题应为:'Image of chapter Test'

像这样的东西应该可以工作(未经测试),灵感来自 the docs:

title = nil

function Meta(m)
  title = m.title
  return m
end

function Image (elem)
  elem.attributes.caption = 'Image of chapter ' .. title
  return elem
end