我试图在Lua过滤器中添加一个div,但是标题前面的#在输出中消失了。
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
预期输出
::: 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