模組:Anchor
外观
有機器人使用本模块
如欲移動、刪除或修改此模块而無法向下兼容,並會影響機器人運作,請先通知機器人操作者,謝謝您。相關的機器人:User:Cewbot/log/20201008/configuration |
本模組由{{anchor}}所執行,詳見模板頁文檔。
請注意:所有會產生網頁錨點的模板或模組,改動時皆應通知User:cewbot,預防機器人誤動作。
上述文档嵌入自Module:Anchor/doc。 (编辑 | 历史) 编者可以在本模块的沙盒 (创建 | 镜像)和测试样例 (创建)页面进行实验。 本模块的子页面。 |
--模塊嵌入{{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