From 672a4bdd1d4a587feaa38613fce64335adaad76d Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Wed, 15 Jan 2020 23:26:00 +0100 Subject: Lua filters: allow filtering of element lists (#6040) Lists of Inline and Block elements can now be filtered via `Inlines` and `Blocks` functions, respectively. This is helpful if a filter conversion depends on the order of elements rather than a single element. For example, the following filter can be used to remove all spaces before a citation: function isSpaceBeforeCite (spc, cite) return spc and spc.t == 'Space' and cite and cite.t == 'Cite' end function Inlines (inlines) for i = #inlines-1,1,-1 do if isSpaceBeforeCite(inlines[i], inlines[i+1]) then inlines:remove(i) end end return inlines end Closes: #6038 --- test/lua/meta.lua | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 test/lua/meta.lua (limited to 'test/lua/meta.lua') diff --git a/test/lua/meta.lua b/test/lua/meta.lua new file mode 100644 index 000000000..5e2946203 --- /dev/null +++ b/test/lua/meta.lua @@ -0,0 +1,6 @@ +function Meta (meta) + meta.old = nil + meta.new = "new" + meta.bool = (meta.bool == false) + return meta +end -- cgit v1.2.3