The editors' meeting has been canceled for technical reasons.
Module:Tabs
此模块的文档可以在Module:Tabs/doc创建
local p = {}
function p.main(frame)
local args = frame:getParent().args
local tabs = {}
local indices = {}
-- 收集所有存在的标签索引
for k, _ in pairs(args) do
local num = k:match('^bt(%d+)$') or k:match('^tab(%d+)$')
if num then
num = tonumber(num)
indices[num] = true
end
end
-- 转换并排序索引
local sorted = {}
for k in pairs(indices) do
table.insert(sorted, k)
end
table.sort(sorted)
-- 处理默认标签
local default = tonumber(args.DefaultTab) or 1
if default < 1 or default > #sorted then
default = 1
else
default = sorted[default] -- 修正为实际存在的标签索引
end
-- 构建标签内容
local tabberContent = {}
for _, i in ipairs(sorted) do
local bt = args['bt'..i] or ''
local bticon = args['bticon'..i] or ''
local tab = args['tab'..i] or ''
-- 构建标题
local title = bticon .. bt
if i == default then
title = title .. '@selected'
end
-- 处理特殊字符
title = mw.text.nowiki(title)
tab = mw.text.nowiki(tab)
table.insert(tabberContent, '|-| '..title..' = '..tab)
end
return '<tabber>\n'..table.concat(tabberContent, '\n')..'\n</tabber>'
end
return p