Module:Reformat

local export = {} local replace = mw.ustring.gsub local replace = mw.ustring.gsub local trim = mw.text.trim local find = mw.ustring.find local match = mw.ustring.match

function export.derivatives(frame) local text = trim([[

]])

local keep = { 'nnd_id', 'yt_id', 'yt_comment', 'singer', 'author', 'category', 'title', 'description', 'color' }

local optional = { 'nnd_comment', 'bb_id', 'bb_comment', 'nnd_id2', 'nnd2_comment', 'yt_id2', 'yt2_comment', 'pp_id', 'pp_comment', 'sc_id', 'sc_comment', 'sc_id2', 'sc2_comment', '5s_id', '5s_comment', 'mz_id', 'mz_comment', 'vm_id', 'vm_comment', 'tm_id', 'tm_comment', 'etc', 'etc_comment', 'etc2', 'etc2_comment', 'ROMAJI', 'width', 'height', 'icon', 'thumb' }

local p = frame.args

p['ROMAJI'] = p['romaji (english)']

for param, value in pairs(p) do		if param == 'title' then value = replace(value, 'cover', 'Cover') end if param == 'category' then value = replace(value, 'Cover', 'cover') value = replace(value, '[Uu]taite', 'Human') value = replace(value, '[Uu][Tt][Aa][Uu]', 'UTAU') value = replace(value, '[Vv][Oo][Cc][Aa][Ll][Oo][Ii][Dd]', 'VOCALOID') value = replace(value, '[Pp]iano', 'Instrumental') value = replace(value, '[Vv]iolin', 'Instrumental') -- value = replace(value, ';', ',') end if param == 'color' then value = replace(value, ' *; *color: *', '; color:') value = replace(value, ';$', '') end if param == 'romaji (english)' then return 'fkggrgopdopfgb' end

if value ~= '' then text = replace(text, '|<'..param..'>', '|'..param..' = '..value) end end

for i, param in ipairs(keep) do		text = replace(text, '|<'..param..'> ?', '|'..param..' = ') end for i, param in ipairs(optional) do		text = replace(text, '|<'..param..'> ?', '') end

text = replace(text, ' +', ' ') text = replace(text, '\n+', '\n') text = replace(text, ' \n', '\n')

-- text = replace(text, 'ROMAJI = ', 'romaji (english) = ')

return text end

return export