Permanently protected module

Module:Normalized pagename

From Yugipedia
Revision as of 14:00, 26 January 2019 by Dinoguy1000 (talk | contribs) (gsub() returns two values, but we only care about the first one, so we have to store back to the pagename variable before returning it, to discard the second value)
Jump to: navigation, search

-- <pre>

--
-- implements {{Normalized pagename}}
--

local mArguments --lazily initialize
local p = {}

function p.main( frame )
	mArguments = mArguments or require( 'Module:Arguments' )
	local args = mArguments.getArgs( frame, { parentOnly = true } )
	
	local pagename = args[1] or mw.title.getCurrentTitle().prefixedText
	
	pagename = pagename
		:gsub( '&#34;', '"' )
		:gsub( '&quot;', '"' )
		:gsub( '&#38;', '&' )
		:gsub( '&amp;', '&' )
		:gsub( '&#39;', "'" )
		:gsub( '&apos;', "'" )
		:gsub( '&#42;', '*' )
		:gsub( '&#59;', ';' )
		:gsub( '&#61;', '=' )
	
	return pagename
end

return p

-- </pre>