Module:InfoboxImage: Difference between revisions

From Totem Arts Wiki
Jump to navigation Jump to search
RaiderAlpha (talk | contribs)
No edit summary
RaiderAlpha (talk | contribs)
Undo revision 4492 by RaiderAlpha (talk)
Tag: Undo
 
(4 intermediate revisions by the same user not shown)
Line 10: Line 10:
         return ""
         return ""
     end
     end
     local gallery = args[1]:match('<slides>(.+)</slides>')
     local wikitext = mw.text.trim(args[1])
    local gallery = wikitext:match('<gallery>(.+)</gallery>')
     if gallery then
     if gallery then
        local size = args[2] or '250px'
        local tabberArgs = {'tabber', ''}
         for match in gallery:gmatch("[^%c]+") do
         for match in gallery:gmatch("[^%c]+") do
             local split = mw.text.split(match, "|", true)
             local split = mw.text.split(match, "|", true)

Latest revision as of 18:41, 22 December 2020

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

--
-- This module implements {{InfoboxImage}}
--
 
local p = {}

p.main = function(f)
    local args = f:getParent().args
    if args[1] == nil then
        return ""
    end
    local wikitext = mw.text.trim(args[1])
    local gallery = wikitext:match('<gallery>(.+)</gallery>')
    if gallery then
        local size = args[2] or '250px'
        local tabberArgs = {'tabber', ''}
        for match in gallery:gmatch("[^%c]+") do
            local split = mw.text.split(match, "|", true)
            local file = mw.text.trim(split[1] or '')
            if not file:match("File:(.+)") then
                file = "File:" .. file
            end
            local desc = mw.text.trim(split[2] or '')
            tabberArgs[2] = tabberArgs[2] .. "\n|-|\n " .. desc.. "=\n[["
            tabberArgs[2] = tabberArgs[2] .. file .. "|" ..size.. "]]"
        end
        return f:callParserFunction('#tag', tabberArgs)
    else
        return args[1]
    end
end

return p