本站页面(多半)转载自
萌娘百科
的同名页面,依CC BY-NC-SA 3.0引入,贡献者可以在历史页查询。
因各种原因页面内容可能和源页面有所出入,
非本站特有页面内容请以萌娘百科为准
。此外,因萌百的api限制,本站部分页面和图片同步自
另一个镜像站
。
置顶公告:
【置顶】关于临时开启评论区所有功能的公告(2022.10.22)
|
【置顶】关于本站Widget恢复使用的公告
你好~!欢迎来到萌娘百科镜像站!
如需查看或编辑,请联系本站管理员注册账号。
本镜像站和其他萌娘百科的镜像站
无关
,请注意分别。
查看“Module:SectionEmbed”的源代码
←
Module:SectionEmbed
跳到导航
跳到搜索
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
local module = {} local getArgs = require('Module:Arguments').getArgs function errorMsg(text) error(text..'[[分类:含有错误嵌入片段的页面]]') end function module._main(args, frame) local titleName = args['page'] or '' if titleName == '' then errorMsg('请传入要载入内容所在的页面!') end local section = args['id'] or '' section = string.gsub(section, '([%%%(%)%.%+%-%*%?%[%]%^%$])', '%%%1') local params = args params['page'] = nil params['id'] = nil local title = mw.title.new(titleName) local redirect = '' local content = title:getContent() if content == nil then errorMsg('页面名无效,请确认传入的页面名是否正确!') end if string.find(content, '^#REDIRECT%s+%[%[.+%]%]%s*$') or string.find(content, '^#重定向%s+%[%[.+%]%]%s*$') then redirect = string.gsub(content, '.+%[%[(.+)%]%]%s*$', '%1') title = mw.title.new(redirect) content = title:getContent() if content == nil then errorMsg('传入的页面【'..titleName..'】为一个重定向页,并且它指向的页面【'..redirect..'】无效!') end end local redirectMsg = '' if redirect ~= '' then redirectMsg = '(重定向至'..redirect..')' end local ptn = '^(.-)<!%-%-%s*embed:?%s*'..(((section ~= '') and section) or '.-').. '%s*%-%->%s*(.-)%s*<!%-%-%s*embed%-end:?%s*'..(((section ~= '') and section) or '.-').. '%s*%-%->.-$' local sample = content content = mw.ustring.gsub(content, ptn, function(s1, s2) s1 = string.gsub(s1, '([^\n]*)\n', function(s3) if string.find(s3, '^(==?=?=?[^\n]-==?=?=?)$') then return s3..'\n' else return '' end end) local frame_child = frame:newChild({ title = (((redirect ~= '') and redirect) or titleName), args = params }) return string.gsub(frame_child:preprocess(s1..'\n@@@sectionEmbed-target@@@sectionEmbed-target@@@\n'..s2), '^.-\n@@@sectionEmbed%-target@@@sectionEmbed%-target@@@\n(.-)$', '%1') end) if sample == content then if section ~= '' then errorMsg('嵌入失败,请确认在页面【'..titleName..'】'..redirectMsg..'是否存在id为“'..section..'”的embed嵌入标记,并检查书写是否正确!') else errorMsg('嵌入失败,请确认在页面【'..titleName..'】'..redirectMsg..'是否存在embed嵌入标记,并检查书写是否正确!') end end return content end function module.main(frame) local args = getArgs(frame) return module._main(args, frame) end return module
本页使用的模板:
Template:Documentation
(
查看源代码
)(仅允许管理员和巡查姬)
Template:Documentation/docname
(
查看源代码
)
Module:SectionEmbed/doc
(
查看源代码
)
返回
Module:SectionEmbed
。
导航菜单
个人工具
登录
命名空间
模块
讨论
English
已展开
已折叠
查看
阅读
查看源代码
查看历史
更多
已展开
已折叠
搜索
导航
首页
随机页面
最近更改
最新文件
萌娘原味图裤
讨论版
帮助
帮助
沙盒
Wiki入门
萌百编辑教程
编辑规范
萌娘百科政策
创建新条目
请求创建条目
常见问题集
分类索引
作品
人物
组织
概念用语
设定
软件
活动
工具
链入页面
相关更改
特殊页面
页面信息