Pandoc Lua:如何在标题周围添加markdown块而不丢失markdown语法#



我试图在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

最新更新