Fandom

Vocaloid Wiki

Module:To table

7,905pages on
this wiki
Add New Page
Talk0

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

local export = {}
local replace = mw.ustring.gsub
local split = mw.text.split
local trim = mw.text.trim
 
--[=[
 
see [[User:Umbreon126/to table]] for usage
 
]=]
 
function export.old(frame)
	local text = '\n' .. frame.args[1]
	text = replace(text, '\n', '\n|\n|-\n|')
	text = replace(text, '%|%-\n%|\n%|\n%|%-', '|-\n|<br />\n|-')
	text = replace(text, '^\n%|\n%|%-', '')
	return trim(text) .. '\n|\n\|}'
end
 
local heads = {
	["ja"] = { "''Japanese'' (日本語歌詞)", "''Romaji'' (ローマ字)" },
	["zht"] = { "''Chinese'' (中文歌詞)", "''Pinyin'' (拼音)" },
	["zhs"] = { "''Chinese'' (中文歌词)", "''Pinyin'' (拼音)" },
	["ko"] = { "''Korean'' (한국어 가사)", "''Romaja'' (로마자)" },
 
	["zh"] = { '<span class="error">Traditional (<code>zht</code>) or simplified (<code>zhs</code>)?</span>', '<span class="error">Traditional (<code>zht</code>) or simplified (<code>zhs</code>)?</span>' },
}
 
function export.show(frame)
	local lang, original, roman = frame.args[1], frame.args[2], frame.args[3] or ''
	local text = ''
 
	text = text .. '{| style="width:100%"'
	text = text .. '\n' .. '! align=left |' .. heads[lang][1]
	text = text .. '\n' .. '! align=left |' .. heads[lang][2]
 
	original = split(original, '\n')
	roman = split(roman, '\n') or {}
	for i = 1, #original, 1 do
		original[i] = '\n' .. '|' .. trim(original[i])
		if not roman[i] then roman[i] = '' end
		roman[i] = '\n' .. '|' .. trim(roman[i])
		text = text .. '\n' .. '|-' .. original[i] .. roman[i]
	end
 
	text = text .. '\n' .. '|}'
 
	text = replace(text, '|%-\n|\n|\n', '|-\n|<br />\n')
	text = replace(text, '|%-\n|([^あ-鿕\n]+)\n|\n', '|-\n|{{shared}}|%1\n')
 
	return text
end
 
return export

Also on Fandom

Random Wiki