Module:AnimalList

local p = {} function p.animallist( f ) local args = f:getParent.args

local listtype, extrastyle = 'ul', '' local showOne = args.showQuantityOne or false local asPerCent = args.showQuantityAsPerCent or false

if args.columns ~= nil then extrastyle = extrastyle..'column-count:'..args.columns..';' end

if args.columnWidth ~= nil then extrastyle = extrastyle..'column-width:'..args.columnWidth..';' end

if args.marginLeft ~= nil then extrastyle = extrastyle..'margin-left:'..args.marginLeft..';' end

if args.listtype ~= nil then if args.listtype == 'ol' then listtype = 'ol' else -- none extrastyle = extrastyle..'list-style:none;margin-left:0;' end end

-- split first value at comma, e.g. for data from module:dv local animals = {} for v in mw.text.gsplit(args[1], ',', true) do   if #v > 0 then -- skip empty table.insert(animals, v)   end end -- append rest parameters for _,v in ipairs(args) do    if _ > 1 and #v > 0 then table.insert(animals, v)   end end

table.sort(animals)

-- read arguments list into animalList (consists of tables, at index 1 is the text) local animalList, i, lastItem = {}, 0, nil for _, item in ipairs(animals) do   item = item:match "^%s*(.-)%s*$" -- trim

if string.len(item) > 0 then table.insert(animalList, {item, nil} ) -- item is text i = i + 1 lastItem = item end end

-- output animalList local output = {} for _, item in ipairs(animalList) do   local fileName = string.gsub(item[1],':',' ')

table.insert(output, ''....(item[1])....'') end

if #output == 0 then return end

return '<'..listtype..(extrastyle ~=  and ' style="'..extrastyle..'"' or )..'>'..table.concat(output, '')..'' end

return p