Module:Redirect-distinguish-for
Jump to navigation
Jump to search
Implements {{Redirect-distinguish-for}}.
mArguments = require('Module:Arguments') mRedirectHatnote = require("Module:Redirect hatnote") local p = {} function p.redirectDistinguishFor(frame) local args = mArguments.getArgs(frame, {parentOnly = true}) local maxArg = 0 for k, v in pairs(args) do if type(k) == 'number' and k > maxArg then maxArg = k end end local parsedArgs = {} for i = 1, maxArg do if i ~= 2 then parsedArgs[i == 1 and 1 or i - 1] = args[i] end end return (string.gsub( --Note that the outer parentheses are necessary! mRedirectHatnote._redirect(parsedArgs, 1, {selfref = args.selfref}), "(redirects? here.)", "%1 Not to be confused with [[:" .. (args[2]:match('^:?(.*)')) .. "]].", 1 )) end return p