打开/关闭搜索
搜索
打开/关闭菜单
331
1.7K
131
11.8K
星露谷物语扩展百科
导航
首页
最近更改
随机页面
交流群
互通站
上传文件
打开/关闭外观设置菜单
通知
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。
user-interface-preferences
个人工具
创建账号
登录
查看“︁模块:Hatnote”︁的源代码
来自星露谷物语扩展百科
查看
阅读
查看源代码
查看历史
associated-pages
模块
讨论
更多操作
←
模块:Hatnote
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:已验证邮箱用户
您必须确认您的电子邮件地址才能编辑页面。请通过
参数设置
设置并确认您的电子邮件地址。
您可以查看和复制此页面的源代码。
local getArgs = require('Module:Arguments').getArgs local p = {} -- 获取页面类型 local function getPageType(title, hasSection) if hasSection then return '章节' end local nsText = title.nsText if nsText == '模板' then return '模板' elseif nsText == '模块' then return '模块' else return '条目' end end -- 格式化链接 local function formatLink(text) if text:find('[[', 1, true) and text:find(']]', 1, true) then return "“'''" .. text .. "'''”" else return "“'''[[" .. text .. "]]'''”" end end -- 检查是否为连接词 local function isConnector(text) return text == '和' or text == '或' or text == '、' end -- 获取最大数字索引 local function getMaxIndex(args) local maxIndex = 0 for key, _ in pairs(args) do local index = tonumber(key) if index and index > 0 and math.floor(index) == index then if index > maxIndex then maxIndex = index end end end return maxIndex end -- 处理描述和链接序列 local function processDescriptionLinks(args, startIndex, maxIndex, pagename) local parts = {} local state = '' -- 状态: '' | 'link' | 'end' for i = startIndex, maxIndex do local value = args[i] if value then if state == 'link' then table.insert(parts, formatLink(value)) state = 'end' elseif isConnector(value) then table.insert(parts, value) else if state == 'end' then table.insert(parts, ';') end local description = (value ~= '') and value or '其他用法' table.insert(parts, '关于' .. description .. ',请见') state = 'link' end end end -- fallback if state == 'link' then table.insert(parts, formatLink(pagename .. '(消歧义)')) end return parts, state end -- For function p.about(frame) local args = getArgs(frame, {trim = true, removeBlanks = true, parentOnly = true}) local maxIndex = getMaxIndex(args) local title = mw.title.getCurrentTitle() local pagename = title.text local contentParts = {'[[File:Disambig gray.svg|25px|link=]] '} if args[1] then local pageType = getPageType(title, args.section) table.insert(contentParts, '本' .. pageType .. '介绍的是' .. args[1]) end local subsequentParts = processDescriptionLinks(args, 2, maxIndex, pagename) if maxIndex < 2 and args[1] then table.insert(subsequentParts, '关于其他用法,请见' .. formatLink(pagename .. '(消歧义)')) end local finalParts = {table.concat(contentParts, '')} if #subsequentParts > 0 then if args[1] then table.insert(finalParts, '。 ') end table.insert(finalParts, table.concat(subsequentParts, ' ')) table.insert(finalParts, '。') elseif args[1] then table.insert(finalParts, '。') end local finalContent = table.concat(finalParts, '') return frame:expandTemplate{title = 'hatnote', args = {finalContent}} end -- For function p.for2(frame) local args = getArgs(frame, {trim = true, removeBlanks = true, parentOnly = true}) local maxIndex = getMaxIndex(args) local title = mw.title.getCurrentTitle() local pagename = title.text local contentParts = {'[[File:Disambig gray.svg|25px|link=]] '} if args.R then table.insert(contentParts, args.R) end local subsequentParts = processDescriptionLinks(args, 1, maxIndex, pagename) if maxIndex < 1 then table.insert(subsequentParts, '关于其他用法,请见') table.insert(subsequentParts, formatLink(pagename .. '(消歧义)')) end local finalParts = {table.concat(contentParts, '')} if #subsequentParts > 0 then if args.R then table.insert(finalParts, ' ') end table.insert(finalParts, table.concat(subsequentParts, ' ')) table.insert(finalParts, '。') end local finalContent = table.concat(finalParts, '') return frame:expandTemplate{title = 'hatnote', args = {finalContent}} end p['for'] = p.for2 return p
该页面嵌入的页面:
模块:Documentation
(
查看源代码
)
模块:Documentation/styles.css
(
查看源代码
)
模块:Hatnote/doc
(
查看源代码
)
模块:ProcessArgs
(
查看源代码
)
模块:STConversion
(
查看源代码
)
模块:Static
(
查看源代码
)
模块:TSLoader
(
查看源代码
)
返回
模块:Hatnote
。
查看“︁模块:Hatnote”︁的源代码
来自星露谷物语扩展百科