Jump to content

Module:Sortkey

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Johnuniq (talk | contribs) at 01:43, 28 June 2018 (Module:Arguments defaults to removing blank arguments but gives an error with string.find; for example List of rampage killers (Asia) uses {{hs|}}). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local getArgs = require('Module:Arguments').getArgs

local p = {}

function p._encode(sortkey)
	-- Protect against sortkey nesting.
	-- Example: {{sort|{{dts|2013|07|07}}|{{dts|1990|12|01}}}}
	if string.find(sortkey, "sortkey") or string.find(sortkey, "data-sort-value") then
		return "";
	end
    return mw.text.encode(sortkey)
end

function p.encode(frame)
	local args = getArgs(frame);
	return p._encode(args[1] or "")
end

return p