模块:Note
来自Blockland Wiki
更多操作
此模块的文档可以在模块:Note/doc创建
local p = {}
local function trim(s)
if s == nil then return '' end
return mw.text.trim(tostring(s))
end
local function link(page)
page = trim(page)
if page == '' then return '' end
return '[[' .. page .. ']]'
end
function p.about(frame)
local args = frame:getParent().args
local subject = trim(args[2])
local section = trim(args.section)
local pageType = section ~= '' and '章节' or '条目'
local output = {}
if subject ~= '' then
table.insert(
output,
'此' .. pageType .. '介绍的是' .. subject .. '。'
)
end
local i = 3
while i <= 31 do
local description = trim(args[i])
local target = trim(args[i + 1])
if description == '' and target == '' then
break
end
if target ~= '' then
if description ~= '' then
table.insert(
output,
description .. ',请参阅' .. link(target) .. '。'
)
else
table.insert(
output,
'其他用法,请参阅' .. link(target) .. '。'
)
end
i = i + 2
else
table.insert(
output,
'其他用法,请参阅' .. link(description) .. '。'
)
break
end
end
local extra = trim(args.text)
if extra ~= '' then
table.insert(output, extra)
end
local content = table.concat(output)
if content == '' then
return ''
end
return frame:expandTemplate{
title = 'Note',
args = {'消歧义', content}
}
end
return p