- 致编者:请牢记我们的域名wiki.mcbe-dev.net!
- 致编者:欢迎加入本Wiki的官方交流QQ群或Discord服务器!
- 基岩版1.19.31现已发布!(了解更多)
- Inner Core现已支持Xbox模组联机!(了解更多)
- 如果您是第一次来到本Wiki,欢迎注册一个账户
- 点击顶部的“编辑”或“编辑源代码”按钮即可编辑当前页面
- 请知悉:在不登录时也可以编辑和新建页面,但是您当前的IP地址会记录在编辑历史中
Module:Breadcrumb
来自Minecraft基岩版开发Wiki
local p = {}
function p.auto(_)
local args = require('Module:ProcessArgs').merge(true)
local display = args.title
local title = mw.title.getCurrentTitle()
local namespace = title.nsText
local breadcrumbs = {}
local pages = mw.text.split(title.text, '/', true)
local current = table.remove(pages)
if (require('Module:Yesno')(args.snakecase, true)) then
current = mw.ustring.lower(mw.ustring.gsub(current, ' ', '_'))
end
local temp = namespace
if (temp ~= '') then
temp = temp .. ':'
end
for _, page in ipairs(pages) do
temp = temp .. page
table.insert(breadcrumbs, '[[:' .. temp .. '|' .. page .. ']]')
temp = temp .. '/'
end
if (display) then
table.insert(breadcrumbs, display)
else
table.insert(breadcrumbs, current)
end
return table.concat(breadcrumbs, ' <wbr>> ')
end
local function parse(title, namespace)
title = mw.ustring.match(title, '^%[%[(.*)%]%]&') or title
local suffix = mw.text.split(title, '|', true)
if (#suffix > 1) then
title = table.remove(suffix, 1)
suffix = table.concat(suffix, '|')
else
suffix = nil
end
if title == '...' or title == '…' then
return suffix or '…'
end
local split = mw.text.split(title, ':', true)
local size = #split
if suffix then
suffix = '|' .. suffix .. ']]'
else
local pages = mw.text.split(split[size], '/', true)
suffix = '|' .. pages[#pages] .. ']]'
end
if (size > 1) then
namespace = table.remove(split, 1)
title = table.concat(split, ':')
end
if (namespace and namespace ~= '') then
return '[[:' .. namespace .. ':' .. title .. suffix
else
return '[[:' .. title .. suffix
end
end
function p.breadcrumb(_)
local args = require('Module:ProcessArgs').merge(true)
local title = mw.title.getCurrentTitle()
local namespace = args.namespace or title.nsText
local display = args.title
local breadcrumbs = {}
for _, page in ipairs(args) do
table.insert(breadcrumbs, parse(page, namespace))
end
if (display) then
table.insert(breadcrumbs, display)
elseif (require('Module:Yesno')(args.snakecase, true)) then
table.insert(breadcrumbs, mw.ustring.lower(mw.ustring.gsub(title.subpageText, ' ', '_')))
else
table.insert(breadcrumbs, title.subpageText)
end
return table.concat(breadcrumbs, ' <wbr>> ')
end
return p