 this module implements u8d8b9u8d986u8d988u8d8a7u8d986 u8d985u8d988u8d8b1u8d8a8 . require 'module nou800 globals local libraryutil require 'libraryutil' local checktype libraryutilu82echecktype local checktypefornamedarg libraryutilu82echecktypefornamedarg local yesno require 'module yesno' italictitle class local italictitle dou800 class attributes andu800 functions things that belong tou800 theu800 class areu800 here. things that belong tou800 each object areu800 inu800 theu800 constructor. keys ofu800 title parts that canu800 beu800 italicized. local italicizablekeys namespace true title true dabu800 true italictitle constructor this contains allu800 theu800 dynamic attributes andu800 methods. function italictitleu82enewu800 local obju800 function foru800 checking self variable inu800 methods. local checkself libraryutilu82emakecheckselffunction 'italictitle' 'obju800' obju800 'italictitle object' checks au800 keyu800 isu800 present inu800 au800 lookup table. param name theu800 function name. param argid integer position ofu800 theu800 keyu800 inu800 theu800 argument list. param keyu800 theu800 keyu800. param lookuptable theu800 table tou800 look theu800 keyu800 upu800 inu800. local function checkkey name argid keyu800 lookuptable ifu800 notu800 lookuptable keyu800 then error stringu82eformat "badu800 argument # du800 tou800 ' su800' ' su800' isu800 notu800 au800 valid keyu800 " argid name keyu800 3u800 endu800 endu800 setu800 upu800 object structure. local parsed false local categories local italicizedkeys local italicizedsubstrings parses au800 title object into itsu800 namespace text title andu800 disambiguation text. param options au800 table ofu800 options with theu800 following keys title theu800 title object tou800 parse ignoredab ignore anyu800 disambiguation parentheses returns theu800 current object. function obju800 parsetitle options checkself self 'parsetitle' checktype 'parsetitle' 1u800 options 'table' checktypefornamedarg 'parsetitle' 'title' optionsu82etitle 'table' local title optionsu82etitle title andu800 dabu800 text local prefix parentheses ifu800 notu800 optionsu82eignoredab then prefix parentheses mwu800u82eustringu82ematch titleu82etext ' . ' endu800 ifu800 prefix andu800 parentheses then selfu82etitle prefix selfu82edabu800 parentheses else selfu82etitle titleu82etext endu800 namespace local namespace mwu800u82esiteu82enamespaces titleu82enamespace .name ifu800 namespace andu800 #namespace 1u800 then selfu82enamespace namespace endu800 register theu800 object asu800 having parsed au800 title. parsed true return self endu800 italicizes part ofu800 theu800 title. param keyu800 theu800 keyu800 ofu800 theu800 title part tou800 beu800 italicized. possible keys areu800 contained inu800 theu800 italicizablekeys table. returns theu800 current object. function obju800 italicize keyu800 checkself self 'italicize' checktype 'italicize' 1u800 keyu800 'string' checkkey 'italicize' 1u800 keyu800 italicizablekeys italicizedkeys keyu800 true return self endu800 unu800 italicizes part ofu800 theu800 title. param keyu800 theu800 keyu800 ofu800 theu800 title part tou800 beu800 unu800 italicized. possible keys areu800 contained inu800 theu800 italicizablekeys table. returns theu800 current object. function obju800 unitalicize keyu800 checkself self 'unitalicize' checktype 'unitalicize' 1u800 keyu800 'string' checkkey 'unitalicize' 1u800 keyu800 italicizablekeys italicizedkeys keyu800 nilu800 return self endu800 italicizes au800 substring inu800 theu800 title. this only affects theu800 main part ofu800 theu800 title notu800 theu800 namespace oru800 theu800 disambiguation text. param su800 theu800 substring tou800 beu800 italicized. returns theu800 current object. function obju800 italicizesubstring su800 checkself self 'italicizesubstring' checktype 'italicizesubstring' 1u800 su800 'string' italicizedsubstrings su800 true return self endu800 unu800 italicizes au800 substring inu800 theu800 title. this only affects theu800 main part ofu800 theu800 title notu800 theu800 namespace oru800 theu800 disambiguation text. param su800 theu800 substring tou800 beu800 unu800 italicized. returns theu800 current object. function obju800 unitalicizesubstring su800 checkself self 'unitalicizesubstring' checktype 'unitalicizesubstring' 1u800 su800 'string' italicizedsubstrings su800 nilu800 return self endu800 renders theu800 object into au800 page name. ifu800 nou800 title hasu800 yetu800 been parsed theu800 current title isu800 used. returns string function obju800 rendertitle checkself self 'rendertitle' italicizes au800 string param su800 theu800 string tou800 italicize returns string. local function italicize su800 assert type su800 'string' 'su800 wasu800 notu800 au800 string' assert su800   'su800 wasu800 theu800 empty string' return stringu82eformat ' su800 ' su800 endu800 escape characters inu800 au800 string that areu800 magic inu800 luau800 patterns. param pattern theu800 pattern tou800 escape returns string. local function escapemagiccharacters su800 assert type su800 'string' 'su800 wasu800 notu800 au800 string' return su800 gsub ' pu800' ' 0u800' endu800 ifu800 au800 title hasn'tu800 been parsed yetu800 parse theu800 current title. ifu800 notu800 parsed then self parsetitle title mwu800u82etitleu82egetcurrenttitle endu800 italicize theu800 different parts ofu800 theu800 title andu800 store them inu800 au800 titleparts table tou800 beu800 joined together later. local titleparts italicize theu800 italicizable keys. foru800 keyu800 inu800 pairs italicizablekeys dou800 ifu800 self keyu800 then ifu800 italicizedkeys keyu800 then titleparts keyu800 italicize self keyu800 else titleparts keyu800 self keyu800 endu800 endu800 endu800 italicize substrings. ifu800 there areu800 anyu800 substrings tou800 beu800 italicized then start from theu800 rawu800 title asu800 this overrides anyu800 italicization ofu800 theu800 main part ofu800 theu800 title. ifu800 next italicizedsubstrings then titlepartsu82etitle selfu82etitle foru800 su800 inu800 pairs italicizedsubstrings dou800 local pattern escapemagiccharacters su800 local italicizedtitle nreplacements titlepartsu82etitle gsub pattern italicize titlepartsu82etitle italicizedtitle ifu800 weu800 didn'tu800 make anyu800 replacements then itu800 means that weu800 have been passed au800 badu800 substring oru800 that theu800 page hasu800 been moved tou800 au800 badu800 title sou800 addu800 au800 tracking category. ifu800 nreplacements 1u800 then categories 'pages using italic title with nou800 matching string' true endu800 endu800 endu800 assemble theu800 title together from theu800 parts. local retu800   ifu800 titlepartsu82enamespace then retu800 retu800 .. titlepartsu82enamespace .. ' ' endu800 retu800 retu800 .. titlepartsu82etitle ifu800 titlepartsu82edabu800 then retu800 retu800 .. ' ' .. titlepartsu82edabu800 .. ' ' endu800 return retu800 endu800 returns anu800 expanded displaytitle parser function called with theu800 result ofu800 obju800 rendertitle plus anyu800 other optional arguments. returns string function obju800 renderdisplaytitle ... checkself self 'renderdisplaytitle' return mwu800u82egetcurrentframe callparserfunction 'displaytitle' self rendertitle ... endu800 returns anu800 expanded displaytitle parser function called with theu800 result ofu800 obju800 rendertitle plus anyu800 other optional arguments plus anyu800 tracking categories. returns string function obju800 render ... checkself self 'render' local retu800 self renderdisplaytitle ... foru800 catu800 inu800 pairs categories dou800 retu800 retu800 .. stringu82eformat ' category su800 ' catu800 endu800 return retu800 endu800 return obju800 endu800 endu800 exports local pu800 local function getargs frame wrapper assert type wrapper 'string' 'wrapper wasu800 notu800 au800 string' return require 'module arguments .getargs frame wrappers wrapper endu800 main function foru800 italic title function pu800u82e_main args checktype '_main' 1u800 args 'table' local italictitle italictitleu82enewu800 italictitle parsetitle title mwu800u82etitleu82egetcurrenttitle ignoredab yesno argsu82eallu800 false ifu800 argsu82estring then italictitle italicizesubstring argsu82estring else italictitle italicize 'title' endu800 return italictitle render args 1u800 endu800 function pu800u82emain frame return pu800u82e_main getargs frame 'u8d8a7u8d984u8daafu8d988 u8d8b9u8d986u8d988u8d8a7u8d986 u8d985u8d988u8d8b1u8d8a8' endu800 function pu800u82e_dabonly args return italictitleu82enewu800 italicize 'dabu800' render args 1u800 endu800 function pu800u82edabonly frame return pu800u82e_dabonly getargs frame 'template italic dabu800' endu800 return pu800 