Module:Officeholder party tracking

From Omniversalis
Revision as of 13:10, 23 May 2018 by Vivaporius (talk | contribs) (Created page with "local p = {} function p.tracking(frame) tcat = 'Category:Pages using infobox officeholder with an atypical party value' function isblank( val ) return (val == n...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Officeholder party tracking/doc

local p = {}

function p.tracking(frame)
	tcat = 'Category:Pages using infobox officeholder with an atypical party value'
    function isblank( val ) 
        return (val == nil) or val:match('^[%s]*$')
    end
	local function iswikilink(s)
		return s and s ~= ''
	end
	
	local pname = frame.args.party or ''
	if isblank(pname) then
		return ''
	end
	pname = mw.text.unstrip(pname)
	if pname:match('^%s*%[%[([^%[%]]*)%]%]%s*$') then
		return ''
	end
	tkey = pname:match('^%s*(.-)%s*$')
	tkey = mw.ustring.gsub(tkey, '[%[%]|]', '')
	tkey = mw.ustring.gsub(tkey, '[^%w\-_ ]', '?')
	return '[[' .. tcat .. '|' .. tkey .. ' ]]'
end

return p