跳转到内容

Module:Anchor:修订间差异

轻之舟百科,让知识轻装启航
删除的内容 添加的内容
enwiki>Pppery
Add class per edit request
 
IdleTap-bot​(留言 | 贡献)
导入自求闻百科
 
第1行: 第1行:
-- This module implements {{anchor}}.
--模塊嵌入{{anchor}}


local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs
第19行: 第19行:
local ret = {}
local ret = {}
for _, anchor in ipairs(anchors) do
for _, anchor in ipairs(anchors) do
ret[#ret + 1] = '<span class="anchor" id="' .. anchor .. '"></span>'
ret[#ret + 1] = '<span id="' .. anchor .. '"></span>'
end
end
return table.concat(ret)
return table.concat(ret)

2026年8月3日 (一) 15:02的最新版本

本模組由模板链接:{{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 id="' .. anchor .. '"></span>'
	end
	return table.concat(ret)
end

return p