【发布时间】:2021-11-04 19:38:20
【问题描述】:
我想在 Pandoc Lua 过滤器中将 CodeBlock 转换为 LineBlock。该转换的问题在于CodeBlock 元素具有text 属性(字符串),但LineBlock 需要内联内容元素(每个单词、空格、换行符等都有自己的元素)。如何将text 属性转换为适合LineBlock 的内容?
这就是我的代码在 ATM 上的样子:
function CodeBlock(el)
-- test for manually generating content
-- return pandoc.LineBlock {{pandoc.Str("Some")}, {pandoc.Space()}, {pandoc.Str("content")}}
-- using read does not work, how can I convert the string el.text?
local contentElements = pandoc.read(el.text)
return pandoc.LineBlock(contentElements)
end
【问题讨论】: