본문으로 이동

모듈:Anchor

위키문헌 ― 우리 모두의 도서관.
모듈 설명문서[보기] [편집] [역사] [새로 고침]

이 모듈은 {{앵커}} 틀을 구현합니다. 설명문서의 경우 틀 문서를 참고해 주십시오.

-- {{anchor}}에 쓰이는 모듈입니다.

local getArgs = require('모듈:Arguments').getArgs
local tableTools = require('모듈:TableTools')

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 = tableTools.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 class="anchor" id="' .. anchor .. '"></span>'
	end
	return table.concat(ret)
end

return p