「模組:FUMOCount」:修訂間差異
外觀
Naritaroad(留言 | 貢獻) 無編輯摘要 |
Naritaroad(留言 | 貢獻) 無編輯摘要 |
||
| 第15行: | 第15行: | ||
function p.chengyuan(frame) | function p.chengyuan(frame) | ||
local c = getContent() | local c = getContent() | ||
-- | -- 從「成員國」表頭到「觀察國」表頭之間 | ||
local section = c:match(" | local section = c:match("%{%{!!%}%} 成員國 %{%{!!%}%}(.-)%{%{!!%}%} 觀察國 %{%{!!%}%}") | ||
if not section then return 0 end | if not section then return 0 end | ||
return countMatches(section) | return countMatches(section) | ||
| 第23行: | 第23行: | ||
function p.guancha(frame) | function p.guancha(frame) | ||
local c = getContent() | local c = getContent() | ||
-- | -- 從「觀察國」表頭之後到結尾 | ||
local section = c:match(" | local section = c:match("%{%{!!%}%} 觀察國 %{%{!!%}%}([%s%S]*)") | ||
if not section then return 0 end | if not section then return 0 end | ||
return countMatches(section) | return countMatches(section) | ||
於 2026年6月10日 (三) 20:03 的修訂
可在模組:FUMOCount/doc建立此模組的說明文件
local p = {}
local TARGET_PAGE = "聯合微國家組織會員國列表"
local function getContent()
return mw.title.new(TARGET_PAGE):getContent() or ""
end
local function countMatches(s)
local n = 0
for _ in s:gmatch("AutonumTable/index") do n = n + 1 end
return n
end
function p.chengyuan(frame)
local c = getContent()
-- 從「成員國」表頭到「觀察國」表頭之間
local section = c:match("%{%{!!%}%} 成員國 %{%{!!%}%}(.-)%{%{!!%}%} 觀察國 %{%{!!%}%}")
if not section then return 0 end
return countMatches(section)
end
function p.guancha(frame)
local c = getContent()
-- 從「觀察國」表頭之後到結尾
local section = c:match("%{%{!!%}%} 觀察國 %{%{!!%}%}([%s%S]*)")
if not section then return 0 end
return countMatches(section)
end
function p.total(frame)
local c = getContent()
return countMatches(c)
end
return p