模組:FUMOCount
外觀
可在模組:FUMOCount/doc建立此模組的說明文件
local p = {}
local TARGET_PAGE = "聯合微國家組織會員國列表"
local function getContent()
return mw.title.new(TARGET_PAGE):getContent() or ""
end
local function countIndex(content, startPattern, endPattern)
local s = endPattern
and content:match(startPattern .. "(.-)" .. endPattern)
or content:match(startPattern .. "(.*)")
if not s then return 0 end
local n = 0
for _ in s:gmatch("AutonumTable/index") do n = n + 1 end
return n
end
-- 成員國數(fumochengyuanguo 區段)
function p.chengyuan(frame)
local c = getContent()
return countIndex(c, "id=fumochengyuanguo", "id=fumoguanchaguo")
end
-- 觀察國數(fumoguanchaguo 區段)
function p.guancha(frame)
local c = getContent()
return countIndex(c, "id=fumoguanchaguo", nil)
end
-- 會員國總數
function p.total(frame)
local c = getContent()
local n = 0
for _ in c:gmatch("AutonumTable/index") do n = n + 1 end
return n
end
return p