简体   繁体   中英

Pandoc Lua Filter: How to access the title variable?

My document looks like this

---
title: 'Test'
---

lorem ipsum

I want to access the title variable to print it like this:

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

The caption of all images should be: 'Image of chapter Test' .

Something like this should work (untested), inspired by 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM