Module:TableList

local p = {}

p.tableList = function(frame) -- https://stackoverflow.com/questions/1426954/split-string-in-lua function split (inputstr, sep) if sep == nil then sep = "%s" end local t={} for str in string.gmatch(inputstr, "([^"..sep.."]+)") do           table.insert(t, str) end return t	end local result = "" result = result .. "{| class=\"wikitable sortable tablelist\"\n" result = result .. "! Brand !! Model\n" for i, arg in ipairs(frame.args) do		if string.len(arg) > 0 then local argSplit = split(arg, ";") local brand = table.remove(argSplit, 1) -- if the last split element is empty, that means there was a trailing ';', so we can remove the last element if #string.gsub(argSplit[#argSplit], "%s", "") == 0 then table.remove(argSplit) end result = result .. "|-\n" result = result .. "| rowspan=" .. #argSplit .. "| " .. brand .. "\n" for j = 1, #argSplit do				local model = string.gsub(argSplit[j], "\n", " ") if j > 1 then result = result .. "|-\n" end result = result .. "| " .. model .. "\n" end end end result = result .. "|}"	return result end

return p