Module:Sandbox/CX Zoom/TestPage3 explained

local function remove_wiki_link (str) return (str:gsub("%[%[([^%[%]]*)%]%]", function(l) return l:gsub("^[^|]*|(.*)$", "%1"):gsub("^%s*(.-)%s*$", "%1"); end));end

local function main (frame) local user = frame.args[1] local page = local i = 1 local content repeat content = mw.title.new (page[i]):getContent; if string.find(content, "|"..user.."]]\n") or string.find(content, "| "..user.."\n") then pgnum = i else if i

10 then pgnum = 0 else pgnum = nil end end i = i + 1 until ((pgnum

i - 1) or (pgnum

0)) if pgnum

0 then outputRank = "nil" outputName = user outputCount = "nil" else for rank, name, count in string.gmatch(content, "|%-\n|%s(.-)\n|%s(.-)\n|%s(.-)\n") do rank = mw.text.trim(rank) name = mw.text.trim(name) count = mw.text.trim(count) name = remove_wiki_link (name) if name

user then outputRank = rank outputName = name outputCount = count break end end end if frame.args[2]

"rank" then return outputRank elseif frame.args[2]

"count" then return outputCount else return outputRank .. " " .. outputName .. " " .. outputCount end end

return