Module:Gallery

local p = {}

function p.main( frame ) local arguments = frame:getParent.args local gallery = {} -- After a line break comes an image local last_one_had_line_break = true for idx, argument in ipairs( arguments ) do		local has_line_break = argument:sub( argument:len ) == '\n' argument = mw.text.trim( argument ) if last_one_had_line_break then -- It is an image or video gallery[ #gallery + 1 ] = argument else gallery[ #gallery ] = gallery[ #gallery ] .. '|' .. argument end last_one_had_line_break = has_line_break end return frame:extensionTag{ name = 'gallery', content = table.concat( gallery, '\n' ) } end

function p.test local frame = mw.getCurrentFrame frame.getParent = function return { args = { 'Superbanner.png', 'Super banner\n', 'Superbanner.png\n', 'Superbanner.png' }		}	end return p.main( frame ) end

return p