FANDOM


-- This module implements {{anchor}}.
-- This is a modified version from [[wp:Module:Arguments]].
 
-- <nowiki>
 
local getArgs = require('Dev:Arguments').getArgs
 
-- [=[ Local implementation/mod of "compressSparseArray" ]=] ---------------------
local function compressSparseArray(t)
    local ret = {}; -- because freaking metatables
 
    for _,v in pairs(t) do
        if (v ~= nil) then ret[#ret + 1] = v; end;
    end
 
    return ret;
end
 
-- [=[ Native program continues... ]=] -------------------------------------------
local p = {}
 
function p.main(frame)
	-- Get the positional arguments from #invoke, remove any nil values,
	-- and pass them to p._main.
	local args = getArgs(frame)
	local argArray = compressSparseArray(args)
	return p._main(unpack(argArray))
end
 
function p._main(...)
	-- Generate the list of anchors.
	local anchors = {...}
	local ret = {}
	for _, anchor in ipairs(anchors) do
		ret[#ret + 1] = '<span id="' .. anchor .. '"></span>'
	end
	return table.concat(ret)
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.