模块:Note:修订间差异
来自Blockland Wiki
更多操作
创建页面,内容为“ 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…” |
无编辑摘要 |
||
| 第40行: | 第40行: | ||
if target ~= '' then | if target ~= '' then | ||
local prefix = description ~= '' | |||
and description .. ',请参阅' | |||
or '其他用法,请参阅' | |||
table.insert( | |||
output, | |||
prefix .. link(target) .. '。' | |||
) | |||
i = i + 2 | i = i + 2 | ||
else | else | ||
| 第67行: | 第64行: | ||
local content = table.concat(output) | local content = table.concat(output) | ||
if content == '' then return '' end | |||
-- 直接生成原模板的 HTML,避免循环 | |||
local html = mw.html.create('div') | |||
:addClass('hatnote') | |||
:cssText( | |||
'display:flex;' .. | |||
'align-items:flex-start;' .. | |||
'margin:0.45em 0 0.65em 1.6em;' .. | |||
'font-size:0.875em;' .. | |||
'line-height:1.55;' | |||
) | |||
html:tag('div') | |||
:cssText( | |||
'flex:0 0 25px;' .. | |||
'width:25px;' .. | |||
'margin-right:0.45em;' .. | |||
'padding-top:0.05em;' | |||
) | |||
:wikitext( | |||
'[[File:消歧义.png|23px|link=|alt=]]' | |||
) | |||
html:tag('div') | |||
:cssText('flex:1;min-width:0;') | |||
:wikitext(content) | |||
return | return tostring(html) | ||
end | end | ||
return p | return p | ||
2026年11月15日 (日) 12:20的版本
此模块的文档可以在模块: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
local prefix = description ~= ''
and description .. ',请参阅'
or '其他用法,请参阅'
table.insert(
output,
prefix .. link(target) .. '。'
)
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
-- 直接生成原模板的 HTML,避免循环
local html = mw.html.create('div')
:addClass('hatnote')
:cssText(
'display:flex;' ..
'align-items:flex-start;' ..
'margin:0.45em 0 0.65em 1.6em;' ..
'font-size:0.875em;' ..
'line-height:1.55;'
)
html:tag('div')
:cssText(
'flex:0 0 25px;' ..
'width:25px;' ..
'margin-right:0.45em;' ..
'padding-top:0.05em;'
)
:wikitext(
'[[File:消歧义.png|23px|link=|alt=]]'
)
html:tag('div')
:cssText('flex:1;min-width:0;')
:wikitext(content)
return tostring(html)
end
return p