模組:Anchor

被永久保护的模块
维基百科,自由的百科全书
文档图示 模块文档[查看] [编辑] [历史] [清除缓存]

本模組由{{anchor}}所執行,詳見模板頁文檔。

請注意:所有會產生網頁錨點的模板或模組,改動時皆應通知User:cewbot,預防機器人誤動作。

--模塊嵌入{{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