簡體   English   中英

Pandoc Lua 過濾器:如何訪問標題變量?

[英]Pandoc Lua Filter: How to access the title variable?

我的文檔看起來像這樣

---
title: 'Test'
---

lorem ipsum

我想訪問 title 變量以這樣打印:

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

所有圖像的標題應為: 'Image of chapter Test'

文檔啟發,這樣的事情應該可以工作(未經測試):

title = nil

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

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM