跳到内容
折叠侧栏
删除百科
搜索
个人工具
创建账号
登录
导航
首页
分类索引
随机条目
最近更改
工具
链入页面
相关更改
特殊页面
页面信息
查看“Module:LinkTools”的源代码
模块
讨论
English
阅读
查看源代码
查看历史
更多
阅读
查看源代码
查看历史
←
Module:LinkTools
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
local p={} --{{#invoke:LinkTools|navRedirect}} function p.navRedirect(frame) local args, working_frame if frame == mw.getCurrentFrame() then -- We're being called via #invoke. The args are passed through to the module -- from the template page, so use the args that were passed into the template. args = frame.args working_frame = frame else -- We're being called from another module or from the debug console, so assume -- the args are passed in directly. args = frame working_frame = mw.getCurrentFrame() if type(args) ~= type({}) then args = {frame} end end local title = mw.text.trim(args[1] or args['1'] or '') local display = mw.text.trim(args[2] or args['2'] or '') local title_obj = mw.title.new(title) local title_target = title_obj local section = '' local title_sp = mw.text.trim(mw.ustring.sub(title, (({mw.ustring.find(title, '#')})[1]or 0)+1, -1) or '') if title_obj then if title_obj.isRedirect then title_target = title_obj.redirectTarget end if mw.text.trim(display) == '' then display = ((mw.text.trim(title_sp) == '') and title or title_sp) end section = mw.text.trim(title_target.fragment or '') local cur_title = mw.title.getCurrentTitle() if (cur_title.namespace == title_target.namespace) and (cur_title.text == title_target.text)then local section_text = '' local section_name = mw.text.trim(title_target.fragment or '') if section_name ~= '' then section_text = "([[#" .. section_name .. "|章節]])" end return "'''"..display.."'''"..section_text end return "[["..title.."|"..display.."]]" else return '' end end function p.loadpage(page) local page_name = page if type(page) == type({}) then page_name = (page.args or page)[1] elseif type(page) == type(nil) then return '' elseif type(page) ~= type("string") then page_name = tostring(page) end page_name = tostring(page_name or '') if mw.text.trim(page_name) ~= '' then local title_obj = mw.title.new(page_name) pcall(title_obj.getContent, title_obj) end return '' end return p
本页使用的模板:
Module:LinkTools/doc
(
查看源代码
)
返回
Module:LinkTools
。