Hi, I'm new to lua, so forgive me if this is something basic.
I'm trying to create a filter to convert the text "{{pagebreak}}" into a
docx page break. I know there are existing haskel filters for this, and
that I could also use a raw block directly in my docx (I've done that
already) but I wanted to scratch my itch and do it with a lua filter.
So far trying different approaches I have ended up with:
-- file: macro-expander.lua
function pagebreak_to_docx (inlines)
if #inlines ~= 1 then return end
if inlines[1].t == 'Str' and inlines[1].text == "{{pagebreak}}" then
return pandoc.RawBlock{"openxml", ""}
end
end
function Para (c)
return pagebreak_to_docx(c.content)
end
Still when I run it with a basic example, I get the following error:
Could not read list: Could not get Block value: Expected a string but got a
nil
Right at the exact place where the {{pagebreak}} occurs.
Without the filter:
$ echo -e "Raw Block in md: \n\n\`\`\`{=openxml}\n\n\`\`\` \n\nLua
Filter Test: \n\n{{pagebreak}}" | pandoc -f markdown -t native
[Para [Str "Raw",Space,Str "Block",Space,Str "in",Space,Str "md:"]
,RawBlock (Format "openxml") ""
,Para [Str "Lua",Space,Str "Filter",Space,Str "Test:"]
,Para [Str "{{pagebreak}}"]]
With the filter I'd expect the last Para to turn into a RawBlock but...
$ echo -e "Raw Block in md: \n\n\`\`\`{=openxml}\n\n\`\`\` \n\nLua
Filter Test: \n\n{{pagebreak}}" | pandoc -f markdown -t native
--lua-filter="./macro-expander.lua"
Error running filter ./src/servicio-gestion-software/macro-expander.lua:
Could not read list: Could not get Block value: Expected a string but got a
nil
Any help would be appreciated.
Thanks!
--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/e32ff546-810b-4df6-a96e-71b07b753397%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.