모듈:Anchor: 두 판 사이의 차이

우트나피쉬팀의 배
둘러보기로 이동 검색으로 이동
(Add class per edit request)
 
잔글 (판 1개를 가져왔습니다: Category:Mbox_and_messagebox_templates)
 

2024년 1월 7일 (일) 20:50 기준 최신판

이 모듈에 대한 설명문서는 모듈:Anchor/설명문서에서 만들 수 있습니다

-- This module implements {{anchor}}.

local getArgs = require('Module:Arguments').getArgs
local tableTools = require('Module: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