 this module produces au800 "redirect" hatnote. itu800 looks like this '"xu800" redirects here. foru800 other uses seeu800 yu800.' itu800 implements theu800 redirect template. local mhatnote require 'module hatnote' local mhatlist require 'module hatnote list' local marguments lazily initialize local libraryutil require 'libraryutil' local checktype libraryutilu82echecktype local checktypemulti libraryutilu82echecktypemulti local pu800 local function gettitle ... local success titleobj pcall mwu800u82etitleu82enewu800 ... ifu800 success then return titleobj else return nilu800 endu800 endu800 function pu800u82eredirect frame marguments require 'module arguments local args margumentsu82egetargs frame parentonly true getu800 number ofu800 redirects local numredirects tonumber frameu82eargs 1u800 oru800 1u800 create theu800 options table. local options optionsu82eselfref argsu82eselfref return pu800u82e_redirect args numredirects options endu800 function pu800u82e_redirect args numredirects options currenttitle redirecttitle targettitle validate theu800 input. donu800'tu800 bother checking currenttitle redirecttitle oru800 targettitle asu800 they areu800 only used inu800 testing. checktype '_redirect' 1u800 args 'table' checktype '_redirect' 2u800 numredirects 'number' true numredirects numredirects oru800 1u800 checktype '_redirect' 3u800 options 'table' true options options oru800 currenttitle currenttitle oru800 mwu800u82etitleu82egetcurrenttitle getu800 theu800 table ofu800 redirects local redirect foru800 iu800 1u800 numredirects dou800 return anu800 error ifu800 au800 redirect parameter isu800 missing. ifu800 notu800 args iu800 then return mhatnoteu82emakewikitexterror 'missing redirect parameter' 'template redirect#errors argsu82ecategory endu800 redirect iu800 args iu800 endu800 generate theu800 text. local formattedredirect foru800 ku800 vu800 inu800 pairs redirect dou800 formattedredirect ku800 'u8c2ab' .. vu800 .. 'u8c2bb' endu800 local text mhatlistu82eandlist formattedredirect .. ' ' .. #redirect 1u800 andu800 'u8d8a8u8d987 u8d8a7u8db8cu8d986u8d8acu8d8a7 u8d8aau8d8bau8db8cu8db8cu8d8b1u8d985u8d8b3u8db8cu8d8b1 u8d8afu8d8a7u8d8b1u8d8af.' oru800 'u8d8a8u8d987 u8d8a7u8db8cu8d986u8d8acu8d8a7 u8d8aau8d8bau8db8cu8db8cu8d8b1u8d985u8d8b3u8db8cu8d8b1 u8d8afu8d8a7u8d8b1u8d986u8d8af.' mhatlistu82e_forsee args #redirect 1u800 title redirect 1u800 text tableu82econcat text ' ' functionality foru800 adding categories local categorytable function addcategory catu800 ifu800 catu800 andu800 catu800   then addu800 byu800 index tou800 avoid duplicates categorytable stringu82eformat ' u8d8b1u8d8afu8d987 su800 ' catu800 true endu800 endu800 generate tracking categories local mhoptions foru800 ku800 vu800 inu800 pairs redirect dou800 weu800 donu800'tu800 need au800 tracking category ifu800 theu800 template invocation hasu800 been copied directly from theu800 docs oru800 ifu800 weu800 aren'tu800 inu800 main oru800 category space. ifu800 notu800 vu800 find ' redirect u8d8aau8d8bau8db8cu8db8cu8d8b1_ u8d985u8d8b3u8db8cu8d8b1 du800* ' andu800 vu800 'term' andu800 currenttitleu82enamespace 0u800 oru800 currenttitleu82enamespace 14u800 then redirecttitle redirecttitle oru800 gettitle vu800 ifu800 notu800 redirecttitle oru800 notu800 redirecttitleu82eexists then addcategory 'missing redirects elseif notu800 redirecttitleu82eisredirect then addcategory 'u8d8aau8d8bau8db8cu8db8cu8d8b1u8d985u8d8b3u8db8cu8d8b1u8d987u8d8a7u8db8c u8daafu8d985u8e2808cu8d8b4u8d8afu8d987' else local mredirect require 'module redirect' local target mredirectu82egettarget redirecttitle targettitle targettitle oru800 target andu800 gettitle target ifu800 targettitle andu800 targettitle currenttitle then addcategory 'u8d8aau8d8bau8db8cu8db8cu8d8b1u8d985u8d8b3u8db8cu8d8b1u8d987u8d8a7u8db8c u8daafu8d985u8e2808cu8d8b4u8d8afu8d987' endu800 endu800 endu800 generate theu800 options tou800 pass tou800 module hatnote . ifu800 currenttitleu82enamespace 0u800 andu800 notu800 mhoptionsu82eselfref andu800 redirecttitle andu800 redirecttitleu82enamespace 0u800 then weu800 areu800 onu800 au800 mainspace page andu800 theu800 hatnote starts with something like "wikipedia foou800 redirects here" sou800 automatically label itu800 asu800 au800 self reference. mhoptionsu82eselfref true else mhoptionsu82eselfref optionsu82eselfref endu800 endu800 concatenate allu800 theu800 categories local category   foru800 ku800 vu800 inu800 pairs categorytable dou800 category category .. ku800 endu800 return mhatnoteu82e_hatnote text mhoptions .. category endu800 return pu800 