Kirby Wiki
Advertisement

Documentation for this module may be created at Module:Filestrip/doc

-- <nowiki>
-- 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 '')
    p.caption = frame.args[2] or ''
    p.count = 0
    file = file
        :gsub('%s-%[+[fF]ile:([^|%]]*)[^%]]-%]+%s-', p.replacer)
    if p.count > 1 then--add last number
        file = file .. ' (' .. p.count .. ')'
    end
    return file
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
Advertisement