 this module implements category seeu800 also local mhatnote require 'module hatnote' local pu800 local function makewikitexterror msgu800 return stringu82eformat ' u8d8aeu8d8b7u8d8a7 su800 u8d8a7u8d984u8daafu8d988 u8d8b1u8d8afu8d987 u8d988u8d8a7u8d8a8u8d8b3u8d8aau8d987 ' msgu800 endu800 gets theu800 length ofu800 theu800 sequence sequ800. usually this should beu800 done with theu800 # operator butu800 weu800 need tou800 work with tables that getu800 their values through anu800 __index metamethod. local function getsequencelength sequ800 local length 0u800 foru800 iu800 inu800 ipairs sequ800 dou800 length iu800 endu800 return length endu800 given au800 table ofu800 options returns au800 function that formats categories foru800 those options. options project au800 project code such asu800 "fru800" foru800 theu800 french wikipedia showprefix au800 boolean value foru800 whether tou800 show theu800 "category " prefix andu800 theu800 project prefix ifu800 specified this isu800 implemented asu800 au800 function generator rather than au800 simple function sou800 that weu800 canu800 just process theu800 options once instead ofu800 every time weu800 generate au800 category. local function newcategorylinker options local formatstring ifu800 optionsu82eproject then ifu800 optionsu82eshowprefix then formatstring ' ' .. optionsu82eproject .. ' u8d8b1u8d8afu8d987 su800 ' else formatstring ' ' .. optionsu82eproject .. ' u8d8b1u8d8afu8d987 su800 su800 ' endu800 else ifu800 optionsu82eshowprefix then formatstring ' u8d8b1u8d8afu8d987 su800 ' else formatstring ' u8d8b1u8d8afu8d987 su800 su800 ' endu800 endu800 return function category local title mwu800u82etitleu82enewu800 category local pagename display ifu800 notu800 title then category isu800 notu800 au800 valid title usually because ofu800 invalid characters like oru800 . raise anu800 error andu800 suppress theu800 stack level information sou800 that weu800 canu800 catch itu800 andu800 format theu800 error message asu800 wikitext. error stringu82eformat "u8d986u8d8a7u8d985 u8d8b1u8d8afu8d987 u8c2ab su8c2bb u8d986u8d8a7u8d985u8d8b9u8d8aau8d8a8u8d8b1 u8d8a7u8d8b3u8d8aa" category 0u800 elseif titleu82enamespace 14u800 then category namespace pagename titleu82etext display titleu82etext else pagename titleu82eprefixedtext display category endu800 weu800 canu800 getu800 away with using twou800 arguments even when optionsu82eshowdisplay isu800 false asu800 stringu82eformat ignores extra arguments asu800 long asu800 there isu800 anu800 argument foru800 each flag inu800 theu800 format string. return formatstring format pagename display endu800 endu800 function pu800u82e_main args local nlinks getsequencelength args ifu800 nlinks 1u800 then return makewikitexterror 'u8d8afu8d8b3u8d8aa u8daa9u8d985 u8db8cu8daa9 u8d9beu8d8a7u8d8b1u8d8a7u8d985u8d8aau8d8b1 u8d985u8d988u8d8b1u8d8af u8d986u8db8cu8d8a7u8d8b2 u8d8a7u8d8b3u8d8aa' endu800 local makecategorylink newcategorylinker project argsu82eproject showprefix nlinks 1u800 local links foru800 iu800 catu800 inu800 ipairs args dou800 local success categorylink pcall makecategorylink catu800 ifu800 success then links iu800 categorylink else ifu800 there wasu800 anu800 error then categorylink isu800 theu800 error message. return makewikitexterror categorylink endu800 endu800 local formatstring ifu800 nlinks 1u800 then formatstring ' su800 su800' else formatstring ' su800 u8d8b1u8d8afu8d987u8e2808cu8d987u8d8a7u8db8c su800' endu800 donu800'tu800 output au800 comma before theu800 "andu800" ifu800 weu800 have only twou800 links. local conjunction ifu800 nlinks 2u800 then conjunction ' u8d988 ' else conjunction ' u8d988 ' endu800 local hatnotetext formatstring format argsu82elabel oru800 'u8d987u8d985u8da86u8d986u8db8cu8d986 u8d986u8daafu8d8a7u8d987 u8daa9u8d986u8db8cu8d8af u8d8a8u8d987' mwu800u82etextu82elisttotext links 'u8d88c ' conjunction return mhatnoteu82e_hatnote hatnotetext selfref true endu800 function pu800u82emain frame local args require 'module arguments .getargs frame wrappers 'u8d8a7u8d984u8daafu8d988 u8d8b1u8d8afu8d987 u8d988u8d8a7u8d8a8u8d8b3u8d8aau8d987' return pu800u82e_main args endu800 return pu800 