我的问题是关于pandoc中的lua过滤器。
我有此代码:
{{% notice info %}}
Частота RAM должна быть не менее **2133 Mhz**
CPU не менее производительный, чем **Intel Xeon E5-2650V4**
Производительность дисковой подсистемы не менее **300 IOPS**
{{% /notice %}}
使用hugo正确地将其转换为html。现在,我想使用pandoc将其转换为PDF。
pandoc -i minimal_private_cloud.ru.md -o ~/Documents/tmp.ru.pdf --from markdown --template eisvogel --listings -V lang=ru-RU --pdf-engine=xelatex --lua-filter ~/tmp/replace_macro.lua --filter pandoc-latex-environment
我的lua过滤器(~/tmp/replace_macro.lua
)的内容:
function Para (el)
content_str = pandoc.utils.stringify(el.content)
local cont = string.match(content_str, "{{%% code file=(.*) %%}}")
local notice_start = string.match(content_str, "{{%% notice info %%}}")
local notice_end = string.match(content_str, "{{%% /notice %%}}")
if cont ~= nil then
local cont_cleared = string.match(cont, "([%w._/]+)")
print(cont_cleared)
cont = "/home/still/Documents/Documents Work/Currentwork/Doc" .. cont_cleared
print(cont)
local f = io.open(cont, 'r')
local doc = pandoc.read(f:read('*a'))
f:close()
return doc.blocks
else
--print 'not a date'
end
if notice_start ~= nil then
print("Notice info start finded!")
local doc = pandoc.Plain("::: info")
return {doc}
end
if notice_end ~= nil then
print("Notice end finded!")
local doc = pandoc.Plain(":::")
return {doc}
end
end
现在,此代码生成带有诸如::: info
之类的难看标记的PDF。
第二个过滤器(pandoc-latex-environment
)会产生带有此标记的美丽气味。
仅当我在原始md中写了此标记时,它才起作用。 如果我尝试用lua更改此标记-它将失败。
P.S。对不起,我的英语不好。