Module:Sandbox/28bytes/acm

From Wikipedia, the free encyclopedia

local p = {}

p.gettitle = function( frame )
	
	local fmter = frame.args[1]
	local base = frame.args[2]
	local disam = frame.args[3]

	if fmter == nil then
		fmter = "" --optional
	end
	if base == nil or base == "" then
		error("Missing/empty parameter; see module documentation for usage")
		return ""
	end
	if disam == nil then
		disam = "" --optional
	end
		
	local c = ""
	if mw.ustring.find(fmter,"q") ~= nil then
		c = "\""
	elseif mw.ustring.find(fmter,"t") ~= nil then
		c = "''"
	end
	
	local title = ""
	if disam == "" then
		title = c .. "[[" .. base .. "]]" .. c
	else
		title = "[[" .. base .. " " .. disam .. "|" ..
			c .. base .. c ..  " " .. disam .. "]]"
	end
	
	local separator = " "
	if mw.ustring.find(fmter,"o") ~= nil then
		separator = separator .. "‹›"
	end
	if mw.ustring.find(fmter,"?") ~= nil then
		separator = separator .. "[[File:Symbol question.svg|20px]]"
	end
	if mw.ustring.find(fmter,"G") ~= nil then
		separator = separator .. "[[File:Symbol support vote.svg|20px]]"
	end

	return title .. separator .. " "
		
end

return p