Module:Sandbox/ChaoticShadow/SongDataLine

local getArgs = require('Module:Arguments').getArgs

local p = {} local args = {}

local root = mw.html.create('table'):addClass('wikitable')

function p.main(frame) args = getArgs(frame)

languages = { {			name = "jp", pattern = "^jp[0-9]+$", lyrics = {} },		{			name = "en", pattern = "^en[0-9]+$", lyrics = {} }	}	for k,v in pairs(args) do		for _,lang in ipairs(languages) do			if string.match(k, lang.pattern) then ind = tonumber(string.match(k, "[0-9]+")) lang.lyrics[ind] = v				break end end end local maxLen = 0 for _,lang in pairs(languages) do		maxLen = math.max(maxLen, #lang.lyrics) end local _row = root:tag('tr') for _,lang in ipairs(languages) do		_row:tag('th'):css('width', string.format("%d\%%", 100 / #languages)):wikitext(lang.name) end for i=1,maxLen,1 do		local _row = root:tag('tr') local nextContent = nil for _,lang in ipairs(languages) do			local content = 'temp' if lang.lyrics[i] ~= nil then content = lang.lyrics[i] end _row:tag('td'):wikitext(content) nextContent = lang.lyrics[i+1] or nextContent end if nextContent == nil then break end end

return tostring(root) .. mw.dumpObject(args) .. mw.dumpObject(languages) end

return p