匿名
未登录
登录
游戏档案馆
搜索
查看“模块:Table row counter”的源代码
来自游戏档案馆
命名空间
模块
讨论
更多
更多
页面操作
阅读
查看源代码
历史
←
模块:Table row counter
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:认证用户
您必须确认您的电子邮件地址才能编辑页面。请通过
参数设置
设置并确认您的电子邮件地址。
您可以查看和复制此页面的源代码。
-- This module counts table rows in wikitext. local p = {} local getArgs function p.main(frame) if not getArgs then getArgs = require('Module:Arguments').getArgs end return p._main(getArgs(frame, {wrappers = 'Template:Table row counter'})) end function p._main(args) -- Get the title object. local titleObj do local success success, titleObj = pcall(mw.title.new, args.page) if not success or not titleObj then titleObj = mw.title.getCurrentTitle() end end -- Get the page content. local content = titleObj:getContent() if not content then return nil end -- Find the wikitables on that page. local wikitables = {} do local iWikitable = 0 local s1 = content:match('^({|.-\n|})') if s1 then iWikitable = iWikitable + 1 wikitables[iWikitable] = s1 end for s in content:gmatch('\n({|.-\n|})') do iWikitable = iWikitable + 1 wikitables[iWikitable] = s end end -- Find the wikitable to work on. local wikitable if args.id then for i, s in ipairs(wikitables) do if s:match('^{|[^\n]*id *= *" *(%w+) *"') == args.id then wikitable = s break end end else wikitable = wikitables[tonumber(args.tableno) or 1] end if not wikitable then return nil end -- Count the number of rows. local count do local temp temp, count = wikitable:gsub('\n|%-', '\n|-') end -- Control for missing row markers at the start. if not wikitable:find('^{|[^\n]*%s*\n|%-') then count = count + 1 end -- Control for extra row markers at the end. if wikitable:find('\n|%-[^\n]-%s*\n|}$') then count = count - 1 end -- Subtract the number of rows to ignore, or the number of header -- rows if it's empty, and make sure the result isn't below zero. local headers do local temp temp, headers = wikitable:gsub('\n|%-\n!', '\n|-\n!') end if not wikitable:find('^{|[^\n]*%s*\n|%-\n!') then headers = headers + 1 end count = count - (tonumber(args.ignore) or headers) if count < 0 then count = 0 end return count end return p
本页使用的模板:
模块:Table row counter/doc
(
查看源代码
)
返回
模块:Table row counter
。
导航
导航
首页
资源站
沙盒
最近更改
随机页面
MediaWiki帮助
Wiki工具
Wiki工具
特殊页面
页面工具
页面工具
用户页面工具
更多
链入页面
相关更改
页面信息
页面日志