Module:Respell-en

From the RuneScape Wiki, the wiki for all things RuneScape
Jump to: navigation, search
Module documentation
This documentation is transcluded from Module:Respell-en/doc. [edit] [purge]
Module:Respell-en's function main is invoked by Template:Respell-en.

This module implements {{Respell-en}}. Please see the template page for documentation.

Wikipedia logo.svg
This page uses content from Wikipedia. The original article was at Module:Respell-en, and authors are listed in the page history. As with the RuneScape Wiki, the text of Wikipedia is available under the Creative Commons Attribution-ShareAlike License 3.0.

local p = {}

function p._main(args)
	local ret = {}
	for i, v in ipairs(args) do
		v = mw.text.trim(v)
		-- Compatibility: Ignore arguments that only contain an apostrophe
		if v ~= '' and v ~= "'" then
			if ret[#ret]
				and not (ret[#ret]:find('_') or ret[#ret]:find('%-%)?$'))
				and not (v:find('_') or v:find('^%(?%-'))
			then
				table.insert(ret, '-')
			end
			if v:find('^[%u%(%)]+$') then
				v = '<span style="font-size:90%">' .. v .. '</span>'
			end
			table.insert(ret, v)
		end
	end
	ret = '<i title="English pronunciation respelling">' ..
		table.concat(ret):gsub('_', ' ')
			 -- Avoid dangling hyphens
			:gsub(' %-', ' -&#8288;')
			:gsub('^%-', '-&#8288;')
		.. '</i>'
	if args.link ~= 'no' then
		ret = '[[wikipedia:Help:Pronunciation respelling/English|' .. ret .. ']]'
	end
	return ret
end

function p.main(frame)
	return p._main(frame:getParent().args)
end

return p