[英]Pandoc Lua : how to add a markdown block around a header without losing the markdown syntax #
I am trying to add a div around a markdown header in a Lua filter, but the # in front of the title disappear in the output.我正在尝试在 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
Input:输入:
# Linux
## Support for Linux users
Create a shell script
Expected Output预计 Output
::: test
# Linux
:::
## Support for Linux users
Create a shell script
The content
field contains the heading text, but the heading itself is the el
element that's not returned. content
字段包含标题文本,但标题本身是不返回的el
元素。 Returning it together with the raw blocks should work though:将它与原始块一起返回应该可以工作:
return {
pre, el, post
}
Or use a Div element:或者使用 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.