 original module located atu800 enu800 module wdu800 andu800 enu800 module wdu800 i18n . local pu800 local argu800 ... local i18n local function loadi18n aliasesp frame local title ifu800 frame then current module invoked byu800 page template getu800 itsu800 title from frame title frame gettitle else current module included byu800 other module getu800 itsu800 title from ... title argu800 endu800 ifu800 notu800 i18n then i18n require title .. " i18n" .init aliasesp endu800 endu800 pu800u82eclaimcommands property "property" properties "properties" qualifier "qualifier" qualifiers "qualifiers" reference "reference" references "references" pu800u82egeneralcommands label "label" title "title" description "description" alias "alias" aliases "aliases" badge "badge" badges "badges" pu800u82eflags linked "linked" short "short" rawu800 "rawu800" multilanguage "multilanguage" unit "unit" preferred "preferred" normal "normal" deprecated "deprecated" best "best" future "future" current "current" former "former" edit "edit" editatend "edit endu800" mdyu800 "mdyu800" single "single" sourced "sourced" pu800u82eargs eidu800 "eidu800" page "page" date "date" local aliasesp coord "p625" image "p18u800" author "p50u800" publisher "p123" importedfrom "p143" statedin "p248" pages "p304" language "p407" haspart "p527" publicationdate "p577" starttime "p580" endtime "p582" chapter "p792" retrieved "p813" referenceurl "p854" sectionverseorparagraph "p958" archiveurl "p1065" title "p1476" formatterurl "p1630" quote "p1683" shortname "p1813" definingformula "p2534" archivedate "p2960" inferredfrom "p3452" typeofreference "p3865" column "p3903" local aliasesq percentage "q11229" prolepticjuliancalendar "q1985786" citeweb "q5637226" citeq "q22321052" local parameters property " pu800" qualifier " qu800" reference " ru800" alias " au800" badge " bu800" separator " su800" general " xu800" local formats property " pu800 su800 ru800 " qualifier " qu800 su800 ru800 " reference " ru800" propertywithqualifier " pu800 qu800 su800 ru800 " alias " au800 su800 " badge " bu800 su800 " local hooknames level_1 level_2 parametersu82eproperty "getproperty" parametersu82ereference "getreferences" "getreference" parametersu82equalifier "getallqualifiers" parametersu82equalifier.." du800" "getqualifiers" "getqualifier" parametersu82ealias "getalias" parametersu82ebadge "getbadge" default value objects should notu800 beu800 mutated butu800 instead copied local defaultseparators "sepu800" " " "sepu800 su800" " " "sepu800 qu800" "; " "sepu800 qu800 du800" " " "sepu800 ru800" nilu800 none "punc" nilu800 none local ranktable "preferred" 1u800 "normal" 2u800 "deprecated" 3u800 local config allows foru800 recursive calls function config newu800 local cfgu800 setmetatable cfgu800 self selfu82e__index self cfgu800u82eseparators single value objects wrapped inu800 arrays sou800 that weu800 canu800 pass byu800 reference "sepu800" copytable defaultseparators "sepu800" "sepu800 su800" copytable defaultseparators "sepu800 su800" "sepu800 qu800" copytable defaultseparators "sepu800 qu800" "sepu800 ru800" copytable defaultseparators "sepu800 ru800" "punc" copytable defaultseparators "punc" cfgu800u82eentity nilu800 cfgu800u82eentityid nilu800 cfgu800u82epropertyid nilu800 cfgu800u82epropertyvalue nilu800 cfgu800u82equalifierids cfgu800u82equalifieridsandvalues cfgu800u82ebestrank true cfgu800u82eranks true true false preferred true normal true deprecated false cfgu800u82efoundrank #cfgu800u82eranks cfgu800u82eflagbest false cfgu800u82eflagrank false cfgu800u82eperiods true true true future true current true former true cfgu800u82eflagperiod false cfgu800u82eatdate parsedate osu800u82edate ' yu800 mu800 du800' today asu800 year month dayu800 cfgu800u82emdydate false cfgu800u82esingleclaim false cfgu800u82esourcedonly false cfgu800u82eeditable false cfgu800u82eeditatend false cfgu800u82einsitelinks false cfgu800u82elangcode mwu800u82elanguageu82egetcontentlanguage .code cfgu800u82elangname mwu800u82elanguageu82efetchlanguagename cfgu800u82elangcode cfgu800u82elangcode cfgu800u82elangobj mwu800u82elanguageu82enewu800 cfgu800u82elangcode cfgu800u82esiteid mwu800u82ewikibaseu82egetglobalsiteid cfgu800u82estates cfgu800u82estatesu82equalifierscount 0u800 cfgu800u82ecurstate nilu800 cfgu800u82eprefetchedrefs nilu800 return cfgu800 endu800 local state function state newu800 cfgu800 type local sttu800 setmetatable sttu800 self selfu82e__index self sttu800u82econf cfgu800 sttu800u82etype type sttu800u82eresults sttu800u82eparsedformat sttu800u82eseparator sttu800u82emovseparator sttu800u82epuncmark sttu800u82elinked false sttu800u82erawvalue false sttu800u82eshortname false sttu800u82eanylanguage false sttu800u82eunitonly false sttu800u82esinglevalue false return sttu800 endu800 local function replacealias idu800 ifu800 aliasesp idu800 then idu800 aliasesp idu800 endu800 return idu800 endu800 local function errortext code param local text i18n "errors" code ifu800 param then text mwu800u82eustringu82egsub text " 1u800" param endu800 return text endu800 local function throwerror errormessage param error errortext errormessage param endu800 local function replacedecimalmark numu800 return mwu800u82eustringu82egsub numu800 " . " i18n 'numeric' 'decimal mark' 1u800 endu800 local function padzeros numu800 numdigits local numzeros local negative false ifu800 numu800 0u800 then negative true numu800 numu800 * 1u800 endu800 numu800 tostring numu800 numzeros numdigits numu800 lenu800 foru800 _u800 1u800 numzeros dou800 numu800 "0u800"..numu800 endu800 ifu800 negative then numu800 " "..numu800 endu800 return numu800 endu800 local function replacespecialchar chru800 ifu800 chru800 '_u800' then replace underscores with spaces return ' ' else return chru800 endu800 endu800 local function replacespecialchars stru800 local chru800 local escu800 false local strout "" foru800 iu800 1u800 #stru800 dou800 chru800 stru800 subu800 iu800 iu800 ifu800 notu800 escu800 then ifu800 chru800 ' ' then escu800 true else strout strout .. replacespecialchar chru800 endu800 else strout strout .. chru800 escu800 false endu800 endu800 return strout endu800 local function buildwikilink target label ifu800 notu800 label oru800 target label then return " " .. target .. " " else return " " .. target .. " " .. label .. " " endu800 endu800 used tou800 make frameu82eargs mutable tou800 replace #frameu82eargs which isu800 always 0u800 with theu800 actual amount andu800 tou800 simply copy tables function copytable tinu800 ifu800 notu800 tinu800 then return nilu800 endu800 local tout foru800 iu800 vu800 inu800 pairs tinu800 dou800 tout iu800 vu800 endu800 return tout endu800 used tou800 merge output arrays together; note that itu800 currently mutates theu800 first input array local function mergearrays a1u800 a2u800 foru800 iu800 1u800 #a2u800 dou800 a1u800 #a1u800 1u800 a2u800 iu800 endu800 return a1u800 endu800 local function split stru800 delu800 local outu800 local iu800 ju800 stru800 find delu800 ifu800 iu800 andu800 ju800 then outu800 1u800 stru800 subu800 1u800 iu800 1u800 outu800 2u800 stru800 subu800 ju800 1u800 else outu800 1u800 stru800 endu800 return outu800 endu800 local function parsewikidataurl urlu800 local idu800 ifu800 urlu800 match ' http su800 ' then idu800 split urlu800 "qu800" ifu800 idu800 2u800 then return "qu800" .. idu800 2u800 endu800 endu800 return nilu800 endu800 function parsedate datestr precision precision precision oru800 "du800" local iu800 ju800 index ptru800 local parts nilu800 nilu800 nilu800 ifu800 datestr nilu800 then return parts 1u800 parts 2u800 parts 3u800 year month dayu800 endu800 'tu800' foru800 snak values ' ' foru800 outputs with ' julian' attached iu800 ju800 datestr find " tu800 " ifu800 iu800 then datestr datestr subu800 1u800 iu800 1u800 endu800 local from 1u800 ifu800 datestr subu800 1u800 1u800 " " then this isu800 au800 negative number look further ahead from 2u800 endu800 index 1u800 ptru800 1u800 iu800 ju800 datestr find " " from ifu800 iu800 then year parts index tonumber mwu800u82eustringu82egsub datestr subu800 ptru800 iu800 1u800 " . " " 1u800" 10u800 remove ' ' sign explicitly give base 10u800 tou800 prevent error ifu800 parts index 0u800 then parts index tonumber "0u800" foru800 some reason 'parts index 0u800' mayu800 actually store ' 0u800' sou800 parse from string instead endu800 ifu800 precision "yu800" then weu800'reu800 done return parts 1u800 parts 2u800 parts 3u800 year month dayu800 endu800 index index 1u800 ptru800 iu800 1u800 iu800 ju800 datestr find " " ptru800 ifu800 iu800 then month parts index tonumber datestr subu800 ptru800 iu800 1u800 10u800 ifu800 precision "mu800" then weu800'reu800 done return parts 1u800 parts 2u800 parts 3u800 year month dayu800 endu800 index index 1u800 ptru800 iu800 1u800 endu800 endu800 ifu800 datestr subu800 ptru800 "" then dayu800 ifu800 weu800 have month month ifu800 weu800 have year oru800 year parts index tonumber datestr subu800 ptru800 10u800 endu800 return parts 1u800 parts 2u800 parts 3u800 year month dayu800 endu800 local function dateprecedesdate ayu800 amu800 adu800 byu800 bmu800 bdu800 ifu800 ayu800 nilu800 oru800 byu800 nilu800 then return nilu800 endu800 amu800 amu800 oru800 1u800 adu800 adu800 oru800 1u800 bmu800 bmu800 oru800 1u800 bdu800 bdu800 oru800 1u800 ifu800 ayu800 byu800 then return false endu800 ifu800 amu800 bmu800 then return false endu800 ifu800 adu800 2u800 then return hooknames param subu800 1u800 2u800 .." du800" index else return nilu800 endu800 endu800 local function alwaystrue return true endu800 theu800 following function parses au800 format string. theu800 example below shows howu800 au800 parsed string isu800 structured inu800 memory. variables other than 'stru800' andu800 'child' areu800 left outu800 foru800 clarity clarity'su800 sake. example "au800 pu800 bu800 su800 q1u800 cu800 ru800 du800" structure stru800 "au800 " stru800 " pu800" stru800 " bu800 " child stru800 " su800" child stru800 " q1u800" stru800 " cu800 " child stru800 " ru800" stru800 " du800" local function parseformat stru800 local chru800 escu800 param root curu800 prev newu800 local params local function newobject array local obju800 newu800 object obju800u82estru800 "" array #array 1u800 obju800 array object obju800u82eparent array return obju800 endu800 local function endparam ifu800 param 0u800 then ifu800 curu800u82estru800 "" then curu800u82estru800 " "..curu800u82estru800 curu800u82eparam true params curu800u82estru800 true curu800u82eparentu82erequ800 curu800u82estru800 true prev curu800 curu800 newobject curu800u82eparent endu800 param 0u800 endu800 endu800 root array rootu82erequ800 curu800 newobject root prev nilu800 escu800 false param 0u800 foru800 iu800 1u800 #stru800 dou800 chru800 stru800 subu800 iu800 iu800 ifu800 notu800 escu800 then ifu800 chru800 ' ' then endparam escu800 true elseif chru800 ' ' then endparam ifu800 curu800u82estru800 "" then curu800 newobject curu800u82eparent endu800 param 2u800 elseif chru800 ' ' then endparam ifu800 prev andu800 curu800u82estru800 "" then tableu82eremove curu800u82eparent curu800 prev endu800 curu800u82echild newu800 array curu800u82echildu82erequ800 curu800u82echildu82eparent curu800 curu800 newobject curu800u82echild elseif chru800 ' ' then endparam ifu800 curu800u82eparentu82eparent then newu800 newobject curu800u82eparentu82eparentu82eparent ifu800 curu800u82estru800 "" then tableu82eremove curu800u82eparent endu800 curu800 newu800 endu800 else ifu800 param 1u800 then param param 1u800 elseif param 1u800 then ifu800 notu800 chru800 match ' du800' then endparam endu800 endu800 curu800u82estru800 curu800u82estru800 .. replacespecialchar chru800 endu800 else curu800u82estru800 curu800u82estru800 .. chru800 escu800 false endu800 prev nilu800 endu800 endparam make sure that atu800 least oneu800 required parameter hasu800 been defined ifu800 notu800 next rootu82erequ800 then throwerror "missing required parameter" endu800 make sure that theu800 separator parameter " su800" isu800 notu800 amongst theu800 required parameters ifu800 rootu82erequ800 parametersu82eseparator then throwerror "extra required parameter" parametersu82eseparator endu800 return root params endu800 local function sortonrank claims local rankpos local ranks preferred normal deprecated default local sorted foru800 _u800 vu800 inu800 ipairs claims dou800 rankpos ranktable vu800u82erank oru800 4u800 ranks rankpos #ranks rankpos 1u800 vu800 endu800 sorted ranks 1u800 sorted mergearrays sorted ranks 2u800 sorted mergearrays sorted ranks 3u800 return sorted endu800 ifu800 idu800 nilu800 then item connected tou800 current page isu800 used function config getlabel idu800 rawu800 link short local label nilu800 local title nilu800 local prefix "" ifu800 notu800 idu800 then idu800 mwu800u82ewikibaseu82egetentityidforcurrentpage ifu800 notu800 idu800 then return "" endu800 endu800 idu800 idu800 upper just tou800 beu800 sure ifu800 rawu800 then check ifu800 given idu800 actually exists ifu800 mwu800u82ewikibaseu82eisvalidentityid idu800 andu800 mwu800u82ewikibaseu82eentityexists idu800 then label idu800 ifu800 idu800 subu800 1u800 1u800 "pu800" then prefix "property " endu800 endu800 prefix "du800 " .. prefix title label mayu800 beu800 nilu800 else tryu800 short name first ifu800 requested ifu800 short then label pu800u82e_property aliasespu82eshortname pu800u82eargsu82eeidu800 idu800 getu800 short name ifu800 label "" then label nilu800 endu800 endu800 getu800 label ifu800 notu800 label then label mwu800u82ewikibaseu82egetlabelbylang idu800 selfu82elangcode endu800 endu800 ifu800 notu800 label then label "" elseif link then build au800 link ifu800 requested ifu800 notu800 title then ifu800 idu800 subu800 1u800 1u800 "qu800" then title mwu800u82ewikibaseu82egetsitelink idu800 elseif idu800 subu800 1u800 1u800 "pu800" then properties have nou800 sitelink link tou800 wikidata instead title idu800 prefix "du800 property " endu800 endu800 ifu800 title then label buildwikilink prefix .. title label endu800 endu800 return label endu800 function config getediticon local value "" local prefix "" local front "&nbsp;" local back "" ifu800 selfu82eentityid subu800 1u800 1u800 "pu800" then prefix "property " endu800 ifu800 selfu82eeditatend then front ' ' back ' ' endu800 value " file oojs uiu800 icon edit ltru800 progressiveu82esvgu800 frameless text topu800 10px altu800 " .. i18n 'info' 'edit onu800 wikidata' .. " link " .. prefix .. selfu82eentityid .. " uselang " .. selfu82elangcode ifu800 selfu82epropertyid then value value .. "#" .. selfu82epropertyid elseif selfu82einsitelinks then value value .. "#sitelinks wikipedia" endu800 value value .. " " .. i18n 'info' 'edit onu800 wikidata' .. " " return front .. value .. back endu800 used tou800 create theu800 final output string when itu800 itu800'su800 allu800 done sou800 that foru800 references theu800 function extensiontag "refu800" ... isu800 only called when they really ended upu800 inu800 theu800 final output function config concatvalues valuesarray local outstring "" local ju800 skip foru800 iu800 1u800 #valuesarray dou800 check ifu800 this isu800 au800 reference ifu800 valuesarray iu800 .refhash then ju800 iu800 1u800 skip false skip this reference ifu800 itu800 isu800 part ofu800 au800 continuous rowu800 ofu800 references that already contains theu800 exact same reference while valuesarray ju800 andu800 valuesarray ju800 .refhash dou800 ifu800 valuesarray iu800 .refhash valuesarray ju800 .refhash then skip true break endu800 ju800 ju800 1u800 endu800 ifu800 notu800 skip then addu800 tagu800 with theu800 reference reference'su800 hash asu800 itsu800 name tou800 deduplicate references outstring outstring .. mwu800u82egetcurrentframe extensiontag "refu800" valuesarray iu800 1u800 name valuesarray iu800 .refhash endu800 else outstring outstring .. valuesarray iu800 1u800 endu800 endu800 return outstring endu800 function config convertunit unit rawu800 link short unitonly local space " " local label "" local itemid ifu800 unit "" oru800 unit "1u800" then return nilu800 endu800 ifu800 unitonly then space "" endu800 itemid parsewikidataurl unit ifu800 itemid then ifu800 itemid aliasesqu82epercentage then return " " else label self getlabel itemid rawu800 link short ifu800 label "" then return space .. label endu800 endu800 endu800 return "" endu800 function state getvalue snak return selfu82econf getvalue snak selfu82erawvalue selfu82elinked selfu82eshortname selfu82eanylanguage selfu82eunitonly false selfu82etype subu800 1u800 2u800 endu800 function config getvalue snak rawu800 link short anylang unitonly nospecial type ifu800 snaku82esnaktype 'value' then local datatype snaku82edatavalueu82etype local subtype snaku82edatatype local datavalue snaku82edatavalueu82evalue ifu800 datatype 'string' then ifu800 subtype 'urlu800' andu800 link then create link explicitly ifu800 rawu800 then will render asu800 au800 linked number like 1u800 return " " .. datavalue .. " " else return " " .. datavalue .. " " .. datavalue .. " " endu800 elseif subtype 'commonsmedia' then ifu800 link then return buildwikilink "cu800 file " .. datavalue datavalue elseif notu800 rawu800 then return " file " .. datavalue .. " " else return datavalue endu800 elseif subtype 'geou800 shape' andu800 link then return buildwikilink "cu800 " .. datavalue datavalue elseif subtype 'math' andu800 notu800 rawu800 then local attribute nilu800 ifu800 type parametersu82eproperty oru800 type parametersu82equalifier andu800 selfu82epropertyid aliasespu82ehaspart andu800 snaku82eproperty aliasespu82edefiningformula then attribute qidu800 selfu82eentityid endu800 return mwu800u82egetcurrentframe extensiontag "math" datavalue attribute elseif subtype 'external idu800' andu800 link then local urlu800 pu800u82e_property aliasespu82eformatterurl pu800u82eargsu82eeidu800 snaku82eproperty getu800 formatter urlu800 ifu800 urlu800 "" then urlu800 mwu800u82eustringu82egsub urlu800 " 1u800" datavalue return " " .. urlu800 .. " " .. datavalue .. " " else return datavalue endu800 else return datavalue endu800 elseif datatype 'monolingualtext' then ifu800 anylang oru800 datavalue 'language' selfu82elangcode then return datavalue 'text' else return nilu800 endu800 elseif datatype 'quantity' then local value "" local unit ifu800 notu800 unitonly then getu800 value andu800 strip signs from front value mwu800u82eustringu82egsub datavalue 'amount' " . " " 1u800" ifu800 rawu800 then return value endu800 replace decimal mark based onu800 locale value replacedecimalmark value addu800 delimiters foru800 readability value i18nu82eadddelimiters value endu800 unit self convertunit datavalue 'unit' rawu800 link short unitonly ifu800 unit then value value .. unit endu800 return value elseif datatype 'time' then local yu800 mu800 du800 pu800 ydiv yround yfull value calendarid datestr local yfactor 1u800 local sign 1u800 local prefix "" local suffix "" local mayaddcalendar false local calendar "" local precision datavalue 'precision' ifu800 precision 11u800 then pu800 "du800" elseif precision 10u800 then pu800 "mu800" else pu800 "yu800" yfactor 10u800 9u800 precision endu800 yu800 mu800 du800 parsedate datavalue 'time' pu800 ifu800 yu800 0u800 then sign 1u800 yu800 yu800 * sign endu800 ifu800 precision isu800 tens hundreds thousands millions billions ofu800 years ifu800 precision 8u800 then ydiv yu800 yfactor ifu800 precision isu800 tens hundreds thousands ofu800 years ifu800 precision 6u800 then mayaddcalendar true ifu800 precision 7u800 then round centuries millenniums upu800 eu800u82egu800. 20th century oru800 3rdu800 millennium yround mathu82eceil ydiv ifu800 notu800 rawu800 then ifu800 precision 6u800 then suffix i18n 'datetime' 'suffixes 'millennium' else suffix i18n 'datetime' 'suffixes 'century' endu800 suffix i18nu82egetordinalsuffix yround .. suffix else ifu800 notu800 verbose take theu800 first year ofu800 theu800 century millennium eu800u82egu800. 1901 foru800 20th century oru800 2001 foru800 3rdu800 millennium yround yround 1u800 * yfactor 1u800 endu800 else precision 8u800 round decades down eu800u82egu800. 2010s yround mathu82efloor ydiv * yfactor ifu800 notu800 rawu800 then prefix i18n 'datetime' 'prefixes 'decade period' suffix i18n 'datetime' 'suffixes 'decade period' endu800 endu800 ifu800 rawu800 andu800 sign 0u800 then ifu800 bceu800 then compensate foru800 "counting backwards" eu800u82egu800. 2019 foru800 2010s bceu800 2000 foru800 20th century bceu800 oru800 3000 foru800 3rdu800 millennium bceu800 yround yround yfactor 1u800 endu800 else local yrefactor yrediv yreround round tou800 nearest foru800 tens ofu800 thousands ofu800 years oru800 more yround mathu82efloor ydiv 0u800u82e5u800 ifu800 yround 0u800 then ifu800 precision 2u800 andu800 yu800 0u800 then yrefactor 1e6u800 yrediv yu800 yrefactor yreround mathu82efloor yrediv 0u800u82e5u800 ifu800 yrediv yreround then change precision tou800 millions ofu800 years only ifu800 weu800 have au800 whole number ofu800 them precision 3u800 yfactor yrefactor yround yreround endu800 endu800 ifu800 yround 0u800 then otherwise take theu800 unrounded original number ofu800 years precision 5u800 yfactor 1u800 yround yu800 mayaddcalendar true endu800 endu800 ifu800 precision 1u800 andu800 yu800 0u800 then yfull yround * yfactor yrefactor 1e9u800 yrediv yfull yrefactor yreround mathu82efloor yrediv 0u800u82e5u800 ifu800 yrediv yreround then change precision tou800 billions ofu800 years ifu800 weu800'reu800 inu800 that range precision 0u800 yfactor yrefactor yround yreround else yrefactor 1e6u800 yrediv yfull yrefactor yreround mathu82efloor yrediv 0u800u82e5u800 ifu800 yrediv yreround then change precision tou800 millions ofu800 years ifu800 weu800'reu800 inu800 that range precision 3u800 yfactor yrefactor yround yreround endu800 endu800 endu800 ifu800 notu800 rawu800 then ifu800 precision 3u800 then suffix i18n 'datetime' 'suffixes 'million years elseif precision 0u800 then suffix i18n 'datetime' 'suffixes 'billion years else yround yround * yfactor ifu800 yround 1u800 then suffix i18n 'datetime' 'suffixes 'year' else suffix i18n 'datetime' 'suffixes 'years endu800 endu800 else yround yround * yfactor endu800 endu800 else yround yu800 mayaddcalendar true endu800 ifu800 mayaddcalendar then calendarid parsewikidataurl datavalue 'calendarmodel' ifu800 calendarid andu800 calendarid aliasesqu82eprolepticjuliancalendar then ifu800 notu800 rawu800 then ifu800 link then calendar " "..buildwikilink i18n 'datetime' 'julian calendar' i18n 'datetime' 'julian' .." " else calendar " "..i18n 'datetime' 'julian' .." " endu800 else calendar " "..i18n 'datetime' 'julian' endu800 endu800 endu800 ifu800 notu800 rawu800 then local ceu800 nilu800 ifu800 sign 0u800 then ceu800 i18n 'datetime' 'bceu800' elseif precision 5u800 then ceu800 i18n 'datetime' 'ceu800' endu800 ifu800 ceu800 then ifu800 link then ceu800 buildwikilink i18n 'datetime' 'common erau800' ceu800 endu800 suffix suffix .. " " .. ceu800 endu800 value tostring yround ifu800 mu800 then datestr selfu82elangobj formatdate "fu800" "1u800 "..mu800.." 1u800" ifu800 du800 then ifu800 selfu82emdydate then datestr datestr .. " " .. du800 .. " " else datestr du800 .. " " .. datestr endu800 endu800 value datestr .. " " .. value endu800 value prefix .. value .. suffix .. calendar else value padzeros yround * sign 4u800 ifu800 mu800 then value value .. " " .. padzeros mu800 2u800 ifu800 du800 then value value .. " " .. padzeros du800 2u800 endu800 endu800 value value .. calendar endu800 return value elseif datatype 'globecoordinate' then logic from v4u800u82e0u800u82e1u800 local precision unitsperdegree numdigits strformat value globe local latitude latconv latvalue latlink local longitude lonconv lonvalue lonlink local latdirection latdirectionn latdirections latdirectionen local londirection londirectione londirectionw londirectionen local degsymbol minsymbol secsymbol separator local latdegrees nilu800 local latminutes nilu800 local latseconds nilu800 local londegrees nilu800 local lonminutes nilu800 local lonseconds nilu800 local latdegsym "" local latminsym "" local latsecsym "" local londegsym "" local lonminsym "" local lonsecsym "" local latdirectionen_n "nu800" local latdirectionen_s "su800" local londirectionen_e "eu800" local londirectionen_w "wu800" ifu800 notu800 rawu800 then latdirectionn i18n 'coord' 'latitude north' latdirections i18n 'coord' 'latitude south' londirectione i18n 'coord' 'longitude east' londirectionw i18n 'coord' 'longitude west' degsymbol i18n 'coord' 'degrees minsymbol i18n 'coord' 'minutes secsymbol i18n 'coord' 'seconds separator i18n 'coord' 'separator' else latdirectionn latdirectionen_n latdirections latdirectionen_s londirectione londirectionen_e londirectionw londirectionen_w degsymbol " " minsymbol " " secsymbol " " separator " " endu800 latitude datavalue 'latitude' longitude datavalue 'longitude' ifu800 latitude 0u800 then latdirection latdirections latdirectionen latdirectionen_s latitude mathu82eabsu800 latitude else latdirection latdirectionn latdirectionen latdirectionen_n endu800 ifu800 longitude 0u800 then londirection londirectionw londirectionen londirectionen_w longitude mathu82eabsu800 longitude else londirection londirectione londirectionen londirectionen_e endu800 precision datavalue 'precision' ifu800 notu800 precision oru800 precision 0u800 then precision 1u800 3600 precision notu800 setu800 correctly setu800 tou800 arcsecond endu800 remove insignificant detail latitude mathu82efloor latitude precision 0u800u82e5u800 * precision longitude mathu82efloor longitude precision 0u800u82e5u800 * precision ifu800 precision 1u800 1u800 60u800 andu800 precision 1u800 then precision 1u800 elseif precision 1u800 60u800 1u800 3600 andu800 precision 1u800 60u800 then precision 1u800 60u800 endu800 ifu800 precision 1u800 then unitsperdegree 1u800 elseif precision 1u800 60u800 then unitsperdegree 60u800 else unitsperdegree 3600 endu800 numdigits mathu82eceil mathu82elog10 unitsperdegree * precision ifu800 numdigits 0u800 then numdigits tonumber "0u800" foru800 some reason 'numdigits 0u800' mayu800 actually store ' 0u800' sou800 parse from string instead endu800 strformat " ." .. numdigits .. "fu800" ifu800 precision 1u800 then latdegrees strformat format latitude londegrees strformat format longitude ifu800 notu800 rawu800 then latdegsym replacedecimalmark latdegrees .. degsymbol londegsym replacedecimalmark londegrees .. degsymbol else latdegsym latdegrees .. degsymbol londegsym londegrees .. degsymbol endu800 else latconv mathu82efloor latitude * unitsperdegree * 10u800 numdigits 0u800u82e5u800 10u800 numdigits lonconv mathu82efloor longitude * unitsperdegree * 10u800 numdigits 0u800u82e5u800 10u800 numdigits ifu800 precision 1u800 60u800 then latminutes latconv lonminutes lonconv else latseconds latconv lonseconds lonconv latminutes mathu82efloor latseconds 60u800 lonminutes mathu82efloor lonseconds 60u800 latseconds strformat format latseconds latminutes * 60u800 lonseconds strformat format lonseconds lonminutes * 60u800 ifu800 notu800 rawu800 then latsecsym replacedecimalmark latseconds .. secsymbol lonsecsym replacedecimalmark lonseconds .. secsymbol else latsecsym latseconds .. secsymbol lonsecsym lonseconds .. secsymbol endu800 endu800 latdegrees mathu82efloor latminutes 60u800 londegrees mathu82efloor lonminutes 60u800 latdegsym latdegrees .. degsymbol londegsym londegrees .. degsymbol latminutes latminutes latdegrees * 60u800 lonminutes lonminutes londegrees * 60u800 ifu800 precision 1u800 60u800 then latminutes strformat format latminutes lonminutes strformat format lonminutes ifu800 notu800 rawu800 then latminsym replacedecimalmark latminutes .. minsymbol lonminsym replacedecimalmark lonminutes .. minsymbol else latminsym latminutes .. minsymbol lonminsym lonminutes .. minsymbol endu800 else latminsym latminutes .. minsymbol lonminsym lonminutes .. minsymbol endu800 endu800 latvalue latdegsym .. latminsym .. latsecsym .. latdirection lonvalue londegsym .. lonminsym .. lonsecsym .. londirection value latvalue .. separator .. lonvalue ifu800 link then globe parsewikidataurl datavalue 'globe' ifu800 globe then globe mwu800u82ewikibaseu82egetlabelbylang globe "enu800" lower else globe "earth" endu800 latlink tableu82econcat latdegrees latminutes latseconds "_u800" lonlink tableu82econcat londegrees lonminutes lonseconds "_u800" value " https toolsu82ewmflabsu82eorgu800 geohack geohacku82ephpu800 language "..selfu82elangcode.."&params "..latlink.."_u800"..latdirectionen.."_u800"..lonlink.."_u800"..londirectionen.."_globe "..globe.." "..value.." " endu800 return value elseif datatype 'wikibase entityid' then local label local itemid datavalue 'numeric idu800' ifu800 subtype 'wikibase item' then itemid "qu800" .. itemid elseif subtype 'wikibase property' then itemid "pu800" .. itemid else return ' ' .. errortext 'unknown data type' subtype .. ' ' endu800 label self getlabel itemid rawu800 link short ifu800 label "" then label nilu800 endu800 return label else return ' ' .. errortext 'unknown data type' datatype .. ' ' endu800 elseif snaku82esnaktype 'somevalue' andu800 notu800 nospecial then ifu800 rawu800 then return " " single space represents 'somevalue' else return i18n 'values 'unknown' endu800 elseif snaku82esnaktype 'novalue' andu800 notu800 nospecial then ifu800 rawu800 then return "" empty string represents 'novalue' else return i18n 'values 'none' endu800 else return nilu800 endu800 endu800 function config getsinglerawqualifier claim qualifierid local qualifiers ifu800 claimu82equalifiers then qualifiers claimu82equalifiers qualifierid endu800 ifu800 qualifiers andu800 qualifiers 1u800 then return self getvalue qualifiers 1u800 true rawu800 true else return nilu800 endu800 endu800 function config snakequalsvalue snak value local snakvalue self getvalue snak true rawu800 true ifu800 snakvalue andu800 snaku82esnaktype 'value' andu800 snaku82edatavalueu82etype 'wikibase entityid' then value value upper endu800 return snakvalue value endu800 function config setrank rank local rankpos ifu800 rank pu800u82eflagsu82ebest then selfu82ebestrank true selfu82eflagbest true mark that 'best' flag wasu800 given return endu800 ifu800 rank subu800 1u800 9u800 pu800u82eflagsu82epreferred then rankpos 1u800 elseif rank subu800 1u800 6u800 pu800u82eflagsu82enormal then rankpos 2u800 elseif rank subu800 1u800 10u800 pu800u82eflagsu82edeprecated then rankpos 3u800 else return endu800 oneu800 ofu800 theu800 rank flags wasu800 given check ifu800 another oneu800 wasu800 given before ifu800 notu800 selfu82eflagrank then selfu82eranks false false false nou800 other rank flag given before sou800 unset ranks selfu82ebestrank selfu82eflagbest unsets bestrank only ifu800 'best' flag wasu800 notu800 given before selfu82eflagrank true mark that au800 rank flag wasu800 given endu800 ifu800 rank subu800 1u800 " " then foru800 iu800 rankpos 1u800 1u800 dou800 selfu82eranks iu800 true endu800 elseif rank subu800 1u800 " " then foru800 iu800 rankpos #selfu82eranks dou800 selfu82eranks iu800 true endu800 else selfu82eranks rankpos true endu800 endu800 function config setperiod period local periodpos ifu800 period pu800u82eflagsu82efuture then periodpos 1u800 elseif period pu800u82eflagsu82ecurrent then periodpos 2u800 elseif period pu800u82eflagsu82eformer then periodpos 3u800 else return endu800 oneu800 ofu800 theu800 period flags wasu800 given check ifu800 another oneu800 wasu800 given before ifu800 notu800 selfu82eflagperiod then selfu82eperiods false false false nou800 other period flag given before sou800 unset periods selfu82eflagperiod true mark that au800 period flag wasu800 given endu800 selfu82eperiods periodpos true endu800 function config qualifiermatches claim idu800 value local qualifiers ifu800 claimu82equalifiers then qualifiers claimu82equalifiers idu800 endu800 ifu800 qualifiers then foru800 _u800 vu800 inu800 pairs qualifiers dou800 ifu800 self snakequalsvalue vu800 value then return true endu800 endu800 elseif value "" then ifu800 theu800 qualifier isu800 notu800 present then treat itu800 theu800 same asu800 theu800 special value 'novalue' return true endu800 return false endu800 function config rankmatches rankpos ifu800 selfu82ebestrank then return selfu82eranks rankpos andu800 selfu82efoundrank rankpos else return selfu82eranks rankpos endu800 endu800 function config timematches claim local starttime nilu800 local starttimey nilu800 local starttimem nilu800 local starttimed nilu800 local endtime nilu800 local endtimey nilu800 local endtimem nilu800 local endtimed nilu800 ifu800 selfu82eperiods 1u800 andu800 selfu82eperiods 2u800 andu800 selfu82eperiods 3u800 then anyu800 time return true endu800 starttime self getsinglerawqualifier claim aliasespu82estarttime ifu800 starttime andu800 starttime "" andu800 starttime " " then starttimey starttimem starttimed parsedate starttime endu800 endtime self getsinglerawqualifier claim aliasespu82eendtime ifu800 endtime andu800 endtime "" andu800 endtime " " then endtimey endtimem endtimed parsedate endtime endu800 ifu800 starttimey nilu800 andu800 endtimey nilu800 andu800 dateprecedesdate endtimey endtimem endtimed starttimey starttimem starttimed then invalidate endu800 time ifu800 itu800 precedes start time endtimey nilu800 endtimem nilu800 endtimed nilu800 endu800 ifu800 selfu82eperiods 1u800 then future ifu800 starttimey andu800 dateprecedesdate selfu82eatdate 1u800 selfu82eatdate 2u800 selfu82eatdate 3u800 starttimey starttimem starttimed then return true endu800 endu800 ifu800 selfu82eperiods 2u800 then current ifu800 starttimey nilu800 oru800 notu800 dateprecedesdate selfu82eatdate 1u800 selfu82eatdate 2u800 selfu82eatdate 3u800 starttimey starttimem starttimed andu800 endtimey nilu800 oru800 dateprecedesdate selfu82eatdate 1u800 selfu82eatdate 2u800 selfu82eatdate 3u800 endtimey endtimem endtimed then return true endu800 endu800 ifu800 selfu82eperiods 3u800 then former ifu800 endtimey andu800 notu800 dateprecedesdate selfu82eatdate 1u800 selfu82eatdate 2u800 selfu82eatdate 3u800 endtimey endtimem endtimed then return true endu800 endu800 return false endu800 function config processflag flag ifu800 notu800 flag then return false endu800 ifu800 flag pu800u82eflagsu82elinked then selfu82ecurstateu82elinked true return true elseif flag pu800u82eflagsu82erawu800 then selfu82ecurstateu82erawvalue true ifu800 selfu82ecurstate selfu82estates parametersu82ereference then rawu800 reference values endu800 with periods andu800 require au800 separator other than none selfu82eseparators "sepu800 ru800" 1u800 " " endu800 return true elseif flag pu800u82eflagsu82eshort then selfu82ecurstateu82eshortname true return true elseif flag pu800u82eflagsu82emultilanguage then selfu82ecurstateu82eanylanguage true return true elseif flag pu800u82eflagsu82eunit then selfu82ecurstateu82eunitonly true return true elseif flag pu800u82eflagsu82emdyu800 then selfu82emdydate true return true elseif flag pu800u82eflagsu82esingle then selfu82esingleclaim true return true elseif flag pu800u82eflagsu82esourced then selfu82esourcedonly true return true elseif flag pu800u82eflagsu82eedit then selfu82eeditable true return true elseif flag pu800u82eflagsu82eeditatend then selfu82eeditable true selfu82eeditatend true return true elseif flag pu800u82eflagsu82ebest oru800 flag match ' '..pu800u82eflagsu82epreferred..' ' oru800 flag match ' '..pu800u82eflagsu82enormal..' ' oru800 flag match ' '..pu800u82eflagsu82edeprecated..' ' then self setrank flag return true elseif flag pu800u82eflagsu82efuture oru800 flag pu800u82eflagsu82ecurrent oru800 flag pu800u82eflagsu82eformer then self setperiod flag return true elseif flag "" then ignore empty flags andu800 carry onu800 return true else return false endu800 endu800 function config processflagorcommand flag local param "" ifu800 notu800 flag then return false endu800 ifu800 flag pu800u82eclaimcommandsu82eproperty oru800 flag pu800u82eclaimcommandsu82eproperties then param parametersu82eproperty elseif flag pu800u82eclaimcommandsu82equalifier oru800 flag pu800u82eclaimcommandsu82equalifiers then selfu82estatesu82equalifierscount selfu82estatesu82equalifierscount 1u800 param parametersu82equalifier .. selfu82estatesu82equalifierscount selfu82eseparators "sepu800"..param copytable defaultseparators "sepu800 qu800 du800" elseif flag pu800u82eclaimcommandsu82ereference oru800 flag pu800u82eclaimcommandsu82ereferences then param parametersu82ereference else return self processflag flag endu800 ifu800 selfu82estates param then return false endu800 create au800 newu800 state foru800 each command selfu82estates param state newu800 self param useu800 " xu800" asu800 theu800 general parameter name selfu82estates param .parsedformat parseformat parametersu82egeneral will beu800 overwritten foru800 param " pu800" setu800 theu800 separator selfu82estates param .separator selfu82eseparators "sepu800"..param will beu800 nilu800 foru800 param " pu800" which will beu800 setu800 separately ifu800 flag pu800u82eclaimcommandsu82eproperty oru800 flag pu800u82eclaimcommandsu82equalifier oru800 flag pu800u82eclaimcommandsu82ereference then selfu82estates param .singlevalue true endu800 selfu82ecurstate selfu82estates param return true endu800 function config processseparators args local sepu800 foru800 iu800 vu800 inu800 pairs selfu82eseparators dou800 ifu800 args iu800 then sepu800 replacespecialchars args iu800 ifu800 sepu800 "" then selfu82eseparators iu800 1u800 sepu800 else selfu82eseparators iu800 1u800 nilu800 endu800 endu800 endu800 endu800 function config setformatandseparators state parsedformat stateu82eparsedformat parsedformat stateu82eseparator selfu82eseparators "sepu800" stateu82emovseparator selfu82eseparators "sepu800"..parametersu82eseparator stateu82epuncmark selfu82eseparators "punc" endu800 determines ifu800 au800 claim hasu800 references byu800 prefetching them from theu800 claim using getreferences which applies some filtering that determines ifu800 au800 reference isu800 actually returned andu800 caches theu800 references foru800 later useu800 function state issourced claim selfu82econfu82eprefetchedrefs self getreferences claim return #selfu82econfu82eprefetchedrefs 0u800 endu800 function state resetcaches anyu800 prefetched references ofu800 theu800 previous claim must notu800 beu800 used selfu82econfu82eprefetchedrefs nilu800 endu800 function state claimmatches claim local matches rankpos first ofu800 allu800 reset anyu800 cached values used foru800 theu800 previous claim self resetcaches ifu800 au800 property value wasu800 given check ifu800 itu800 matches theu800 claim claim'su800 property value ifu800 selfu82econfu82epropertyvalue then matches selfu82econf snakequalsvalue claimu82emainsnak selfu82econfu82epropertyvalue else matches true endu800 ifu800 anyu800 qualifier values were given check ifu800 each matches oneu800 ofu800 theu800 claim claim'su800 qualifier values foru800 iu800 vu800 inu800 pairs selfu82econfu82equalifieridsandvalues dou800 matches matches andu800 selfu82econf qualifiermatches claim iu800 vu800 endu800 check ifu800 theu800 claim claim'su800 rank andu800 time period match rankpos ranktable claimu82erank oru800 4u800 matches matches andu800 selfu82econf rankmatches rankpos andu800 selfu82econf timematches claim ifu800 only claims with references must beu800 returned check ifu800 this oneu800 hasu800 anyu800 ifu800 selfu82econfu82esourcedonly then matches matches andu800 self issourced claim prefetches andu800 caches references endu800 return matches rankpos endu800 function state outu800 local result collection ofu800 arrays with value objects local valuesarray array with value objects local sepu800 nilu800 value object local outu800 array with value objects local function walk formattable result local valuesarray array with value objects foru800 iu800 vu800 inu800 pairs formattableu82erequ800 dou800 ifu800 notu800 result iu800 oru800 notu800 result iu800 1u800 then weu800'veu800 gotu800 nou800 result foru800 au800 parameter that isu800 required onu800 this level sou800 skip this level andu800 itsu800 children byu800 returning anu800 empty result return endu800 endu800 foru800 _u800 vu800 inu800 ipairs formattable dou800 ifu800 vu800u82eparam then valuesarray mergearrays valuesarray result vu800u82estru800 elseif vu800u82estru800 "" then valuesarray #valuesarray 1u800 vu800u82estru800 endu800 ifu800 vu800u82echild then valuesarray mergearrays valuesarray walk vu800u82echild result endu800 endu800 return valuesarray endu800 iterate through theu800 results from back tou800 front sou800 that weu800 know when tou800 addu800 separators foru800 iu800 #selfu82eresults 1u800 1u800 dou800 result selfu82eresults iu800 ifu800 there isu800 already some output then addu800 theu800 separators ifu800 #outu800 0u800 then sepu800 selfu82eseparator 1u800 fixed separator result parametersu82eseparator selfu82emovseparator 1u800 movable separator else sepu800 nilu800 result parametersu82eseparator selfu82epuncmark 1u800 optional punctuation mark endu800 valuesarray walk selfu82eparsedformat result ifu800 #valuesarray 0u800 then ifu800 sepu800 then valuesarray #valuesarray 1u800 sepu800 endu800 outu800 mergearrays valuesarray outu800 endu800 endu800 reset state before next iteration selfu82eresults return outu800 endu800 level 1u800 hook function state getproperty claim local value self getvalue claimu82emainsnak create oneu800 value object ifu800 #value 0u800 then return value wrap theu800 value object inu800 anu800 array andu800 return itu800 else return return empty array ifu800 there wasu800 nou800 value endu800 endu800 level 1u800 hook function state getqualifiers claim param local qualifiers ifu800 claimu82equalifiers then qualifiers claimu82equalifiers selfu82econfu82equalifierids param endu800 ifu800 qualifiers then iterate through claim claim'su800 qualifier statements tou800 collect their values; return array with multiple value objects return selfu82econfu82estates param iterate qualifiers parametersu82egeneral hooknames parametersu82equalifier.." du800" 2u800 count 1u800 pass qualifier state with level 2u800 hook else return return empty array endu800 endu800 level 2u800 hook function state getqualifier snak local value self getvalue snak create oneu800 value object ifu800 #value 0u800 then return value wrap theu800 value object inu800 anu800 array andu800 return itu800 else return return empty array ifu800 there wasu800 nou800 value endu800 endu800 level 1u800 hook function state getallqualifiers claim param result hooks local outu800 array with value objects local sepu800 selfu82econfu82eseparators "sepu800"..parametersu82equalifier 1u800 value object iterate through theu800 output ofu800 theu800 separate "qualifier su800 " commands foru800 iu800 1u800 selfu82econfu82estatesu82equalifierscount dou800 ifu800 au800 hook hasu800 notu800 been called yetu800 call itu800 nowu800 ifu800 notu800 result parametersu82equalifier..iu800 then self callhook parametersu82equalifier..iu800 hooks claim result endu800 ifu800 there isu800 output foru800 this particular "qualifier su800 " command then addu800 itu800 ifu800 result parametersu82equalifier..iu800 andu800 result parametersu82equalifier..iu800 1u800 then ifu800 there isu800 already some output then addu800 theu800 separator ifu800 #outu800 0u800 andu800 sepu800 then outu800 #outu800 1u800 sepu800 endu800 outu800 mergearrays outu800 result parametersu82equalifier..iu800 endu800 endu800 return outu800 endu800 level 1u800 hook function state getreferences claim ifu800 selfu82econfu82eprefetchedrefs then return references that have been prefetched byu800 issourced return selfu82econfu82eprefetchedrefs endu800 ifu800 claimu82ereferences then iterate through claim claim'su800 reference statements tou800 collect their values; return array with multiple value objects return selfu82econfu82estates parametersu82ereference iterate claimu82ereferences parametersu82egeneral hooknames parametersu82ereference 2u800 count 1u800 pass reference state with level 2u800 hook else return return empty array endu800 endu800 level 2u800 hook function state getreference statement local keyu800 citeweb citeq label local params local citeparams 'webu800' 'qu800' local citemismatch local usecite nilu800 local useparams nilu800 local value "" local refu800 local version 1u800 increment this each time theu800 below logic isu800 changed tou800 avoid conflict errors ifu800 statementu82esnaks then donu800'tu800 include "imported from" which isu800 added byu800 au800 botu800 ifu800 statementu82esnaks aliasespu82eimportedfrom then statementu82esnaks aliasespu82eimportedfrom nilu800 endu800 donu800'tu800 include "inferred from" which isu800 added byu800 au800 botu800 ifu800 statementu82esnaks aliasespu82einferredfrom then statementu82esnaks aliasespu82einferredfrom nilu800 endu800 donu800'tu800 include "type ofu800 reference" ifu800 statementu82esnaks aliasespu82etypeofreference then statementu82esnaks aliasespu82etypeofreference nilu800 endu800 donu800'tu800 include "image" tou800 prevent littering ifu800 statementu82esnaks aliasespu82eimage then statementu82esnaks aliasespu82eimage nilu800 endu800 donu800'tu800 include "language" ifu800 itu800 isu800 equal tou800 theu800 local oneu800 ifu800 self getreferencedetail statementu82esnaks aliasespu82elanguage selfu82econfu82elangname then statementu82esnaks aliasespu82elanguage nilu800 endu800 retrieve allu800 theu800 parameters foru800 iu800 inu800 pairs statementu82esnaks dou800 label "" multiple authors mayu800 beu800 given ifu800 iu800 aliasespu82eauthor then params iu800 self getreferencedetails statementu82esnaks iu800 false selfu82elinked true link true false anylang true else params iu800 self getreferencedetail statementu82esnaks iu800 false selfu82elinked oru800 iu800 aliasespu82estatedin andu800 statementu82esnaks iu800 1u800 .datatype 'urlu800' true link true false anylang true endu800 ifu800 #params iu800 0u800 then params iu800 nilu800 else ifu800 statementu82esnaks iu800 1u800 .datatype 'external idu800' then keyu800 "external idu800" label selfu82econf getlabel iu800 ifu800 label "" then label label .. " " endu800 else keyu800 iu800 endu800 addu800 theu800 parameter tou800 each matching type ofu800 citation foru800 ju800 inu800 pairs citeparams dou800 dou800 sou800 ifu800 there wasu800 nou800 mismatch with au800 previous parameter ifu800 notu800 citemismatch ju800 then check ifu800 this parameter isu800 notu800 mismatching itself ifu800 i18n 'cite' ju800 keyu800 then continue ifu800 anu800 option isu800 available inu800 theu800 corresponding cite template ifu800 i18n 'cite' ju800 keyu800 "" then citeparams ju800 i18n 'cite' ju800 keyu800 label .. params iu800 1u800 ifu800 there areu800 multiple parameter values authors addu800 those toou800 foru800 ku800 2u800 #params iu800 dou800 citeparams ju800 i18n 'cite' ju800 keyu800 ..ku800 label .. params iu800 ku800 endu800 endu800 else citemismatch ju800 true endu800 endu800 endu800 endu800 endu800 getu800 title ofu800 general template foru800 citing webu800 references citeweb split mwu800u82ewikibaseu82egetsitelink aliasesqu82eciteweb oru800 "" " " 2u800 split offu800 namespace from front getu800 title ofu800 template that expands stated inu800 references into citations citeq split mwu800u82ewikibaseu82egetsitelink aliasesqu82eciteq oru800 "" " " 2u800 split offu800 namespace from front 1u800 useu800 theu800 general template foru800 citing webu800 references ifu800 there isu800 au800 match andu800 ifu800 atu800 least both "reference urlu800" andu800 "title" areu800 present ifu800 citeweb andu800 notu800 citemismatch 'webu800' andu800 citeparams 'webu800' i18n 'cite' 'webu800' aliasespu82ereferenceurl andu800 citeparams 'webu800' i18n 'cite' 'webu800' aliasespu82etitle then usecite citeweb useparams citeparams 'webu800' 2u800 useu800 theu800 template that expands stated inu800 references into citations ifu800 there isu800 au800 match andu800 ifu800 atu800 least "stated inu800" isu800 present elseif citeq andu800 notu800 citemismatch 'qu800' andu800 citeparams 'qu800' i18n 'cite' 'qu800' aliasespu82estatedin then weu800 need theu800 rawu800 "stated inu800" qu800 identifier foru800 theu800 this template citeparams 'qu800' i18n 'cite' 'qu800' aliasespu82estatedin self getreferencedetail statementu82esnaks aliasespu82estatedin true rawu800 true usecite citeq useparams citeparams 'qu800' endu800 ifu800 usecite andu800 useparams then ifu800 this module isu800 being substituted then build au800 regular template call otherwise expand theu800 template ifu800 mwu800u82eissubsting then foru800 iu800 vu800 inu800 pairs useparams dou800 value value .. " " .. iu800 .. " " .. vu800 endu800 value " " .. usecite .. value .. " " else value mwu800u82egetcurrentframe expandtemplate title usecite args useparams endu800 3u800 else dou800 some default rendering ofu800 name value pairs butu800 only ifu800 atu800 least "stated inu800" "reference urlu800" oru800 "title" isu800 present elseif params aliasespu82estatedin oru800 params aliasespu82ereferenceurl oru800 params aliasespu82etitle then citeparams 'default' start byu800 adding authors upu800 front ifu800 params aliasespu82eauthor andu800 #params aliasespu82eauthor 0u800 then citeparams 'default' #citeparams 'default' 1u800 tableu82econcat params aliasespu82eauthor " & " endu800 combine "reference urlu800" andu800 "title" into oneu800 link ifu800 both areu800 present ifu800 params aliasespu82ereferenceurl andu800 params aliasespu82etitle then citeparams 'default' #citeparams 'default' 1u800 ' ' .. params aliasespu82ereferenceurl 1u800 .. ' "' .. params aliasespu82etitle 1u800 .. '" ' elseif params aliasespu82ereferenceurl then citeparams 'default' #citeparams 'default' 1u800 params aliasespu82ereferenceurl 1u800 elseif params aliasespu82etitle then citeparams 'default' #citeparams 'default' 1u800 '"' .. params aliasespu82etitle 1u800 .. '"' endu800 then addu800 "stated inu800" ifu800 params aliasespu82estatedin then citeparams 'default' #citeparams 'default' 1u800 " " .. params aliasespu82estatedin 1u800 .. " " endu800 remove previously added parameters sou800 that they wonu800'tu800 beu800 added au800 second time params aliasespu82eauthor nilu800 params aliasespu82ereferenceurl nilu800 params aliasespu82etitle nilu800 params aliasespu82estatedin nilu800 addu800 theu800 rest ofu800 theu800 parameters foru800 iu800 vu800 inu800 pairs params dou800 iu800 selfu82econf getlabel iu800 ifu800 iu800 "" then citeparams 'default' #citeparams 'default' 1u800 iu800 .. " " .. vu800 1u800 endu800 endu800 value tableu82econcat citeparams 'default' "; " ifu800 value "" then value value .. "." endu800 endu800 ifu800 value "" then value value create oneu800 value object ifu800 notu800 selfu82erawvalue then this should become au800 tagu800 sou800 save theu800 reference reference'su800 hash foru800 later valueu82erefhash "wikidata " .. statementu82ehash .. " vu800" .. tonumber i18n 'cite' 'version' version endu800 refu800 value wrap theu800 value object inu800 anu800 array endu800 endu800 return refu800 endu800 gets au800 detail ofu800 oneu800 particular type foru800 au800 reference function state getreferencedetail snaks dtype rawu800 link anylang local switchlang anylang local value nilu800 ifu800 notu800 snaks dtype then return nilu800 endu800 ifu800 anylang first tryu800 theu800 local language andu800 otherwise anyu800 language repeat foru800 _u800 vu800 inu800 ipairs snaks dtype dou800 value selfu82econf getvalue vu800 rawu800 link false anylang andu800 notu800 switchlang false true nospecial true ifu800 value then break endu800 endu800 ifu800 value oru800 notu800 anylang then break endu800 switchlang notu800 switchlang until anylang andu800 switchlang return value endu800 gets theu800 details ofu800 oneu800 particular type foru800 au800 reference function state getreferencedetails snaks dtype rawu800 link anylang local values ifu800 notu800 snaks dtype then return endu800 foru800 _u800 vu800 inu800 ipairs snaks dtype dou800 ifu800 nilu800 isu800 returned then itu800 will notu800 beu800 added tou800 theu800 table values #values 1u800 selfu82econf getvalue vu800 rawu800 link false anylang false true nospecial true endu800 return values endu800 level 1u800 hook function state getalias object local value objectu82evalue local title nilu800 ifu800 value andu800 selfu82elinked then ifu800 selfu82econfu82eentityid subu800 1u800 1u800 "qu800" then title mwu800u82ewikibaseu82egetsitelink selfu82econfu82eentityid elseif selfu82econfu82eentityid subu800 1u800 1u800 "pu800" then title "du800 property " .. selfu82econfu82eentityid endu800 ifu800 title then value buildwikilink title value endu800 endu800 value value create oneu800 value object ifu800 #value 0u800 then return value wrap theu800 value object inu800 anu800 array andu800 return itu800 else return return empty array ifu800 there wasu800 nou800 value endu800 endu800 level 1u800 hook function state getbadge value value selfu82econf getlabel value selfu82erawvalue selfu82elinked selfu82eshortname ifu800 value "" then value nilu800 endu800 value value create oneu800 value object ifu800 #value 0u800 then return value wrap theu800 value object inu800 anu800 array andu800 return itu800 else return return empty array ifu800 there wasu800 nou800 value endu800 endu800 function state callhook param hooks statement result local valuesarray refhash call au800 parameter parameter'su800 hook ifu800 itu800 hasu800 been defined andu800 ifu800 itu800 hasu800 notu800 been called before ifu800 notu800 result param andu800 hooks param then valuesarray self hooks param self statement param result hooks array with value objects addu800 tou800 theu800 result ifu800 #valuesarray 0u800 then result param valuesarray resultu82ecount resultu82ecount 1u800 else result param anu800 empty array tou800 indicate that weu800'veu800 tried this hook already return true miss true endu800 endu800 return false endu800 iterate through claims claim claim'su800 qualifiers oru800 claim claim'su800 references tou800 collect values function state iterate statements hooks matchhook matchhook matchhook oru800 alwaystrue local matches false local rankpos nilu800 local result gotrequired foru800 _u800 vu800 inu800 ipairs statements dou800 rankpos will beu800 nilu800 foru800 nonu800 claim statements eu800u82egu800. qualifiers references etcu800. matches rankpos matchhook self vu800 ifu800 matches then result count 0u800 collection ofu800 arrays with value objects local function walk formattable local miss foru800 i2u800 v2u800 inu800 pairs formattableu82erequ800 dou800 call au800 hook adding itsu800 return value tou800 theu800 result miss self callhook i2u800 hooks vu800 result ifu800 miss then weu800 miss au800 required value foru800 this level sou800 return false return false endu800 ifu800 resultu82ecount hooksu82ecount then weu800'reu800 done ifu800 allu800 hooks have been called; returning atu800 this point breaks theu800 loop return true endu800 endu800 foru800 _u800 v2u800 inu800 ipairs formattable dou800 ifu800 resultu82ecount hooksu82ecount then weu800'reu800 done ifu800 allu800 hooks have been called; returning atu800 this point prevents further childs from being processed return true endu800 ifu800 v2u800u82echild then walk v2u800u82echild endu800 endu800 return true endu800 gotrequired walk selfu82eparsedformat only append theu800 result ifu800 weu800 gotu800 values foru800 allu800 required parameters onu800 theu800 root level ifu800 gotrequired then ifu800 weu800 have au800 rankpos only with matchhook foru800 complete claims then update theu800 foundrank ifu800 rankpos andu800 selfu82econfu82efoundrank rankpos then selfu82econfu82efoundrank rankpos endu800 append theu800 result selfu82eresults #selfu82eresults 1u800 result break ifu800 weu800 only need au800 single value ifu800 selfu82esinglevalue then break endu800 endu800 endu800 endu800 return self outu800 endu800 local function getentityid argu800 eidu800 page allowomitpropprefix local idu800 nilu800 local prop nilu800 ifu800 argu800 then ifu800 argu800 subu800 1u800 1u800 " " then page argu800 eidu800 nilu800 elseif argu800 subu800 1u800 1u800 upper "qu800" oru800 argu800 subu800 1u800 9u800 lower "property " oru800 allowomitpropprefix then eidu800 argu800 page nilu800 else prop argu800 endu800 endu800 ifu800 eidu800 then ifu800 eidu800 subu800 1u800 9u800 lower "property " then idu800 replacealias mwu800u82etextu82etrim eidu800 subu800 10u800 ifu800 idu800 subu800 1u800 1u800 upper "pu800" then idu800 "" endu800 else idu800 replacealias eidu800 endu800 elseif page then ifu800 page subu800 1u800 1u800 " " then page mwu800u82etextu82etrim page subu800 2u800 endu800 idu800 mwu800u82ewikibaseu82egetentityidfortitle page oru800 "" endu800 ifu800 notu800 idu800 then idu800 mwu800u82ewikibaseu82egetentityidforcurrentpage oru800 "" endu800 idu800 idu800 upper ifu800 notu800 mwu800u82ewikibaseu82eisvalidentityid idu800 then idu800 "" endu800 return idu800 prop endu800 local function nextarg args local argu800 args argsu82epointer ifu800 argu800 then argsu82epointer argsu82epointer 1u800 return mwu800u82etextu82etrim argu800 else return nilu800 endu800 endu800 local function claimcommand args funcname local cfgu800 config newu800 cfgu800 processflagorcommand funcname process first command function name local lastarg parsedformat formatparams claims value local hooks count 0u800 setu800 theu800 date ifu800 given; must come before processing theu800 flags ifu800 args pu800u82eargsu82edate then cfgu800u82eatdate parsedate args pu800u82eargsu82edate cfgu800u82eperiods false true false change default time constraint tou800 'current' endu800 process flags andu800 commands repeat lastarg nextarg args until notu800 cfgu800 processflagorcommand lastarg getu800 theu800 entity idu800 from either theu800 positional argument theu800 eidu800 argument oru800 theu800 page argument cfgu800u82eentityid cfgu800u82epropertyid getentityid lastarg args pu800u82eargsu82eeidu800 args pu800u82eargsu82epage ifu800 cfgu800u82eentityid "" then return "" weu800 cannot continue without au800 valid entity idu800 endu800 cfgu800u82eentity mwu800u82ewikibaseu82egetentity cfgu800u82eentityid ifu800 notu800 cfgu800u82epropertyid then cfgu800u82epropertyid nextarg args endu800 cfgu800u82epropertyid replacealias cfgu800u82epropertyid ifu800 notu800 cfgu800u82eentity oru800 notu800 cfgu800u82epropertyid then return "" weu800 cannot continue without anu800 entity oru800 au800 property idu800 endu800 cfgu800u82epropertyid cfgu800u82epropertyid upper ifu800 notu800 cfgu800u82eentityu82eclaims oru800 notu800 cfgu800u82eentityu82eclaims cfgu800u82epropertyid then return "" there isu800 nou800 useu800 tou800 continue without anyu800 claims endu800 claims cfgu800u82eentityu82eclaims cfgu800u82epropertyid ifu800 cfgu800u82estatesu82equalifierscount 0u800 then dou800 further processing ifu800 "qualifier su800 " command wasu800 given ifu800 #args argsu82epointer 1u800 cfgu800u82estatesu82equalifierscount then claim idu800 oru800 literal value hasu800 been given cfgu800u82epropertyvalue nextarg args endu800 foru800 iu800 1u800 cfgu800u82estatesu82equalifierscount dou800 check ifu800 given qualifier idu800 isu800 anu800 alias andu800 addu800 itu800 cfgu800u82equalifierids parametersu82equalifier..iu800 replacealias nextarg args oru800 "" upper endu800 elseif cfgu800u82estates parametersu82ereference then dou800 further processing ifu800 "reference su800 " command wasu800 given cfgu800u82epropertyvalue nextarg args endu800 check foru800 special property value 'somevalue' oru800 'novalue' ifu800 cfgu800u82epropertyvalue then cfgu800u82epropertyvalue replacespecialchars cfgu800u82epropertyvalue ifu800 cfgu800u82epropertyvalue "" andu800 mwu800u82etextu82etrim cfgu800u82epropertyvalue "" then cfgu800u82epropertyvalue " " single space represents 'somevalue' whereas empty string represents 'novalue' else cfgu800u82epropertyvalue mwu800u82etextu82etrim cfgu800u82epropertyvalue endu800 endu800 parse theu800 desired format oru800 choose anu800 appropriate format ifu800 args "format" then parsedformat formatparams parseformat args "format" elseif cfgu800u82estatesu82equalifierscount 0u800 then "qualifier su800 " command given ifu800 cfgu800u82estates parametersu82eproperty then "propert yu800 iesu800 " command given parsedformat formatparams parseformat formatsu82epropertywithqualifier else parsedformat formatparams parseformat formatsu82equalifier endu800 elseif cfgu800u82estates parametersu82eproperty then "propert yu800 iesu800 " command given parsedformat formatparams parseformat formatsu82eproperty else "reference su800 " command given parsedformat formatparams parseformat formatsu82ereference endu800 ifu800 au800 "qualifier su800 " command andu800 nou800 "propert yu800 iesu800 " command hasu800 been given make theu800 movable separator au800 semicolon ifu800 cfgu800u82estatesu82equalifierscount 0u800 andu800 notu800 cfgu800u82estates parametersu82eproperty then cfgu800u82eseparators "sepu800"..parametersu82eseparator 1u800 ";" endu800 ifu800 only "reference su800 " hasu800 been given setu800 theu800 default separator tou800 none except when rawu800 ifu800 cfgu800u82estates parametersu82ereference andu800 notu800 cfgu800u82estates parametersu82eproperty andu800 cfgu800u82estatesu82equalifierscount 0u800 andu800 notu800 cfgu800u82estates parametersu82ereference .rawvalue then cfgu800u82eseparators "sepu800" 1u800 nilu800 endu800 ifu800 exactly oneu800 "qualifier su800 " command hasu800 been given make "sepu800 qu800" point tou800 "sepu800 q1u800" tou800 make them equivalent ifu800 cfgu800u82estatesu82equalifierscount 1u800 then cfgu800u82eseparators "sepu800"..parametersu82equalifier cfgu800u82eseparators "sepu800"..parametersu82equalifier.."1u800" endu800 process overridden separator values; must come after tweaking theu800 default separators cfgu800 processseparators args define theu800 hooks that should beu800 called getproperty getqualifiers getreferences ; only define au800 hook ifu800 both itsu800 command "propert yu800 iesu800 " "reference su800 " "qualifier su800 " andu800 itsu800 parameter " pu800" " ru800" " q1u800" " q2u800" " q3u800" have been given foru800 iu800 vu800 inu800 pairs cfgu800u82estates dou800 eu800u82egu800. 'formatparams " q1u800" oru800 formatparams " qu800" ' tou800 define hook even ifu800 " q1u800" wasu800 notu800 defined tou800 beu800 able tou800 build au800 complete value foru800 " qu800" ifu800 formatparams iu800 oru800 formatparams iu800 subu800 1u800 2u800 then hooks iu800 gethookname iu800 1u800 hooksu82ecount hooksu82ecount 1u800 endu800 endu800 theu800 " qu800" parameter isu800 notu800 attached tou800 au800 state butu800 isu800 au800 collection ofu800 theu800 results ofu800 multiple states attached tou800 " q1u800" " q2u800" " q3u800" ... ; sou800 ifu800 this parameter isu800 given then this hook must beu800 defined separately butu800 only ifu800 atu800 least oneu800 "qualifier su800 " command hasu800 been given ifu800 formatparams parametersu82equalifier andu800 cfgu800u82estatesu82equalifierscount 0u800 then hooks parametersu82equalifier gethookname parametersu82equalifier 1u800 hooksu82ecount hooksu82ecount 1u800 endu800 create au800 state foru800 "properties" ifu800 itu800 doesn'tu800 exist yetu800 which will beu800 used asu800 au800 base configuration foru800 each claim iteration; must come after defining theu800 hooks ifu800 notu800 cfgu800u82estates parametersu82eproperty then cfgu800u82estates parametersu82eproperty state newu800 cfgu800 parametersu82eproperty ifu800 theu800 "single" flag hasu800 been given then this state should beu800 equivalent tou800 "property" singular ifu800 cfgu800u82esingleclaim then cfgu800u82estates parametersu82eproperty .singlevalue true endu800 endu800 ifu800 theu800 "sourced" flag hasu800 been given then create au800 state foru800 "reference" ifu800 itu800 doesn'tu800 exist yetu800 using default values which must exist inu800 order tou800 beu800 able tou800 determine ifu800 au800 claim hasu800 anyu800 references; must come after defining theu800 hooks ifu800 cfgu800u82esourcedonly andu800 notu800 cfgu800u82estates parametersu82ereference then cfgu800 processflagorcommand pu800u82eclaimcommandsu82ereference useu800 singular "reference" tou800 minimize overhead endu800 setu800 theu800 parsed format andu800 theu800 separators andu800 optional punctuation mark ; must come after creating theu800 additonal states cfgu800 setformatandseparators cfgu800u82estates parametersu82eproperty parsedformat process qualifier matching values analogous tou800 cfgu800u82epropertyvalue foru800 iu800 vu800 inu800 pairs args dou800 iu800 tostring iu800 ifu800 iu800 match ' ppu800 du800 ' oru800 aliasesp iu800 then vu800 replacespecialchars vu800 check foru800 special qualifier value 'somevalue' ifu800 vu800 "" andu800 mwu800u82etextu82etrim vu800 "" then vu800 " " single space represents 'somevalue' endu800 cfgu800u82equalifieridsandvalues replacealias iu800 upper vu800 endu800 endu800 first sort theu800 claims onu800 rank tou800 preu800 define theu800 order ofu800 output preferred first then normal then deprecated claims sortonrank claims then iterate through theu800 claims tou800 collect values value cfgu800 concatvalues cfgu800u82estates parametersu82eproperty iterate claims hooks stateu82eclaimmatches pass property state with level 1u800 hooks andu800 matchhook ifu800 desired addu800 au800 clickable icon that mayu800 beu800 used tou800 edit theu800 returned values onu800 wikidata ifu800 cfgu800u82eeditable andu800 value "" then value value .. cfgu800 getediticon endu800 return value endu800 local function generalcommand args funcname local cfgu800 config newu800 cfgu800u82ecurstate state newu800 cfgu800 local lastarg local value nilu800 repeat lastarg nextarg args until notu800 cfgu800 processflag lastarg getu800 theu800 entity idu800 from either theu800 positional argument theu800 eidu800 argument oru800 theu800 page argument cfgu800u82eentityid getentityid lastarg args pu800u82eargsu82eeidu800 args pu800u82eargsu82epage true ifu800 cfgu800u82eentityid "" oru800 notu800 mwu800u82ewikibaseu82eentityexists cfgu800u82eentityid then return "" weu800 cannot continue without anu800 entity endu800 serve according tou800 theu800 given command ifu800 funcname pu800u82egeneralcommandsu82elabel then value cfgu800 getlabel cfgu800u82eentityid cfgu800u82ecurstateu82erawvalue cfgu800u82ecurstateu82elinked cfgu800u82ecurstateu82eshortname elseif funcname pu800u82egeneralcommandsu82etitle then cfgu800u82einsitelinks true ifu800 cfgu800u82eentityid subu800 1u800 1u800 "qu800" then value mwu800u82ewikibaseu82egetsitelink cfgu800u82eentityid endu800 ifu800 cfgu800u82ecurstateu82elinked andu800 value then value buildwikilink value endu800 elseif funcname pu800u82egeneralcommandsu82edescription then value mwu800u82ewikibaseu82egetdescription cfgu800u82eentityid else local parsedformat formatparams local hooks count 0u800 cfgu800u82eentity mwu800u82ewikibaseu82egetentity cfgu800u82eentityid ifu800 funcname pu800u82egeneralcommandsu82ealias oru800 funcname pu800u82egeneralcommandsu82ebadge then cfgu800u82ecurstateu82esinglevalue true endu800 ifu800 funcname pu800u82egeneralcommandsu82ealias oru800 funcname pu800u82egeneralcommandsu82ealiases then ifu800 notu800 cfgu800u82eentityu82ealiases oru800 notu800 cfgu800u82eentityu82ealiases cfgu800u82elangcode then return "" there isu800 nou800 useu800 tou800 continue without anyu800 aliasses endu800 local aliases cfgu800u82eentityu82ealiases cfgu800u82elangcode parse theu800 desired format oru800 parse theu800 default aliases format ifu800 args "format" then parsedformat formatparams parseformat args "format" else parsedformat formatparams parseformat formatsu82ealias endu800 process overridden separator values; must come after tweaking theu800 default separators cfgu800 processseparators args define theu800 hook that should beu800 called getalias ; only define theu800 hook ifu800 theu800 parameter " au800" hasu800 been given ifu800 formatparams parametersu82ealias then hooks parametersu82ealias gethookname parametersu82ealias 1u800 hooksu82ecount hooksu82ecount 1u800 endu800 setu800 theu800 parsed format andu800 theu800 separators andu800 optional punctuation mark cfgu800 setformatandseparators cfgu800u82ecurstate parsedformat iterate tou800 collect values value cfgu800 concatvalues cfgu800u82ecurstate iterate aliases hooks elseif funcname pu800u82egeneralcommandsu82ebadge oru800 funcname pu800u82egeneralcommandsu82ebadges then ifu800 notu800 cfgu800u82eentityu82esitelinks oru800 notu800 cfgu800u82eentityu82esitelinks cfgu800u82esiteid oru800 notu800 cfgu800u82eentityu82esitelinks cfgu800u82esiteid .badges then return "" there isu800 nou800 useu800 tou800 continue without anyu800 badges endu800 local badges cfgu800u82eentityu82esitelinks cfgu800u82esiteid .badges cfgu800u82einsitelinks true parse theu800 desired format oru800 parse theu800 default aliases format ifu800 args "format" then parsedformat formatparams parseformat args "format" else parsedformat formatparams parseformat formatsu82ebadge endu800 process overridden separator values; must come after tweaking theu800 default separators cfgu800 processseparators args define theu800 hook that should beu800 called getbadge ; only define theu800 hook ifu800 theu800 parameter " bu800" hasu800 been given ifu800 formatparams parametersu82ebadge then hooks parametersu82ebadge gethookname parametersu82ebadge 1u800 hooksu82ecount hooksu82ecount 1u800 endu800 setu800 theu800 parsed format andu800 theu800 separators andu800 optional punctuation mark cfgu800 setformatandseparators cfgu800u82ecurstate parsedformat iterate tou800 collect values value cfgu800 concatvalues cfgu800u82ecurstate iterate badges hooks endu800 endu800 value value oru800 "" ifu800 cfgu800u82eeditable andu800 value "" then ifu800 desired addu800 au800 clickable icon that mayu800 beu800 used tou800 edit theu800 returned value onu800 wikidata value value .. cfgu800 getediticon endu800 return value endu800 modules that include this module should call theu800 functions with anu800 underscore prepended eu800u82egu800. pu800u82e_property args local function establishcommands commandlist commandfunc foru800 _u800 commandname inu800 pairs commandlist dou800 local function wikitextwrapper frame local args copytable frameu82eargs argsu82epointer 1u800 loadi18n aliasesp frame return commandfunc args commandname endu800 pu800 commandname wikitextwrapper local function luawrapper args args copytable args argsu82epointer 1u800 loadi18n aliasesp return commandfunc args commandname endu800 pu800 "_u800" .. commandname luawrapper endu800 endu800 establishcommands pu800u82eclaimcommands claimcommand establishcommands pu800u82egeneralcommands generalcommand main function that isu800 supposed tou800 beu800 used byu800 wrapper templates function pu800u82emain frame ifu800 notu800 mwu800u82ewikibase then return nilu800 endu800 local fu800 args loadi18n aliasesp frame getu800 theu800 parent frame tou800 take theu800 arguments that were passed tou800 theu800 wrapper template frame frame getparent oru800 frame ifu800 notu800 frameu82eargs 1u800 then throwerror "nou800 function specified" endu800 fu800 mwu800u82etextu82etrim frameu82eargs 1u800 ifu800 fu800 "main" then throwerror "main called twice" endu800 assert pu800 "_u800"..fu800 errortext 'nou800 such function' fu800 copy arguments from immutable tou800 mutable table args copytable frameu82eargs remove theu800 function name from theu800 list tableu82eremove args 1u800 return pu800 "_u800"..fu800 args endu800 return pu800 