Module:Filestrip

-- -- Lua module that changes file links in infoboxes -- to proper infobox gallery items local p = {}

function p.strip (frame) local file = mw.text.trim(frame.args[1] or '') local onlymultiple = frame.args[3] or false p.caption = frame.args[2] or '' p.count = 0 local newfile = file :gsub('%s-%[+[fF]ile:([^|%]]*)[^%]]-%]+%s-', p.replacer) if p.count > 1 then -- add last number newfile = newfile .. ' (' .. p.count .. ')' if onlymultiple then newfile = '' end elseif onlymultiple then return file end return newfile end

function p.replacer (captures) local s = '' if p.count > 0 then s = ' (' .. p.count .. ')\n' end s = s .. captures .. '|' .. p.caption p.count = p.count + 1 return s end

return p