local p = {}
function p.main(frame)
local args = frame:getParent().args
local items = {}
for _, value in pairs(args) do
if value ~= '' then -- ignores empty arguments
table.insert(items, value)
end
end
local count = #items
if count == 0 then
return "" -- returns nothing if empty
elseif count == 1 then
return items[1] -- just return the string input if alone
elseif count == 2 then
return items[1] .. " and " .. items[2] -- returns "string1, string2, ... and last_string"
else
local last = table.remove(items)
return table.concat(items, ", ") .. " and " .. last
end
end
return p