Jump to content

Module:Respell/sandbox

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Nardog (talk | contribs) at 23:27, 17 January 2019. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
local p = {}

function p._main(args)
	local ret, link = {}
	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('[%-_]$') and not 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
		-- For documentation: Blank parameter at the end suppresses the link
		if not args[i + 1] and v ~= '' then link = true end
	end
	ret = '<i title="English pronunciation respelling">' ..
		string.gsub(table.concat(ret), '_', ' ') .. '</i>'
	ret = link and '[[Help:Pronunciation respelling key|' .. ret .. ']]' or ret
	return ret
end

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

return p