Module:Sandbox/Theknightwho/Category disambiguation explained

local concat = table.concatlocal getArgs = require("Module:Arguments").getArgslocal insert = table.insertlocal messageBox = require("Module:Message box").mainlocal namespace = mw.title.getCurrentTitle.namespace

local p =

function p.main(frame) -- We want to keep blanks in the list or ipairs will terminate early, but if allowredlink is blank it should be nil. local args = getArgs(frame,) local allowredlink = args.allowredlink ~= "" and args.allowredlink or nil local list, topic, needs_fixing = for i, arg in ipairs(args) do if i % 2

1 then topic = arg else insert(list, "*For " .. topic .. ", see ." ) -- Add "needs fixing" category if: -- (1) We're in the category namespace. -- (2) allowredlink isn't set. -- (3) The category is a redlink. (Use :getContent to avoid triggering the expensive parser function count.) if (not needs_fixing and namespace

14 and not (allowredlink or mw.title.new(arg, 14):getContent) ) then needs_fixing = true end end end if #list < 2 then error("Please supply at least two categories, using the first four parameters.") end return messageBox("cmbox",) .. (needs_fixing and "" or "")end

return p