![](/img/trans.png)
[英]Pandoc: in a .md file, how to modifiy the YAML metadata block and put the modified block in markdown format using a lua filter
[英]Pandoc Lua : how to add a markdown block around a header without losing the markdown syntax #
我正在尝试在 Lua 过滤器中围绕 markdown header 添加一个 div,但标题前面的 # 在 Z7135CEDD1F39383 中消失了
Header = function(el)
if el.level == 1 then
local content = el.content
local pre = pandoc.RawBlock('markdown','::: test')
local post = pandoc.RawBlock('markdown',':::')
table.insert(content,1,pre)
table.insert(content, post)
return content
else
return el
end
end
输入:
# Linux
## Support for Linux users
Create a shell script
预计 Output
::: test
# Linux
:::
## Support for Linux users
Create a shell script
content
字段包含标题文本,但标题本身是不返回的el
元素。 将它与原始块一起返回应该可以工作:
return {
pre, el, post
}
或者使用 Div 元素:
function Header (el)
if h.level == 1 then
return pandoc.Div(el, {class = 'test'})
end
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.