Module:Sandbox/Ahecht/navboxtolua

return {[''] = function(frame) local lists = {} local params = {} local numbers = {} local args = require('Module:Arguments').getArgs(frame) local output = "{\n" for k,v in pairs(args) do		local n = mw.ustring.sub(k,-1) if not params[n] then table.insert(numbers, n)			params[n] = {} end params[n][k] = v	end table.sort( numbers ) for _,n in ipairs(numbers) do		a = params[n] if a['group'..n] then output = output .. 'group' .. n .. ' = "' .. a['group'..n] .. '",\n' end if a['abbr'..n] then output = output .. 'abbr' .. n .. ' = "' .. a['abbr'..n] .. '",\n' end if a['state'..n] then output = output .. 'state' .. n .. ' = "' .. a['state'..n] .. '",\n' end if a['list'..n] then local k = 'list'..n			local v = a['list'..n]			if mw.ustring.find(v,'####',1,true) then output = output .. k .. ' = _navbox({[1] = "child",\n\n}),\n' elseif mw.ustring.find(v,'\n',1,true) then table.insert(lists, "===" .. mw.ustring.upper(k) .. "===\n" .. mw.ustring.gsub(mw.ustring.gsub(v,"%[","【"),"%]","】") .. "\n") output = output .. k .. ' = [=[\n\n]=],\n' else output = output .. k .. ' = [=[\n' .. mw.ustring.gsub(v,'^%*%s*','') .. '\n]=],\n' end end end return "==Params==\n" .. frame:callParserFunction( '#tag', 'pre', output .. "}" ) .. '\n==Lists==\n' .. table.concat(lists) end }