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

问题描述 投票:0回答:1

我的文档看起来像这样

---
title: 'Test'
---

lorem ipsum

我想访问title变量来像这样打印它:

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

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

lua pandoc
1个回答
0
投票

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
© www.soinside.com 2019 - 2024. All rights reserved.