local make_pdf
local Meta = function(meta)
-- For use outside this function
make_pdf = meta['my-filter-pdf']
if not (make_pdf) then
local includes = meta['header-includes']
-- Make sure we have a list
if 'List' ~= pandoc.utils.type(includes) then
if nil == includes then
includes = pandoc.List({ })
else
-- Assume the current value makes sense as a meta list item
includes = pandoc.List({ includes })
end
end
includes:insert(pandoc.RawBlock('html', [=[...]=]))
meta['header-includes'] = includes
return meta
end
return nil
end
return {
{ Meta = Meta },
main_filter
}
``````
% pandoc -L my-filter.lua -M my-filter-pdf ...
At least guaranteed surprise free...