Module:RelatedCategories

local function exists(page) local success, title = pcall(mw.title.new, page) return success and title and title.exists or false end

local p = {}

function p._main(args) local cats = {} local num = 0 local result = ''

for k, v in pairs(args) do		local param = v:gsub("[%[%]]*", "") if param:find("Category:") then if exists(param) then local page = param:gsub("Category:", "") table.insert(cats, page) num = num + 1 end end end if num ~= 0 then local catlist = {} for x, r in pairs(cats) do			table.insert(catlist, string.format('%s', r, r)) end table.insert(catlist, 1, ' Related Categories: ') table.insert(catlist, ' ') result = table.concat(catlist) end return result end function p.main(frame) local args = {} for k, v in pairs(frame:getParent.args) do		v = v:match('^%s*(.-)%s*$') if v ~= '' then args[k] = v		end end return p._main(args) end

return p