Module:Anchor

-- This module implements. -- This is a modified version from wp:Module:Arguments. -- 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 = {} local _frame 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) _frame = frame return p._main(unpack(argArray)) end function p._main(...) -- Generate the list of anchors. local anchors = {...} local ret = {} for _, anchor in ipairs(anchors) do	   local tag = anchor:match("^#(%u%u+)") if tag then if tag == "REFS" then -- Do nothing, handled by template. end else local anch_cont = { ' ' } table.insert(anch_cont, 2,                (anchor:gsub( "%[%[(.-)%]%]", function(link)                    return link:gsub("^.-|",'')                end ))            ) ret[#ret + 1] = table.concat(anch_cont,'') end end

return table.concat(ret) end return p