Documentation for this module may be created at Module:Sandbox/Firefly/No ping with link color/doc

-- This module implements {{no ping with link color}}.

local p = {}

function p.main(frame)
	local args = frame:getParent().args
	local pageTitle = frame:getParent():getTitle()
	local styles = frame:extensionTag( 'templatestyles', '', { src = 'Module:Sandbox/Firefly/No ping with link color/styles.css' } );
	return p._main(args, pageTitle, styles)
end

function p._main(args, pageTitle, styles)
	local ret = {}
	local fullUrl = mw.uri.fullUrl
	local format = string.format
	for i, username in ipairs(args) do
		local url = fullUrl(mw.site.namespaces.User.name .. ':' .. username)
		url = tostring(url)
		local label = args['label' .. tostring(i)]
		local template = label or username
		if pageTitle.subpageText ~= 'Archive' or yesno(args['force_ifexist'], 'no') then
			if mw.title.makeTitle(2, username).exists then
				template = '<span title="User:' .. template .. '">' .. template .. '</span>'
				url = format('[%s %s]', url, template)
			else
				template = '<span title="User:' .. template .. ' (page does not exist)">' .. template .. '</span>'
				url = format('<span class="pseudoredlink">[%s %s]</span>', url, template)
			end
		end
		ret[#ret + 1] = url
	end
	ret = mw.text.listToText(ret)
	ret = styles .. '<span class="plainlinks">' .. ret .. '</span>'
	return ret
end

return p