FANDOM

!
20 Pages

local helloworld = {}
local replace = mw.ustring.gsub
local trim = mw.text.trim
local itersplit = mw.text.gsplit
local split = mw.text.split
local match = mw.ustring.match
local itermatch = mw.ustring.gmatch
local find = mw.ustring.find
 
function helloworld.gallery(frame)
	local args = mw.clone(frame:getParent().args)
 
	local caption, colorpair = args['caption'] or '', args['color'] or 'royalblue; white'
 
	colorpair = split(colorpair, '; ?')
 
	local gallery = mw.html.create('gallery')
	gallery
		:attr('caption', caption)
 
		:attr('bordercolor', colorpair[1])
		:attr('captiontextcolor', colorpair[2])
 
		:attr('bordersize', 'none')
 
		:attr('captionposition', 'within')
		:attr('captionalign', 'center')
 
		:attr('widths', '115')
		:attr('position', 'center')
		:attr('spacing', 'small')
		:attr('orientation', 'square')
 
		:attr('navigation', 'true')
		:attr('orientation', 'true')
 
	local files, captions, targets = {}, {}, {}
	local skip_me_i_am_not_a_link = false
	for i = 1, #args do
		local one, two, three = args[i], args[i+1] or '', args[i+2] or ''
 
		if skip_me_i_am_not_a_link == true then
			skip_me_i_am_not_a_link = false
		elseif skip_me_i_am_not_a_link == false then
			if find(one, '%.%w%w%w$') then
				table.insert(files, trim(one))
				table.insert(captions, trim(two))
 
				if find(three, '%.%w%w%w$') then
					table.insert(targets, '')
					skip_me_i_am_not_a_link = true
				else
					table.insert(targets, trim(three))
				end
			end
		end
	end
 
	for i = 1, #files do
		if not find(captions[i], '%[%[') and targets[i] ~= '' then
			captions[i] = '[[' .. targets[i] .. '|' .. captions[i] .. ']]'
		end
 
		gallery:wikitext('\n' .. files[i] .. '|' .. captions[i] .. '|link=' .. targets[i])
	end
 
	gallery = tostring(gallery)
	gallery = frame:preprocess(gallery)
 
	return gallery
end
 
 
 
function helloworld.fielde(frame)
	local text = mw.text.unstripNoWiki(frame.args[1])
 
	text = trim(text)
 
	text = replace(text, 'o`', 'OO')
	text = replace(text, 'u`', 'UU')
	text = replace(text, 'n`', 'NN')
 
	text = replace(text, '\n([%a%d]+)\n', '\n{{center|— %1 —}}\n')
	text = replace(text, '&lt;br&gt;', '<br>')
	text = replace(text, '&lt;hr&gt;', '<noinclude>{{multicol-break}}</noinclude>')
	text = replace(text, '%[(.-)%]', function(a) return '{{swatow entry|〓|' .. replace(a, '[|.]', '|') .. '}}' end)
 
	text = replace(text, '(%a)2', '%1́')
	text = replace(text, '(%a)3', '%1̀')
	text = replace(text, '(%a)5', '%1̂')
	text = replace(text, '(%a)6', '%1̆')
	text = replace(text, '(%a)7', '%1̄')
 
	text = replace(text, 'OO', 'o̤')
	text = replace(text, 'UU', 'ṳ')
	text = replace(text, 'NN', 'ⁿ')
 
	text = mw.ustring.toNFC(text)
 
	return frame:preprocess('<pre><nowiki>' .. text .. '\n\n</nowiki></pre>')
end
 
function helloworld.maclay(frame)
	local text = mw.text.unstripNoWiki(frame.args[1])
 
	text = trim(text)
 
	text = replace(text, '&lt;hr&gt;', '<noinclude>{{multicol-break}}</noinclude>')
	text = replace(text, '%[(.-)%]', function(a) return '{{cdo-Maclay entry|' .. replace(a, '[|.]', '|') .. '}}' end)
	text = replace(text, 'x`', '<ref>〓〓</ref>`')
	text = replace(text, '`(.-)`', function(a) return '{{cdo-Maclay rom|' .. replace(replace(a, '(%d)', '|%1'), ' ', '|') .. '}}' end)
 
	text = replace(text, 'AA', 'ă')
	text = replace(text, 'EE', 'é')
	text = replace(text, 'ER', 'ë')
	text = replace(text, 'OO', 'ó')
	text = replace(text, 'UU', 'ü')
	text = replace(text, 'HH', 'ʻ')
 
	return frame:preprocess('<pre><nowiki>' .. text .. '\n\n</nowiki></pre>')
end
 
function helloworld.lim(frame)
	local text = mw.text.unstripNoWiki(frame.args[1])
 
	text = trim(text)
 
	text = replace(text, '`', ' || ')
	text = replace(text, '\n', '\n|-\n| ')
 
	text = replace(text, '(%a)2', '%1́')
	text = replace(text, '(%a)3', '%1̀')
	text = replace(text, '(%a)5', '%1̂')
	text = replace(text, '(%a)6', '%1̃')
	text = replace(text, '(%a)7', '%1̄')
	text = replace(text, '(%a)8', '%1̍')
 
	text = replace(text, 'UU', 'ṳ')
	text = replace(text, 'NN', 'ⁿ')
 
	text = replace(text, '叫', '呌')
	text = replace(text, '攜', '携')
 
	text = replace(text, '他', '伊')
	text = replace(text, '你', '爾')
 
	text = mw.ustring.toNFC(text)
 
	return frame:preprocess('<pre><nowiki>' .. text .. '\n\n</nowiki></pre>')
end
 
function helloworld.adam(frame)
	local text = mw.text.unstripNoWiki(frame.args[1])
 
	text = trim(text)
 
	text = '{{hi|\n' .. text .. '\n}}'
 
	text = replace(text, '([^\n]+)', '%1\n')
 
	text = replace(text, '%-%-', '&ndash;')
 
	text = replace(text, '/(.-)/', function(text)
		text = replace(text, '([aiueo])%1', '%1̤')
		text = replace(text, '2', '́')
		text = replace(text, '3', '̀')
		text = replace(text, '5', '̂')
		text = replace(text, '6', '̆')
		text = replace(text, '7', '̄')
		return '<i>' .. text .. '</i>'
	end)
 
	text = mw.ustring.toNFC(text)
 
	return frame:preprocess('<pre><nowiki>' .. text .. '\n\n</nowiki></pre>')
end
 
function helloworld.akusento(frame)
	local text = mw.text.unstripNoWiki(frame.args[1])
 
	text = trim(text)
 
	text = '{{rh|000|{{bold|000—000}}|000}}\n{{rule}}\n{{multicol|line=1px solid black}}\n' .. text .. '\n{{multicol-end}}\n{{nop}}'
 
	text = replace(text, '\n\n', '\n{{multicol-break}}\n')
 
	text = replace(text, '\n([^\n ]+) ', '\n{{bold|%1}} ')
	text = replace(text, '「', '{{ol|')
	text = replace(text, '」', '}}')
	text = replace(text, '([^\n]+)', '%1\n')
 
	text = trim(text)
 
	return frame:preprocess('<pre><nowiki>' .. text .. '\n\n</nowiki></pre>')
end
 
function helloworld.gen(frame)
	local start = tonumber(frame.args[1]) or 1
	local roof = tonumber(frame.args[2]) or 50
	local increment = tonumber(frame.args[3]) or 1
 
	local prepend = frame.args['^'] or ''
	local append = frame.args['$'] or ''
 
	local numbers = {}
 
	local i = start
 
	while not (i > roof) do
		table.insert(numbers, ' ' .. prepend .. i .. append)
		i = i + increment
	end
 
	return table.concat(numbers, '\n')
end
 
function helloworld.aa(frame)
	local text = mw.text.unstripNoWiki(frame.args[1])
 
	text = trim(text)
 
	local out = {}
 
	local function rom(text)
		text = replace(text, '/(.+)/', '<i>%1</i>')
		return replace(text, '([%[%]~])', {['[']='̆', [']']='̆', ['~'] = 'ʼ'})
	end
 
	local lastditto = {}
	lastditto['en'] = '{{ditto|????????|do.}}'
	lastditto['zh'] = '丨'
	lastditto['rom'] = '{{ditto|????????}}'
 
	local function ditto(text, lang)
		return replace(text, '=', lastditto[lang])
	end
 
	for line in itersplit(text, '\n') do
		if find(line, '`') then
			line = split(line, '`')
 
			if #line == 3 then
				line[1] = ditto(line[1], 'en')
				line[2] = ditto(line[2], 'zh')
				line[3] = ditto(line[3], 'rom')
 
				line[3] = rom(line[3])
 
				line[1] = '! ' .. line[1] .. '\n'
				line[2] = '| ' .. line[2] .. ' || '
				line[3] = line[3] .. '\n|-\n'
			elseif #line == 4 then
				line[2] = ditto(line[2], 'en')
				line[3] = ditto(line[3], 'zh')
				line[4] = ditto(line[4], 'rom')
 
				line[4] = rom(line[4])
 
				line[1] = '! ' .. line[1] .. ' || '
				line[2] = line[2] .. '\n'
				line[3] = '| ' .. line[3] .. ' || '
				line[4] = line[4] .. '\n|-\n'
			end
 
			table.insert(out, table.concat(line, ''))
		elseif line ~= '' then
			line = '|+ ' .. line .. '\n|-\n'
			table.insert(out, line)
		elseif line == '' then
			table.insert(out, '\n\n')
		else
			table.insert(out, line)
		end
	end
 
	text = table.concat(out, '')
 
	text = mw.ustring.toNFC(text)
 
	return frame:preprocess('<pre><nowiki>' .. text .. '\n\n</nowiki></pre>')
end
 
function helloworld.a(frame)
	local text = mw.text.unstripNoWiki(frame.args[1])
 
	text = trim(text)
 
	local out = {}
 
	for line in itersplit(text, '\n') do
		if match(line, '^p%d+') then
			line = replace(line, '^p(%d+)', '\nPage %1:')
		elseif match(line, '^`%d+') then
			line = replace(line, '^`(%d+)', '[panel %1]')
		elseif match(line, '^%~') then
			line = replace(line, '^%~(.+)', 'FX: @%1@')
		elseif match(line, '^\\') then
			line = replace(line, '^\\(.+)', '*%1*')
		else
			line = '????: ' .. line
		end
		table.insert(out, line)
	end
 
	text = table.concat(out, '\n')
 
	text = mw.ustring.toNFC(text)
 
	return frame:preprocess('<pre><nowiki>' .. text .. '\n\n</nowiki></pre>')
end
 
return helloworld

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.