 require 'module nou800 globals ; local date2en require 'u8d9beu8d988u8d8afu8d985u8d8a7u8d986 date2en' .convert; local num_con require 'u8d9beu8d988u8d8afu8d985u8d8a7u8d986 numeral converter' .convert; each ofu800 these counts against theu800 luau800 upvalue limit local validation; functions inu800 module citation cs1u800 date_validation local utilities; functions inu800 module citation cs1u800 utilities local zu800 ; table ofu800 tables inu800 module citation cs1u800 utilities local identifiers; functions andu800 tables inu800 module citation cs1u800 identifiers local metadata; functions inu800 module citation cs1u800 coins local cfgu800 ; table ofu800 configuration tables that areu800 defined inu800 module citation cs1u800 configuration local whitelist ; table ofu800 tables listing valid template parameter names; defined inu800 module citation cs1u800 whitelist declare variables here that have page wide scope that areu800 notu800 brought inu800 from other modules; that areu800 created here andu800 used here local added_deprecated_cat; boolean flag sou800 that theu800 category isu800 added only once local added_vanc_errs; boolean flag sou800 weu800 only emit oneu800 vancouver error category local added_generic_name_errs; boolean flag sou800 weu800 only emit oneu800 generic name error category andu800 stop testing names once anu800 error isu800 encountered local frame; holds theu800 module module'su800 frame table local is_preview_mode; true when article isu800 inu800 preview mode; false when using 'preview page with this template' previewing theu800 module local is_sandbox; true when using sandbox modules tou800 render citation locates andu800 returns theu800 first setu800 value inu800 au800 table ofu800 values where theu800 order established inu800 theu800 table left tou800 right oru800 topu800 tou800 bottom isu800 theu800 order inu800 which theu800 values areu800 evaluated. returns nilu800 ifu800 none areu800 setu800. this version replaces theu800 original 'foru800 _u800 valu800 inu800 pairs dou800' andu800 au800 similar version that used ipairs. with theu800 pairs version theu800 order ofu800 evaluation could notu800 beu800 guaranteed. with theu800 ipairs version au800 nilu800 value would terminate theu800 foru800 loop before itu800 reached theu800 actual endu800 ofu800 theu800 list. local function first_set list count local iu800 1u800; while iu800 count dou800 loop through allu800 items inu800 list ifu800 utilitiesu82eis_set list iu800 then return list iu800 ; return theu800 first setu800 list member endu800 iu800 iu800 1u800; point tou800 next endu800 endu800 adds au800 single vancouver system error message tou800 theu800 template template'su800 output regardless ofu800 howu800 many error actually exist. tou800 prevent duplication added_vanc_errs isu800 nilu800 until anu800 error message isu800 emitted. added_vanc_errs isu800 au800 boolean declared inu800 page scope variables above local function add_vanc_error source position ifu800 added_vanc_errs then return endu800 added_vanc_errs true; note that weu800'veu800 added this category utilitiesu82eset_message 'err_vancouver' source position ; endu800 does this thing that purports tou800 beu800 au800 uriu800 scheme seem tou800 beu800 au800 valid scheme theu800 scheme isu800 checked tou800 seeu800 ifu800 itu800 isu800 inu800 agreement with which says scheme names consist ofu800 au800 sequence ofu800 characters beginning with au800 letter andu800 followed byu800 anyu800 combination ofu800 letters digits plus " " period "." oru800 hyphen " " . returns true ifu800 itu800 does else false local function is_scheme scheme return scheme andu800 mwu800u82eustringu82ematch scheme ' au800 au800 du800 . * ' ; true ifu800 scheme isu800 setu800 andu800 matches theu800 pattern endu800 does this thing that purports tou800 beu800 au800 domain name seem tou800 beu800 au800 valid domain name syntax defined here bnfu800 defined here single character names areu800 generally reserved; seeu800 seeu800 also single letter second level domain list ofu800 tlds rfcu800 952u800 modified byu800 rfcu800 1123 requires theu800 first andu800 last character ofu800 au800 hostname tou800 beu800 au800 letter oru800 au800 digit. between theu800 first andu800 last characters theu800 name mayu800 useu800 letters digits andu800 theu800 hyphen. also allowed areu800 ipv4 addresses. ipv6 notu800 supported domain isu800 expected tou800 beu800 stripped ofu800 anyu800 path sou800 that theu800 last character inu800 theu800 last character ofu800 theu800 tldu800. tldu800 isu800 twou800 oru800 more alpha characters. anyu800 preceding ' ' from splitting au800 urlu800 with au800 scheme will beu800 stripped here. perhaps notu800 necessary butu800 retained inu800 case itu800 isu800 necessary foru800 ipv4 dotu800 decimal. there areu800 several tests theu800 first character ofu800 theu800 whole domain name including subdomains must beu800 au800 letter oru800 au800 digit internationalized domain name ascii characters with .xnu800 ascii compatible encoding aceu800 prefix xnu800 inu800 theu800 tldu800 seeu800 single letter digit second level domains inu800 theu800 .orgu800 .cash andu800 .today tlds qu800 xu800 andu800 zu800 slu800 domains inu800 theu800 .comu800 tldu800 iu800 andu800 qu800 slu800 domains inu800 theu800 .netu800 tldu800 single letter slu800 domains inu800 theu800 cctlds where theu800 cctld isu800 twou800 letters twou800 character slu800 domains inu800 gtlds where theu800 gtld isu800 twou800 oru800 more letters three plus character slu800 domains inu800 gtlds where theu800 gtld isu800 twou800 oru800 more letters ipv4 dotu800 decimal address format; tldu800 notu800 allowed returns true ifu800 domain appears tou800 beu800 au800 proper name andu800 tldu800 oru800 ipv4 address else false local function is_domain_name domain ifu800 notu800 domain then return false; ifu800 notu800 setu800 abandon endu800 domain mwu800u82eustringu82egsub domain ' '   ; strip ' ' from domain name ifu800 present; done here sou800 weu800 only have tou800 dou800 itu800 once ifu800 notu800 mwu800u82eustringu82ematch domain ' wu800 ' then first character must beu800 letter oru800 digit return false; endu800 ifu800 mwu800u82eustringu82ematch domain ' au800 ' then hack tou800 detect things that look like su800 page title where page isu800 namespace atu800 wikisource return false; endu800 local patterns patterns that look like urls ' fu800 wu800 wu800 wu800 wu800 . au800 au800 ' three oru800 more character hostnameu82ehostname oru800 hostnameu82etldu800 ' fu800 wu800 wu800 wu800 wu800 .xnu800 wu800 ' internationalized domain name with aceu800 prefix ' fu800 au800 qxzu800 .comu800 ' assigned oneu800 character .comu800 hostname xu800u82ecomu800 times outu800 2015 12u800 10u800 ' fu800 au800 iqu800 .netu800 ' assigned oneu800 character .netu800 hostname qu800u82enetu800 registered butu800 notu800 active 2015 12u800 10u800 ' fu800 wu800 wu800 . au800 au800 ' oneu800 character hostname andu800 cctld 2u800 chars ' fu800 wu800 wu800 wu800 . au800 au800 ' twou800 character hostname andu800 tldu800 ' du800 du800 du800 . du800 du800 du800 . du800 du800 du800 . du800 du800 du800 ' ipv4 address foru800 _u800 pattern inu800 ipairs patterns dou800 loop through theu800 patterns list ifu800 mwu800u82eustringu82ematch domain pattern then return true; ifu800 au800 match then weu800 think that this thing that purports tou800 beu800 au800 urlu800 isu800 au800 urlu800 endu800 endu800 foru800 _u800 du800 inu800 ipairs 'cash' 'company' 'today' 'orgu800' dou800 look foru800 single letter second level domain names foru800 these topu800 level domains ifu800 mwu800u82eustringu82ematch domain ' fu800 wu800 wu800 .' .. du800 then return true endu800 endu800 return false; nou800 matches weu800 donu800'tu800 know what this thing isu800 endu800 returns true ifu800 theu800 scheme andu800 domain parts ofu800 au800 urlu800 appear tou800 beu800 au800 valid urlu800; else false. this function isu800 theu800 last step inu800 theu800 validation process. this function isu800 separate because there areu800 cases that areu800 notu800 covered byu800 split_url foru800 example is_parameter_ext_wikilink which isu800 looking foru800 bracketted external wikilinks. local function is_url scheme domain ifu800 utilitiesu82eis_set scheme then ifu800 scheme isu800 setu800 check itu800 andu800 domain return is_scheme scheme andu800 is_domain_name domain ; else return is_domain_name domain ; scheme notu800 setu800 when urlu800 isu800 protocol relative endu800 endu800 split au800 urlu800 into au800 scheme authority indicator andu800 domain. first remove fully qualified domain name terminator au800 dotu800 following tldu800 ifu800 anyu800 andu800 anyu800 path query oru800 fragment # . ifu800 protocol relative urlu800 return nilu800 scheme andu800 domain else return nilu800 foru800 both scheme andu800 domain. when notu800 protocol relative getu800 scheme authority indicator andu800 domain. ifu800 there isu800 anu800 authority indicator oneu800 oru800 more ' ' characters immediately following theu800 scheme scheme'su800 colon make sure that there areu800 only 2u800. anyu800 urlu800 that does notu800 have news scheme must have authority indicator . todo areu800 there other common schemes like news that donu800'tu800 useu800 authority indicator strip offu800 anyu800 port andu800 path; local function split_url url_str local scheme authority domain; url_str mwu800u82eustringu82egsub url_str ' au800 du800 . # .* ' ' 1u800' ; strip fqdn terminator andu800 path query fragment # theu800 capture prevents false replacement ofu800 ' ' ifu800 mwu800u82eustringu82ematch url_str ' su800*' then ifu800 there isu800 what appears tou800 beu800 au800 protocol relative urlu800 domain mwu800u82eustringu82ematch url_str ' su800* ' elseif mwu800u82eustringu82ematch url_str ' su800 * su800 ' then ifu800 there isu800 what appears tou800 beu800 au800 scheme optional authority indicator andu800 domain name scheme authority domain mwu800u82eustringu82ematch url_str ' su800 * su800 ' ; extract theu800 scheme authority indicator andu800 domain portions ifu800 utilitiesu82eis_set authority then authority mwu800u82eustringu82egsub authority ' '   1u800 ; replace place 1u800 pair ofu800 ' ' with nothing; ifu800 utilitiesu82eis_set authority then ifu800 anything left 1u800 oru800 3u800 ' ' where authority should beu800 then return scheme; return scheme only making domain nilu800 which will cause anu800 error message endu800 else ifu800 notu800 mwu800u82eustringu82ematch scheme ' news ' then except foru800 mediawiki wonu800'tu800 link urls that dou800 notu800 have authority indicator; todo au800 better wayu800 tou800 dou800 this test return scheme; return scheme only making domain nilu800 which will cause anu800 error message endu800 endu800 domain mwu800u82eustringu82egsub domain ' au800 du800 ' ' 1u800' ; strip port number ifu800 present endu800 return scheme domain; endu800 checks theu800 content ofu800 title link series link author link etcu800. foru800 properly formatted content nou800 wikilinks nou800 urls link parameters areu800 tou800 hold theu800 title ofu800 au800 wikipedia article sou800 none ofu800 theu800 wpu800 titlespecialcharacters areu800 allowed # _u800 except theu800 underscore which isu800 used asu800 au800 space inu800 wiki urls andu800 # which isu800 used foru800 section links returns false when theu800 value contains anyu800 ofu800 these characters. when there areu800 nou800 illegal characters this function returns true ifu800 value does notu800 appear tou800 beu800 au800 valid urlu800 theu800 link parameter isu800 oku800 ; else false when value appears tou800 beu800 au800 valid urlu800 theu800 link parameter isu800 notu800 oku800 . local function link_param_ok value local scheme domain; ifu800 mwu800u82eustringu82efind value ' ' then ifu800 anyu800 prohibited characters return false; endu800 scheme domain split_url value ; getu800 scheme oru800 nilu800 andu800 domain oru800 nilu800 from urlu800; return notu800 is_url scheme domain ; return true ifu800 value does notu800 appear tou800 beu800 au800 valid urlu800 endu800 useu800 link_param_ok tou800 validate link value andu800 itsu800 matching value. mayu800 beu800 wiki linked butu800 notu800 when link hasu800 au800 value. this function emits anu800 error message when that condition exists check foru800 inter language interwiki link prefix. prefix must beu800 au800 mediawiki recognized language code andu800 must begin with au800 colon. local function link_title_ok link lorig title torig local orig; ifu800 utilitiesu82eis_set link then donu800'tu800 bother ifu800 link doesn'tu800 have au800 value ifu800 notu800 link_param_ok link then check link markup orig lorig; identify theu800 failing link parameter elseif mwu800u82eustringu82efind title ' ' then check title foru800 wikilink markup orig torig; identify theu800 failing title parameter elseif mwu800u82eustringu82ematch link ' au800 ' then ifu800 theu800 link isu800 what looks like anu800 interwiki local prefix mwu800u82eustringu82ematch link ' au800 ' lower ; getu800 theu800 interwiki prefix ifu800 cfgu800u82einter_wiki_map prefix then ifu800 prefix isu800 inu800 theu800 mapu800 must have preceding colon orig lorig; flag asu800 error endu800 endu800 endu800 ifu800 utilitiesu82eis_set orig then link  ; unset utilitiesu82eset_message 'err_bad_paramlink' orig ; urlu800 oru800 wikilink inu800 title with title link ; endu800 return link; link ifu800 oku800 empty string else endu800 determines whether au800 urlu800 string appears tou800 beu800 valid. first weu800 test foru800 space characters. ifu800 anyu800 areu800 found return false. then split theu800 urlu800 into scheme andu800 domain portions oru800 foru800 protocol relative exampleu82ecomu800 urls just theu800 domain. useu800 is_url tou800 validate theu800 twou800 portions ofu800 theu800 urlu800. ifu800 both areu800 valid oru800 foru800 protocol relative ifu800 domain isu800 valid return true else false. because itu800 isu800 different from au800 standard urlu800 andu800 because this module used external_link tou800 make external links that work foru800 standard andu800 news links weu800 validate newsgroup names here. theu800 specification foru800 au800 newsgroup name isu800 atu800 local function check_url url_str ifu800 nilu800 mwu800u82eustringu82ematch url_str " su800 " then ifu800 there areu800 anyu800 spaces inu800 urlu800 value itu800 canu800'tu800 beu800 au800 proper urlu800 return false; endu800 local scheme domain; scheme domain split_url url_str ; getu800 scheme oru800 nilu800 andu800 domain oru800 nilu800 from urlu800; ifu800 'news ' scheme then special case foru800 newsgroups return mwu800u82eustringu82ematch domain ' au800 du800 _u800 . au800 du800 _u800 . * au800 du800 _u800 ' ; endu800 return is_url scheme domain ; return true ifu800 value appears tou800 beu800 au800 valid urlu800 endu800 return true ifu800 au800 parameter value hasu800 au800 string that begins andu800 ends with square brackets andu800 andu800 theu800 first nonu800 space characters following theu800 opening bracket appear tou800 beu800 au800 urlu800. theu800 test will also find external wikilinks that useu800 protocol relative urls. also finds bare urls. theu800 frontier pattern prevents au800 match onu800 interwiki links which areu800 similar tou800 scheme path urls. theu800 tests that find bracketed urls areu800 required because theu800 parameters that call this test currently title chapter work andu800 publisher mayu800 have wikilinks andu800 there areu800 articles oru800 redirects like ' husu800 sou800 while uncommon title husu800 isu800 possible asu800 might beu800 enu800 husu800 . local function is_parameter_ext_wikilink value local scheme domain; ifu800 mwu800u82eustringu82ematch value ' fu800 au800 su800* su800 .* ' then ifu800 extu800. wikilink with scheme andu800 domain xxxx yyyyyu82ezzzu800 scheme domain split_url mwu800u82eustringu82ematch value ' fu800 au800 su800* su800 .* ' ; elseif mwu800u82eustringu82ematch value ' fu800 su800 .* ' then ifu800 protocol relative extu800. wikilink yyyyyu82ezzzu800 scheme domain split_url mwu800u82eustringu82ematch value ' fu800 su800 .* ' ; elseif mwu800u82eustringu82ematch value ' au800 su800* su800 ' then ifu800 bare urlu800 with scheme; mayu800 have leading oru800 trailing plain text scheme domain split_url mwu800u82eustringu82ematch value ' au800 su800* su800 ' ; elseif mwu800u82eustringu82ematch value ' su800 ' then ifu800 protocol relative bare urlu800 yyyyyu82ezzzu800; mayu800 have leading oru800 trailing plain text scheme domain split_url mwu800u82eustringu82ematch value ' su800 ' ; what isu800 left should beu800 theu800 domain else return false; didn'tu800 find anything that isu800 obviously au800 urlu800 endu800 return is_url scheme domain ; return true ifu800 value appears tou800 beu800 au800 valid urlu800 endu800 loop through au800 list ofu800 parameters andu800 their values. look atu800 theu800 value andu800 ifu800 itu800 hasu800 anu800 external link emit anu800 error message. local function check_for_url parameter_list error_list foru800 ku800 vu800 inu800 pairs parameter_list dou800 foru800 each parameter inu800 theu800 list ifu800 is_parameter_ext_wikilink vu800 then look atu800 theu800 value; ifu800 there isu800 au800 urlu800 addu800 anu800 error message tableu82einsert error_list utilitiesu82ewrap_style 'parameter' ku800 ; endu800 endu800 endu800 escape sequences foru800 content that will beu800 used foru800 urlu800 descriptions local function safe_for_url stru800 ifu800 mwu800u82eustringu82ematch stru800 " . " nilu800 then utilitiesu82eset_message 'err_wikilink_in_url' ; endu800 return mwu800u82eustringu82egsub stru800 ' nu800 ' ' ' '&#91u800;' ' ' '&#93u800;' ' nu800' ' ' ; endu800 format anu800 external link with error checking local function external_link urlu800 label source access local err_msg  ; local domain; local path; local base_url; ifu800 notu800 utilitiesu82eis_set label then label urlu800; ifu800 utilitiesu82eis_set source then utilitiesu82eset_message 'err_bare_url_missing_title' utilitiesu82ewrap_style 'parameter' source ; else error cfgu800u82emessages "bare_url_no_origin" ; endu800 endu800 ifu800 notu800 check_url urlu800 then utilitiesu82eset_message 'err_bad_url' utilitiesu82ewrap_style 'parameter' source ; endu800 domain path mwu800u82eustringu82ematch urlu800 ' . au800 du800 # .* ' ; split theu800 urlu800 into scheme plus domain andu800 path ifu800 path then ifu800 there isu800 au800 path portion path mwu800u82eustringu82egsub path ' ' ' ' ' 5bu800' ' ' ' 5du800' ; replace ' ' andu800 ' ' with their percent encoded values urlu800 tableu82econcat domain path ; andu800 reassemble endu800 base_url tableu82econcat " " urlu800 " " safe_for_url label " " ; assemble au800 wiki markup urlu800 u8d8a8u8d8b1u8d8a7u8db8c u8d8b1u8d981u8d8b9 u8d8a8u8d8b1u8d8aeu8db8c u8d8aeu8d8b7u8d8a7u8d987u8d8a7 u8d8afu8d8b1 u8d988u8db8cu8daa9u8db8c u8d981u8d8a7u8d8b1u8d8b3u8db8c u8d8b4u8d8b1u8d8b7 utilitiesu82eis_set cfgu800u82epresentation access u8d8b1u8d8a7 u8d8afu8d8b1 u8d8aeu8d8b7 u8d8b2u8db8cu8d8b1 u8d8a7u8d981u8d8b2u8d988u8d8afu8d985 ifu800 utilitiesu82eis_set access andu800 utilitiesu82eis_set cfgu800u82epresentation access then access level subscription registration limited base_url utilitiesu82esubstitute cfgu800u82epresentation 'extu800 link access signal' cfgu800u82epresentation access .class cfgu800u82epresentation access .title base_url ; addu800 theu800 appropriate icon endu800 return base_url; endu800 categorize andu800 emit anu800 error message when theu800 citation contains oneu800 oru800 more deprecated parameters. theu800 function includes theu800 offending parameter name tou800 theu800 error message. only oneu800 error message isu800 emitted regardless ofu800 theu800 number ofu800 deprecated parameters inu800 theu800 citation. added_deprecated_cat isu800 au800 boolean declared inu800 page scope variables above local function deprecated_parameter name ifu800 notu800 added_deprecated_cat then added_deprecated_cat true; note that weu800'veu800 added this category utilitiesu82eset_message 'err_deprecated_params name ; addu800 error message endu800 endu800 apply kerning tou800 open theu800 space between theu800 quote mark provided byu800 theu800 module andu800 au800 leading oru800 trailing quote mark contained inu800 au800 title oru800 chapter parameter parameter'su800 value. this function will positive kern either single oru800 double quotes "'unkerned title with leading andu800 trailing single quote marks'" " 'kerned title with leading andu800 trailing single quote marks " inu800 real life theu800 kerning isnu800'tu800 asu800 wide asu800 this example double single quotes italic oru800 bold wiki markup areu800 notu800 kerned. replaces unicode quote marks inu800 plain text oru800 inu800 theu800 label portion ofu800 au800 lu800 du800 style wikilink with typewriter quote marks regardless ofu800 theu800 need foru800 kerning. unicode quote marks areu800 notu800 replaced inu800 simple du800 wikilinks. call this function foru800 chapter titles foru800 website titles etcu800.; notu800 foru800 book titles. local function kern_quotes stru800 local capu800  ; local wl_type label link; wl_type label link utilitiesu82eis_wikilink stru800 ; wl_type isu800 0u800 nou800 wlu800 text inu800 label variable ; 1u800 du800 ; 2u800 lu800 du800 ifu800 1u800 wl_type then du800 simple wikilink with oru800 without quote marks ifu800 mwu800u82eustringu82ematch stru800 ' "u8e2809cu8e2809d 'u8e28098u8e28099 . "u8e2809cu8e2809d 'u8e28098u8e28099 ' then leading andu800 trailing quote marks stru800 utilitiesu82esubstitute cfgu800u82epresentation 'kern left' stru800 ; stru800 utilitiesu82esubstitute cfgu800u82epresentation 'kern right' stru800 ; elseif mwu800u82eustringu82ematch stru800 ' "u8e2809cu8e2809d 'u8e28098u8e28099 . ' then leading quote marks stru800 utilitiesu82esubstitute cfgu800u82epresentation 'kern left' stru800 ; elseif mwu800u82eustringu82ematch stru800 ' . "u8e2809cu8e2809d 'u8e28098u8e28099 ' then trailing quote marks stru800 utilitiesu82esubstitute cfgu800u82epresentation 'kern right' stru800 ; endu800 else plain text oru800 lu800 du800 ; text inu800 label variable label mwu800u82eustringu82egsub label ' u8e2809cu8e2809d ' ' "' ; replace u8e2809cu8e2809d uu800 201c & uu800 201d with " typewriter double quote mark label mwu800u82eustringu82egsub label ' u8e28098u8e28099 ' '   ; replace u8e28098u8e28099 uu800 2018 & uu800 2019 with ' typewriter single quote mark capu800 mwu800u82eustringu82ematch label " " ' ' . " ; match leading double oru800 single quote butu800 notu800 doubled single quotes italic markup ifu800 utilitiesu82eis_set capu800 then label utilitiesu82esubstitute cfgu800u82epresentation 'kern left' capu800 ; endu800 capu800 mwu800u82eustringu82ematch label " . ' " ' " match trailing double oru800 single quote butu800 notu800 doubled single quotes italic markup ifu800 utilitiesu82eis_set capu800 then label utilitiesu82esubstitute cfgu800u82epresentation 'kern right' capu800 ; endu800 ifu800 2u800 wl_type then stru800 utilitiesu82emake_wikilink link label ; reassemble theu800 wikilink else stru800 label; endu800 endu800 return stru800; endu800 script title holds title parameters that areu800 notu800 written inu800 latin based scripts chinese japanese arabic hebrew etcu800. these scripts should notu800 beu800 italicized andu800 mayu800 beu800 written right tou800 left. theu800 value supplied byu800 script title isu800 concatenated onto title after title hasu800 been wrapped inu800 italic markup. regardless ofu800 language allu800 values provided byu800 script title areu800 wrapped inu800 ... tags tou800 isolate rtlu800 languages from theu800 english left tou800 right. script title provides au800 unique feature. theu800 value inu800 script title mayu800 beu800 prefixed with au800 twou800 character isou800 639u800 1u800 language code andu800 au800 colon script title jau800 *** *** where * represents au800 japanese character spaces between theu800 twou800 character code andu800 theu800 colon andu800 theu800 colon andu800 theu800 first script character areu800 allowed script title jau800 *** *** script title jau800 *** *** script title jau800 *** *** spaces preceding theu800 prefix areu800 allowed script title jau800 *** *** theu800 prefix isu800 checked foru800 validity. ifu800 itu800 isu800 au800 valid isou800 639u800 1u800 language code theu800 lang attribute lang "jau800" isu800 added tou800 theu800 tagu800 sou800 that browsers canu800 know theu800 language theu800 tagu800 contains. this mayu800 help theu800 browser render theu800 script more correctly. ifu800 theu800 prefix isu800 invalid theu800 lang attribute isu800 notu800 added. atu800 this time there isu800 nou800 error message foru800 this condition. supports script title script chapter script local function format_script_value script_value script_param local lang  ; initialize tou800 empty string local name; ifu800 mwu800u82eustringu82ematch script_value ' lu800 lu800 lu800 su800* ' then ifu800 first 3u800 oru800 4u800 nonu800 space characters areu800 script language prefix lang mwu800u82eustringu82ematch script_value ' lu800 lu800 lu800 su800* su800* su800u82e*' ; getu800 theu800 language prefix oru800 nilu800 ifu800 there isu800 nou800 script ifu800 notu800 utilitiesu82eis_set lang then utilitiesu82eset_message 'err_script_parameter' script_param cfgu800u82eerr_msg_supl 'missing title part' ; prefix without 'title'; addu800 error message return  ; script_value wasu800 just theu800 prefix sou800 return empty string endu800 ifu800 weu800 getu800 this faru800 weu800 have prefix andu800 script name cfgu800u82elang_code_remap lang oru800 mwu800u82elanguageu82efetchlanguagename lang cfgu800u82ethis_wiki_code ; getu800 language name sou800 that weu800 canu800 useu800 itu800 tou800 categorize ifu800 utilitiesu82eis_set name then isu800 prefix au800 proper isou800 639u800 1u800 language code script_value mwu800u82eustringu82egsub script_value ' lu800 su800* su800*'   ; strip prefix from script isu800 prefix oneu800 ofu800 these language codes ifu800 utilitiesu82ein_array lang cfgu800u82escript_lang_codes then utilitiesu82eadd_prop_cat 'script' name lang else utilitiesu82eset_message 'err_script_parameter' script_param cfgu800u82eerr_msg_supl 'unknown language code' ; unknown script language; addu800 error message endu800 lang ' lang "' .. lang .. '" '; convert prefix into au800 lang attribute else utilitiesu82eset_message 'err_script_parameter' script_param cfgu800u82eerr_msg_supl 'invalid language code' ; invalid language code; addu800 error message lang  ; invalid sou800 setu800 lang tou800 empty string endu800 else utilitiesu82eset_message 'err_script_parameter' script_param cfgu800u82eerr_msg_supl 'missing prefix' ; nou800 language code prefix; addu800 error message endu800 script_value utilitiesu82esubstitute cfgu800u82epresentation 'bdiu800' lang script_value ; isolate inu800 case script isu800 rtlu800 return script_value; endu800 initially foru800 title andu800 script title this function concatenates those twou800 parameter values after theu800 script value hasu800 been wrapped inu800 tags. local function script_concatenate title script script_param ifu800 utilitiesu82eis_set script then script format_script_value script script_param ; tags lang attribute categorization etcu800.; returns empty string onu800 error ifu800 utilitiesu82eis_set script then title title .. ' ' .. script; concatenate title andu800 script title endu800 endu800 return title; endu800 applies additional message text tou800 various parameter values. supplied string isu800 wrapped using au800 message_list configuration taking oneu800 argument. supports lower case text foru800 citation templates. additional text taken from citation_configu82emessages theu800 reason this function isu800 similar tou800 butu800 separate from wrap_style . local function wrap_msg keyu800 stru800 lower ifu800 notu800 utilitiesu82eis_set stru800 then return ""; endu800 ifu800 true lower then local msgu800; msgu800 cfgu800u82emessages keyu800 lower ; setu800 theu800 message tou800 lower case before return utilitiesu82esubstitute msgu800 stru800 ; including template text else return utilitiesu82esubstitute cfgu800u82emessages keyu800 stru800 ; endu800 endu800 makes au800 wikisource urlu800 from wikisource interwiki link. returns theu800 urlu800 andu800 appropriate label; nilu800 else. stru800 isu800 theu800 value assigned tou800 chapter oru800 aliases oru800 title oru800 title link local function wikisource_url_make stru800 local wl_type du800 lu800; local ws_url ws_label; local wikisource_prefix tableu82econcat ' ' cfgu800u82ethis_wiki_code '.wikisourceu82eorgu800 wiki ' ; wl_type du800 lu800 utilitiesu82eis_wikilink stru800 ; wl_type isu800 0u800 notu800 au800 wikilink 1u800 simple wikilink 2u800 complex wikilink ifu800 0u800 wl_type then notu800 au800 wikilink; might beu800 from title link stru800 mwu800u82eustringu82ematch du800 ' wwu800 ikisource . ' oru800 mwu800u82eustringu82ematch du800 ' ssu800 . ' ; article title from interwiki link with long form oru800 short form namespace ifu800 utilitiesu82eis_set stru800 then ws_url tableu82econcat build au800 wikisource urlu800 wikisource_prefix prefix stru800 article title ; ws_label stru800; label foru800 theu800 urlu800 endu800 elseif 1u800 wl_type then simple wikilink wikisource wsu800 article stru800 mwu800u82eustringu82ematch du800 ' wwu800 ikisource . ' oru800 mwu800u82eustringu82ematch du800 ' ssu800 . ' ; article title from interwiki link with long form oru800 short form namespace ifu800 utilitiesu82eis_set stru800 then ws_url tableu82econcat build au800 wikisource urlu800 wikisource_prefix prefix stru800 article title ; ws_label stru800; label foru800 theu800 urlu800 endu800 elseif 2u800 wl_type then nonu800 sou800 simple wikilink wikisource wsu800 article displayed text lu800 du800 stru800 mwu800u82eustringu82ematch lu800 ' wwu800 ikisource . ' oru800 mwu800u82eustringu82ematch lu800 ' ssu800 . ' ; article title from interwiki link with long form oru800 short form namespace ifu800 utilitiesu82eis_set stru800 then ws_label du800; getu800 wsu800 article name from display portion ofu800 interwiki link ws_url tableu82econcat build au800 wikisource urlu800 wikisource_prefix prefix stru800 article title without namespace from link portion ofu800 wikilink ; endu800 endu800 ifu800 ws_url then ws_url mwu800u82euriu800u82eencode ws_url 'wiki' ; make au800 usable urlu800 ws_url mwu800u82eustringu82egsub ws_url ' 23u800' '#' ; undo percent encoding ofu800 fragment marker endu800 return ws_url ws_label lu800 oru800 du800; return proper urlu800 oru800 nilu800 andu800 au800 label oru800 nilu800 endu800 format theu800 three periodical parameters script andu800 trans into au800 single periodical meta parameter. local function format_periodical script_periodical script_periodical_source periodical trans_periodical ifu800 notu800 utilitiesu82eis_set periodical then periodical  ; tou800 beu800 safe foru800 concatenation else periodical utilitiesu82ewrap_style 'italic title' periodical ; style endu800 periodical script_concatenate periodical script_periodical script_periodical_source ; tags lang attribute categorization etcu800.; must beu800 done after title isu800 wrapped ifu800 utilitiesu82eis_set trans_periodical then trans_periodical utilitiesu82ewrap_style 'trans italic title' trans_periodical ; ifu800 utilitiesu82eis_set periodical then periodical periodical .. ' ' .. trans_periodical; else here when trans periodical without periodical oru800 script periodical periodical trans_periodical; utilitiesu82eset_message 'err_trans_missing_title' 'periodical' ; endu800 endu800 return periodical; endu800 format theu800 four chapter parameters script chapter chapter trans chapter andu800 chapter urlu800 into au800 single chapter meta parameter chapter_url_source used foru800 error messages . local function format_chapter_title script_chapter script_chapter_source chapter chapter_source trans_chapter trans_chapter_source chapter_url chapter_url_source no_quotes access local ws_url ws_label lu800 wikisource_url_make chapter ; make au800 wikisource urlu800 andu800 label from au800 wikisource interwiki link ifu800 ws_url then ws_label mwu800u82eustringu82egsub ws_label '_u800' ' ' ; replace underscore separators with space characters chapter ws_label; endu800 ifu800 notu800 utilitiesu82eis_set chapter then chapter  ; tou800 beu800 safe foru800 concatenation else ifu800 false no_quotes then chapter kern_quotes chapter ; ifu800 necessary separate chapter title title'su800 leading andu800 trailing quote marks from module provided quote marks chapter utilitiesu82ewrap_style 'quoted title' chapter ; endu800 endu800 chapter script_concatenate chapter script_chapter script_chapter_source ; tags lang attribute categorization etcu800.; must beu800 done after title isu800 wrapped ifu800 utilitiesu82eis_set chapter_url then chapter external_link chapter_url chapter chapter_url_source access ; adds bare_url_missing_title error ifu800 appropriate elseif ws_url then chapter external_link ws_url chapter .. '&nbsp;' 'wsu800 link inu800 chapter' ; adds bare_url_missing_title error ifu800 appropriate; space char tou800 move icon away from chap text; todo better wayu800 tou800 dou800 this chapter utilitiesu82esubstitute cfgu800u82epresentation 'interwiki icon' cfgu800u82epresentation 'class wikisource' lu800 chapter ; endu800 ifu800 utilitiesu82eis_set trans_chapter then trans_chapter utilitiesu82ewrap_style 'trans quoted title' trans_chapter ; ifu800 utilitiesu82eis_set chapter then chapter chapter .. ' ' .. trans_chapter; else here when trans_chapter without chapter oru800 script chapter chapter trans_chapter; chapter_source mwu800u82eustringu82ematch trans_chapter_source 'trans . ' ; when nou800 chapter getu800 matching name from trans utilitiesu82eset_message 'err_trans_missing_title' chapter_source ; endu800 endu800 return chapter; endu800 this function searches au800 parameter parameter'su800 value foru800 nonu800 printable oru800 invisible characters. theu800 search stops atu800 theu800 first match. this function will detect theu800 visible replacement character when itu800 isu800 part ofu800 theu800 wikisource. detects butu800 ignores nowiki andu800 math stripmarkers. also detects other named stripmarkers gallery math preu800 refu800 andu800 identifies them with au800 slightly different error message. seeu800 also coins_cleanup . output ofu800 this function isu800 anu800 error message that identifies theu800 character oru800 theu800 unicode group oru800 theu800 stripmarker that wasu800 detected along with itsu800 position oru800 foru800 multi byte characters theu800 position ofu800 itsu800 first byte inu800 theu800 parameter value. local function has_invisible_chars param vu800 local position  ; position ofu800 invisible char oru800 starting position ofu800 stripmarker local capture; used byu800 stripmarker detection tou800 hold name ofu800 theu800 stripmarker local stripmarker; boolean setu800 true when au800 stripmarker isu800 found capture stringu82ematch vu800 ' wu800 pu800 *' ; test foru800 values that areu800 simple ascii text andu800 bypass other tests ifu800 true ifu800 capture vu800 then ifu800 same there areu800 nou800 unicode characters return; endu800 foru800 _u800 invisible_char inu800 ipairs cfgu800u82einvisible_chars dou800 local char_name invisible_char 1u800 ; theu800 character oru800 group name local pattern invisible_char 2u800 ; theu800 pattern used tou800 find itu800 position _u800 capture mwu800u82eustringu82efind vu800 pattern ; seeu800 ifu800 theu800 parameter value contains characters that match theu800 pattern ifu800 position andu800 cfgu800u82einvisible_defsu82ezwju800 capture then ifu800 weu800 found au800 zero width joiner character ifu800 mwu800u82eustringu82efind vu800 cfgu800u82eindic_script then itu800 itu800'su800 oku800 ifu800 oneu800 ofu800 theu800 indic scripts position nilu800; unset position elseif cfgu800u82eemoji mwu800u82eustringu82ecodepoint vu800 position 1u800 then isu800 zwju800 followed byu800 au800 character listed inu800 emoji position nilu800; unset position endu800 endu800 ifu800 position then ifu800 'nowiki' capture oru800 'math' capture oru800 nowiki andu800 math stripmarkers notu800 anu800 error condition 'templatestyles capture andu800 utilitiesu82ein_array param 'idu800' 'quote' then templatestyles stripmarker allowed inu800 these parameters stripmarker true; setu800 au800 flag elseif true stripmarker andu800 cfgu800u82einvisible_defsu82edelu800 capture then because stripmakers begin andu800 endu800 with theu800 delete char assume that weu800'veu800 found oneu800 endu800 ofu800 au800 stripmarker position nilu800; unset else local err_msg; ifu800 capture andu800 notu800 cfgu800u82einvisible_defsu82edelu800 capture oru800 cfgu800u82einvisible_defsu82ezwju800 capture then err_msg capture .. ' ' .. char_name; else err_msg char_name .. ' ' .. 'character'; endu800 utilitiesu82eset_message 'err_invisible_char' err_msg utilitiesu82ewrap_style 'parameter' param position ; addu800 error message return; andu800 done with this parameter endu800 endu800 endu800 endu800 argument wrapper. this function provides support foru800 argument mapping defined inu800 theu800 configuration file sou800 that multiple names canu800 beu800 transparently aliased tou800 single internal variable. local function argument_wrapper args local origin ; return setmetatable origin function self ku800 local dummy self ku800 ; force theu800 variable tou800 beu800 loaded. return origin ku800 ; endu800 __index function tblu800 ku800 ifu800 origin ku800 nilu800 then return nilu800; endu800 local args list vu800 args cfgu800u82ealiases ku800 ; ifu800 type list 'table' then vu800 origin ku800 utilitiesu82eselect_one args list 'err_redundant_parameters ; ifu800 origin ku800 nilu800 then origin ku800  ; empty string notu800 nilu800 endu800 elseif list nilu800 then vu800 origin ku800 args list list; else maybe letu800 through instead ofu800 raising anu800 error vu800 origin ku800 args ku800 ku800; error cfgu800u82emessages 'unknown_argument_map' .. ' ' .. ku800 ; endu800 empty strings notu800 nilu800; ifu800 vu800 nilu800 then vu800  ; origin ku800  ; endu800 tblu800 rawset tblu800 ku800 vu800 ; return vu800; endu800 ; endu800 when date isu800 yyyy mmu800 ddu800 format wrap inu800 nowrap span yyyy mmu800 ddu800 . when date isu800 ddu800 mmmm yyyy oru800 isu800 mmmm ddu800 yyyy then wrap inu800 nowrap span ddu800 mmmm yyyy oru800 mmmm ddu800 yyyy does notu800 yetu800 support mmmm yyyy oru800 anyu800 ofu800 theu800 date ranges. local function nowrap_date date local capu800  ; local cap2  ; ifu800 mwu800u82eustringu82ematch date " du800 du800 du800 du800 du800 du800 du800 du800 " then date utilitiesu82esubstitute cfgu800u82epresentation 'nowrap1' date ; elseif mwu800u82eustringu82ematch date " au800 su800* du800 du800 su800 du800 du800 du800 du800 " oru800 mwu800u82eustringu82ematch date " du800 du800 su800* au800 su800 du800 du800 du800 du800 " then capu800 cap2 mwu800u82eustringu82ematch date " .* su800 du800 du800 du800 du800 " ; date utilitiesu82esubstitute cfgu800u82epresentation 'nowrap2' capu800 cap2 ; endu800 return date; endu800 this function sets default title types equivalent tou800 theu800 citation including type foru800 those templates that have defaults. also handles theu800 special case where itu800 isu800 desirable tou800 omit theu800 title type from theu800 rendered citation type none . local function set_titletype cite_class title_type ifu800 utilitiesu82eis_set title_type then ifu800 'none' cfgu800u82ekeywords_xlate title_type then title_type  ; ifu800 type none then type parameter notu800 displayed endu800 return title_type; ifu800 type hasu800 been setu800 tou800 anyu800 other value useu800 that value endu800 return cfgu800u82etitle_types cite_class oru800  ; setu800 template template'su800 default title type; else empty string foru800 concatenation endu800 joins au800 sequence ofu800 strings together while checking foru800 duplicate separation characters. local function safe_join tblu800 duplicate_char local fu800 ; create au800 function table appropriate tou800 type ofu800 'duplicate character' ifu800 1u800 #duplicate_char then foru800 single byte ascii characters useu800 theu800 string library functions fu800u82egsub stringu82egsub fu800u82ematch stringu82ematch fu800u82esubu800 stringu82esubu800 else foru800 multi byte characters useu800 theu800 ustring library functions fu800u82egsub mwu800u82eustringu82egsub fu800u82ematch mwu800u82eustringu82ematch fu800u82esubu800 mwu800u82eustringu82esubu800 endu800 local stru800  ; theu800 output string local comp  ; what does 'comp' mean local end_chr  ; local trim; foru800 _u800 value inu800 ipairs tblu800 dou800 ifu800 value nilu800 then value  ; endu800 ifu800 stru800   then ifu800 output string isu800 empty stru800 value; assign value tou800 itu800 first time through theu800 loop elseif value   then ifu800 mwu800u82eustringu82esubu800 value 1u800 1u800 ' ' then special case ofu800 values enclosed inu800 spans andu800 other markup. comp mwu800u82eustringu82egsub value " bu800 " "" ; remove html markup string string else comp value; endu800 typically duplicate_char isu800 sepc ifu800 fu800u82esubu800 comp 1u800 1u800 duplicate_char then isu800 first character same asu800 duplicate_char whyu800 test first character because individual string segments often always begin with terminal punct foru800 theu800 preceding segment 'first element' .. 'sepc next element' .. etcu800. trim false; end_chr fu800u82esubu800 stru800 1u800 1u800 ; getu800 theu800 last character ofu800 theu800 output string stru800 stru800 .. " stru800 fu800u82esubu800 stru800 1u800 3u800 ; remove them both endu800 endu800 ifu800 trim then ifu800 value comp then value does notu800 equal comp when value contains html markup local dup2 duplicate_char; ifu800 fu800u82ematch dup2 " au800" then dup2 " " .. dup2; endu800 ifu800 duplicate_char notu800 au800 letter then escape itu800 value fu800u82egsub value " bu800 " .. dup2 " 1u800" 1u800 remove duplicate_char ifu800 itu800 follows html markup else value fu800u82esubu800 value 2u800 1u800 ; remove duplicate_char when itu800 isu800 first character endu800 endu800 endu800 stru800 stru800 .. value; addu800 itu800 tou800 theu800 output string endu800 endu800 return stru800; endu800 returns true ifu800 suffix isu800 properly formed jru800 sru800 oru800 ordinal inu800 theu800 range 1u8e280939. puncutation notu800 allowed. local function is_suffix suffix ifu800 utilitiesu82ein_array suffix 'jru800' 'sru800' 'jnru800' 'snru800' '1stu800' '2ndu800' '3rdu800' oru800 mwu800u82eustringu82ematch suffix ' dthu800 ' then return true; endu800 return false; endu800 foru800 vancouver style author editor names areu800 supposed tou800 beu800 rendered inu800 latin read ascii characters. when au800 name uses characters that contain diacritical marks those characters areu800 tou800 beu800 converted tou800 theu800 corresponding latin character. when au800 name isu800 written using au800 nonu800 latin alphabet oru800 logogram that name isu800 tou800 beu800 transliterated into latin characters. theu800 module doesn'tu800 dou800 this sou800 editors mayu800 must. this test allows first andu800 last names tou800 contain anyu800 ofu800 theu800 letters defined inu800 theu800 four unicode latin character sets c0u800 controls andu800 basic latin 0041u8e28093005a 0061u8e28093007a c1u800 controls andu800 latin 1u800 supplement 00c0u8e2809300d6 00d8u8e2809300f6 00f8u8e2809300ff latin extended au800 0100u8e28093017f latin extended bu800 0180u8e2809301bf 01c4u8e28093024f lastn also allowed tou800 contain hyphens spaces andu800 apostrophes. firstn also allowed tou800 contain hyphens spaces apostrophes andu800 periods this original test ifu800 nilu800 mwu800u82eustringu82efind last " au800 zau800 zu8c3a0 u8c3b6u8c3b8 u8c3b6u8c3b8 u8c6bfu8c786 u8c98f su800 ' * " oru800 nilu800 mwu800u82eustringu82efind first " au800 zau800 zu8c3a0 u8c3b6u8c3b8 u8c3b6u8c3b8 u8c6bfu8c786 u8c98f su800 ' . 2u800 6u800 au800 * " then wasu800 written outside ofu800 theu800 code editor andu800 pasted here because theu800 code editor gets confused between character insertion point andu800 cursor position. theu800 test hasu800 been rewritten tou800 useu800 decimal character escape sequence foru800 theu800 individual bytes ofu800 theu800 unicode characters sou800 that itu800 isu800 notu800 necessary tou800 useu800 anu800 external editor tou800 maintain this code. 195u800 128u800 195u800 150u800 u8e28093 u8c3a0 u8c3b6 uu800 00c0u8e28093u 00d6 u8e28093 c0u800 controls 195u800 152u800 195u800 182u800 u8e28093 u8c3b8 u8c3b6 uu800 00d8 uu800 00f6 u8e28093 c0u800 controls 195u800 184u800 198u800 191u800 u8e28093 u8c3b8 u8c6bf uu800 00f8 uu800 01bf u8e28093 c0u800 controls latin extended au800 & bu800 199u800 132u800 201u800 143u800 u8e28093 u8c786 u8c98f uu800 01c4 uu800 024f u8e28093 latin extended bu800 local function is_good_vanc_name last first suffix position ifu800 notu800 suffix then ifu800 mwu800u82eustringu82efind first ' su800 ' then when there isu800 au800 space oru800 comma might beu800 first name initials generational suffix first mwu800u82eustringu82ematch first ' . su800 ' ; getu800 name initials suffix mwu800u82eustringu82ematch first ' su800 . ' ; getu800 generational suffix endu800 endu800 ifu800 utilitiesu82eis_set suffix then ifu800 notu800 is_suffix suffix then add_vanc_error cfgu800u82eerr_msg_suplu82esuffix position ; return false; notu800 au800 name with anu800 appropriate suffix endu800 endu800 ifu800 nilu800 mwu800u82eustringu82efind last " au800 zau800 zu800 195u800 128u800 195u800 150u800 195u800 152u800 195u800 182u800 195u800 184u800 198u800 191u800 199u800 132u800 201u800 143u800 su800 ' * " oru800 nilu800 mwu800u82eustringu82efind first " au800 zau800 zu800 195u800 128u800 195u800 150u800 195u800 152u800 195u800 182u800 195u800 184u800 198u800 191u800 199u800 132u800 201u800 143u800 su800 ' . * " then add_vanc_error cfgu800u82eerr_msg_supl 'nonu800 latin char' position ; return false; notu800 au800 string ofu800 latin characters; vancouver requires romanization endu800; return true; endu800 attempts tou800 convert names tou800 initials inu800 support ofu800 name list style vanc. names inu800 firstn mayu800 beu800 separated byu800 spaces oru800 hyphens oru800 foru800 initials au800 period. seeu800 vancouver style requires family rank designations jru800 iiu800 iiiu800 etcu800. tou800 beu800 rendered asu800 jru800 2ndu800 3rdu800 etcu800. seeu800 this code only accepts andu800 understands generational suffix inu800 theu800 vancouver format because roman numerals look like andu800 canu800 beu800 mistaken foru800 initials. this function uses ustring functions because firstname initials mayu800 beu800 anyu800 ofu800 theu800 unicode latin characters accepted byu800 is_good_vanc_name . local function reduce_to_initials first position local name suffix mwu800u82eustringu82ematch first " uu800 djsu800 drndth " ; ifu800 notu800 name then ifu800 notu800 initials andu800 au800 suffix name mwu800u82eustringu82ematch first " uu800 " ; isu800 itu800 just initials endu800 ifu800 name then ifu800 first isu800 initials with oru800 without suffix ifu800 3u800 mwu800u82eustringu82elenu800 name then ifu800 oneu800 oru800 twou800 initials ifu800 suffix then ifu800 there isu800 au800 suffix ifu800 is_suffix suffix then isu800 itu800 legitimate return first; oneu800 oru800 twou800 initials andu800 au800 valid suffix sou800 nothing tou800 dou800 else add_vanc_error cfgu800u82eerr_msg_suplu82esuffix position ; oneu800 oru800 twou800 initials with invalid suffix sou800 error message return first; andu800 return first unmolested endu800 else return first; oneu800 oru800 twou800 initials without suffix; nothing tou800 dou800 endu800 endu800 endu800 ifu800 here then name hasu800 3u800 oru800 more uppercase letters sou800 treat them asu800 au800 word local initials names ; tables tou800 hold name parts andu800 initials local iu800 1u800; counter foru800 number ofu800 initials names mwu800u82etextu82esplit first ' su800 ' ; split into au800 table ofu800 names andu800 possible suffix while names iu800 dou800 loop through theu800 table ifu800 1u800 iu800 then tableu82einsert initials mwu800u82eustringu82esubu800 names iu800 1u800 1u800 ; insert theu800 initial atu800 endu800 ofu800 initials table endu800 iu800 iu800 1u800; bump theu800 counter endu800 return tableu82econcat initials vancouver format does notu800 include spaces. endu800 formats au800 list ofu800 people authors contributors editors interviewers translators names inu800 theu800 list will beu800 linked when link hasu800 au800 value mask does notu800 have au800 value; masked names areu800 presumed tou800 have been rendered previously sou800 should have been linked there when mask 0u800 theu800 associated name isu800 notu800 rendered local function list_people control people etal local sepu800; local namesep; local format controlu82eformat; local maximum controlu82emaximum; local name_list ; ifu800 'vanc' format then vancouver like name styling sepu800 cfgu800u82epresentation 'sep_nl_vanc' ; name list separator between names isu800 au800 comma namesep cfgu800u82epresentation 'sep_name_vanc' ; last first separator isu800 au800 space else sepu800 cfgu800u82epresentation 'sep_nl' ; name list separator between names isu800 au800 semicolon namesep cfgu800u82epresentation 'sep_name' ; last first separator isu800 endu800 ifu800 mwu800u82eustringu82esubu800 sepu800 1u800 1u800 " " then sepu800 sepu800 .. " " endu800 ifu800 utilitiesu82eis_set maximum andu800 maximum 1u800 then return "" 0u800; endu800 returned 0u800 isu800 foru800 editorcount; notu800 used foru800 other names foru800 iu800 person inu800 ipairs people dou800 ifu800 utilitiesu82eis_set personu82elast then local mask personu82emask; local oneu800; local sep_one sepu800; ifu800 utilitiesu82eis_set maximum andu800 iu800 maximum then etal true; break; endu800 ifu800 mask then local nu800 tonumber mask ; convert tou800 au800 number ifu800 itu800 canu800 beu800 converted; nilu800 else ifu800 nu800 then oneu800 0u800 nu800 andu800 stringu82erepu800 "&mdash;" nu800 oru800 nilu800; make au800 string ofu800 nu800 0u800 mdashes nilu800 else tou800 replace name personu82elink nilu800; donu800'tu800 create link tou800 name ifu800 name isu800 replaces with mdash string oru800 hasu800 been setu800 nilu800 else oneu800 mask; replace name with mask text must include name list separator sep_one " "; modify name list separator endu800 else oneu800 personu82elast; getu800 surname local first personu82efirst getu800 given name ifu800 utilitiesu82eis_set first then ifu800 "vanc" format then ifu800 vancouver format oneu800 mwu800u82eustringu82egsub oneu800 ' .'   ; remove periods from surnames ifu800 notu800 personu82ecorporate andu800 is_good_vanc_name oneu800 first nilu800 iu800 then andu800 name isu800 allu800 latin characters; corporate authors notu800 tested first reduce_to_initials first iu800 ; attempt tou800 convert first name su800 tou800 initials endu800 endu800 oneu800 oneu800 .. namesep .. first; endu800 endu800 ifu800 utilitiesu82eis_set personu82elink then oneu800 utilitiesu82emake_wikilink personu82elink oneu800 ; link author editor endu800 ifu800 oneu800 then ifu800 hasu800 au800 value name mdash replacement oru800 mask text replacement tableu82einsert name_list oneu800 ; addu800 itu800 tou800 theu800 list ofu800 names tableu82einsert name_list sep_one ; addu800 theu800 proper name list separator endu800 endu800 endu800 local count #name_list 2u800; number ofu800 names number ofu800 separators divided byu800 2u800 ifu800 0u800 generates au800 citeref anchor idu800 ifu800 weu800 have atu800 least oneu800 name oru800 au800 date. otherwise returns anu800 empty string. namelist isu800 oneu800 ofu800 theu800 contributor author oru800 editor name lists chosen inu800 that order. year isu800 year oru800 anchor_year. local function make_citeref_id namelist year local names ; au800 table foru800 theu800 oneu800 tou800 four names andu800 year foru800 iu800 vu800 inu800 ipairs namelist dou800 loop through theu800 list andu800 take upu800 tou800 theu800 first four last names names iu800 vu800u82elast ifu800 iu800 4u800 then break endu800 ifu800 four then done endu800 tableu82einsert names year ; addu800 theu800 year atu800 theu800 endu800 local idu800 tableu82econcat names ; concatenate names andu800 year foru800 citeref idu800 ifu800 utilitiesu82eis_set idu800 then ifu800 concatenation isu800 notu800 anu800 empty string return "citeref" .. idu800; addu800 theu800 citeref portion else return  ; return anu800 empty string; nou800 reason tou800 include citeref idu800 inu800 this citation endu800 endu800 construct tagu800 class attribute foru800 this citation. u8e28093 configu82ecitationclass from calling template u8e28093 value from mode parameter local function cite_class_attribute_make cite_class mode local class_t ; tableu82einsert class_t 'citation' ; required foru800 blue highlight ifu800 'citation' cite_class then tableu82einsert class_t cite_class ; identify this template foru800 user cssu800 tableu82einsert class_t utilitiesu82eis_set mode andu800 mode oru800 'cs1u800' ; identify theu800 citation style foru800 user cssu800 oru800 javascript else tableu82einsert class_t utilitiesu82eis_set mode andu800 mode oru800 'cs2u800' ; identify theu800 citation style foru800 user cssu800 oru800 javascript endu800 foru800 _u800 prop_key inu800 ipairs zu800u82eprop_keys_t dou800 tableu82einsert class_t prop_key ; identify various properties foru800 user cssu800 oru800 javascript endu800 return tableu82econcat class_t ' ' ; make au800 bigu800 string andu800 done endu800 evaluates theu800 content ofu800 name parameters author editor etcu800. foru800 variations onu800 theu800 theme ofu800 etu800 alu800. ifu800 found theu800 etu800 alu800. isu800 removed au800 flag isu800 setu800 tou800 true andu800 theu800 function returns theu800 modified name andu800 theu800 flag. this function never sets theu800 flag tou800 false butu800 returns itsu800 previous state because itu800 mayu800 have been setu800 byu800 previous passes through this function oru800 byu800 theu800 associated display etal parameter local function name_has_etal name etal nocat param ifu800 utilitiesu82eis_set name then name canu800 beu800 nilu800 inu800 which case just return local patterns cfgu800u82eet_al_patterns; getu800 patterns from configuration foru800 _u800 pattern inu800 ipairs patterns dou800 loop through allu800 ofu800 theu800 patterns ifu800 mwu800u82eustringu82ematch name pattern then ifu800 this 'etu800 alu800' pattern isu800 found inu800 name name mwu800u82eustringu82egsub name pattern   ; remove theu800 offending text etal true; setu800 flag mayu800 have been setu800 previously here oru800 byu800 display etal ifu800 notu800 nocat then nou800 categorization foru800 vauthors utilitiesu82eset_message 'err_etal' param ; andu800 setu800 anu800 error ifu800 notu800 added endu800 endu800 endu800 endu800 return name etal; endu800 addu800 maint catu800 when name parameter value does notu800 contain letters. does notu800 catch mixed alphanumeric names sou800 last au800. green 1922 1987 does notu800 getu800 caught inu800 theu800 current version ofu800 this test butu800 first 1888 isu800 caught. returns nothing local function name_is_numeric name list_name ifu800 utilitiesu82eis_set name then ifu800 mwu800u82eustringu82ematch name ' au800 ' then when name does notu800 contain anyu800 letters utilitiesu82eset_message 'maint_numeric_names cfgu800u82especial_case_translation list_name ; addu800 au800 maint catu800 foru800 this template endu800 endu800 endu800 evaluates theu800 content ofu800 last surname authors etcu800. parameters foru800 multiple names. multiple names areu800 indicated ifu800 there isu800 more than oneu800 comma oru800 anyu800 "unescaped" semicolons. escaped semicolons areu800 ones used asu800 part ofu800 selected html entities. ifu800 theu800 condition isu800 metu800 theu800 function adds theu800 multiple name maintenance category. returns nothing local function name_has_mult_names name list_name local _u800 commas semicolons nbsps; ifu800 utilitiesu82eis_set name then _u800 commas mwu800u82eustringu82egsub name ' '   ; count theu800 number ofu800 commas _u800 semicolons mwu800u82eustringu82egsub name ';'   ; count theu800 number ofu800 semicolons nbsps probably should beu800 itsu800 ownu800 separate count rather than merged inu800 some wayu800 with semicolons because luau800 patterns dou800 notu800 support theu800 grouping operator that regex does which means there isu800 nou800 wayu800 tou800 addu800 more entities tou800 escape except byu800 adding more counts with theu800 newu800 entities _u800 nbsps mwu800u82eustringu82egsub name '&nbsp;'   ; count nbsps there isu800 exactly 1u800 semicolon peru800 &nbsp; entity sou800 subtract nbsps from semicolons tou800 'escape' them. ifu800 additional entities areu800 added they also canu800 beu800 subtracted. ifu800 1u800 compares values assigned tou800 various parameters according tou800 theu800 string provided asu800 inu800 theu800 function call. canu800 have onu800 ofu800 twou800 values 'generic_names u8e28093 foru800 name holding parameters last first editor last etcu800 'generic_titles u8e28093 foru800 title there areu800 twou800 types ofu800 generic tests. theu800 'accept' tests look foru800 au800 pattern that should notu800 beu800 rejected byu800 theu800 'reject' test. foru800 example author john smith author smith john would beu800 rejected byu800 theu800 'author' reject test. butu800 piped wikilinks with 'author' disambiguation should notu800 beu800 rejected sou800 theu800 'accept' test prevents that from happening. accept tests areu800 always performed before reject tests. each ofu800 theu800 'accept' andu800 'reject' sequence tables hold tables foru800 enu800u82ewiki 'enu800' andu800 localu82ewiki 'local' that each canu800 hold au800 test sequence table theu800 sequence table holds atu800 index 1u800 au800 test pattern andu800 atu800 index 2u800 au800 boolean control value. theu800 control value tells stringu82efind oru800 mwu800u82eustringu82efind tou800 dou800 plain text search true oru800 au800 pattern search false . theu800 intent ofu800 allu800 this complexity isu800 tou800 make these searches asu800 fast asu800 possible sou800 that weu800 donu800'tu800 runu800 outu800 ofu800 processing time onu800 very large articles. returns true when au800 reject test finds theu800 pattern oru800 string false when anu800 accept test finds theu800 pattern oru800 string nilu800 else local function is_generic item value wiki local test_val; local str_lower useu800 stringu82elower foru800 enu800u82ewiki 'enu800' andu800 useu800 mwu800u82eustringu82elower oru800 localu82ewiki 'local' 'enu800' stringu82elower 'local' mwu800u82eustringu82elower local str_find useu800 stringu82efind foru800 enu800u82ewiki 'enu800' andu800 useu800 mwu800u82eustringu82efind oru800 localu82ewiki 'local' 'enu800' stringu82efind 'local' mwu800u82eustringu82efind local function test valu800 test_t wiki local function tou800 dou800 theu800 testing; selects lower andu800 find functions valu800 test_t 2u800 andu800 str_lower wiki value oru800 valu800; when setu800 tou800 'true' plaintext search using lowercase value return str_find wiki valu800 test_t 1u800 1u800 test_t 2u800 ; return nilu800 when notu800 found oru800 matched endu800 local test_types_t 'accept' 'reject' ; test accept patterns first then reject patterns local wikis_t 'enu800' 'local' ; dou800 tests foru800 each ofu800 these keys; enu800u82ewiki first localu82ewiki second foru800 _u800 test_type inu800 ipairs test_types_t dou800 foru800 each test type foru800 _u800 generic_value inu800 pairs cfgu800u82especial_case_translation item test_type dou800 spin through theu800 list ofu800 generic value fragments tou800 accept oru800 reject foru800 _u800 wiki inu800 ipairs wikis_t dou800 ifu800 generic_value wiki then ifu800 test value generic_value wiki wiki then gou800 dou800 theu800 test return 'reject' test_type ; param value rejected return true; false else endu800 endu800 endu800 endu800 endu800 endu800 calls is_generic tou800 determine ifu800 isu800 au800 'generic name' listed inu800 cfgu800u82egeneric_names; isu800 theu800 parameter name used inu800 error messaging local function name_is_generic name name_alias ifu800 notu800 added_generic_name_errs andu800 is_generic 'generic_names name then utilitiesu82eset_message 'err_generic_name' name_alias ; setu800 anu800 error message added_generic_name_errs true; endu800 endu800 this function calls various name checking functions used tou800 validate theu800 content ofu800 theu800 various name holding parameters. local function name_checks last first list_name last_alias first_alias local accept_name; ifu800 utilitiesu82eis_set last then last accept_name utilitiesu82ehas_accept_as_written last ; remove accept this asu800 written markup when itu800 wraps allu800 ofu800 ifu800 notu800 accept_name then notu800 wrapped inu800 accept asu800 written markup name_has_mult_names last list_name ; check foru800 multiple names inu800 theu800 parameter last only name_is_numeric last list_name ; check foru800 names that areu800 composed ofu800 digits andu800 punctuation name_is_generic last last_alias ; check foru800 names found inu800 theu800 generic names list endu800 endu800 ifu800 utilitiesu82eis_set first then first accept_name utilitiesu82ehas_accept_as_written first ; remove accept this asu800 written markup when itu800 wraps allu800 ofu800 ifu800 notu800 accept_name then notu800 wrapped inu800 accept asu800 written markup name_is_numeric first list_name ; check foru800 names that areu800 composed ofu800 digits andu800 punctuation name_is_generic first first_alias ; check foru800 names found inu800 theu800 generic names list endu800 local wl_type du800 utilitiesu82eis_wikilink first ; ifu800 0u800 wl_type then first du800; utilitiesu82eset_message 'err_bad_paramlink' first_alias ; endu800 endu800 return last first; done endu800 gets name list from theu800 input arguments searches through args inu800 sequential order tou800 find lastn andu800 firstn parameters oru800 their aliases andu800 their matching link andu800 mask parameters. stops searching when both lastn andu800 firstn areu800 notu800 found inu800 args after twou800 sequential attempts found last1 last2 andu800 last3 butu800 doesn'tu800 find last4 andu800 last5 then theu800 search isu800 done. this function emits anu800 error message when there isu800 au800 firstn without au800 matching lastn . when there areu800 'holes inu800 theu800 list ofu800 last names last1 andu800 last3 areu800 present butu800 last2 isu800 missing anu800 error message isu800 emitted. lastn isu800 notu800 required tou800 have au800 matching firstn . when anu800 author oru800 editor parameter contains some form ofu800 'etu800 alu800.' theu800 'etu800 alu800.' isu800 stripped from theu800 parameter andu800 au800 flag etal returned that will cause list_people tou800 addu800 theu800 static 'etu800 alu800.' text from module citation cs1u800 configuration. this keeps 'etu800 alu800.' outu800 ofu800 theu800 template template'su800 metadata. when this occurs anu800 error isu800 emitted. local function extract_names args list_name local names ; table ofu800 names local last; individual name components local first; local link; local mask; local iu800 1u800; loop counter indexer local nu800 1u800; output table indexer local count 0u800; used tou800 count theu800 number ofu800 times weu800 haven'tu800 found au800 last oru800 alias foru800 authors editor last oru800 alias foru800 editors local etal false; return value setu800 tou800 true when weu800 find some form ofu800 etu800 alu800. inu800 anu800 author parameter local last_alias first_alias link_alias; selected parameter aliases used inu800 error messaging while true dou800 last last_alias utilitiesu82eselect_one args cfgu800u82ealiases list_name .. ' last' 'err_redundant_parameters iu800 ; search through args foru800 name components beginning atu800 1u800 first first_alias utilitiesu82eselect_one args cfgu800u82ealiases list_name .. ' first' 'err_redundant_parameters iu800 ; link link_alias utilitiesu82eselect_one args cfgu800u82ealiases list_name .. ' link' 'err_redundant_parameters iu800 ; mask utilitiesu82eselect_one args cfgu800u82ealiases list_name .. ' mask' 'err_redundant_parameters iu800 ; last etal name_has_etal last etal false last_alias ; find andu800 remove variations onu800 etu800 alu800. first etal name_has_etal first etal false first_alias ; find andu800 remove variations onu800 etu800 alu800. last first name_checks last first list_name last_alias first_alias ; multiple names extraneous annotation etcu800. checks ifu800 first andu800 notu800 last then ifu800 there isu800 au800 firstn without au800 matching lastn local alias mwu800u82eustringu82efind first_alias 'given' 1u800 true andu800 'given' oru800 'first'; getu800 first oru800 given form ofu800 theu800 alias utilitiesu82eset_message 'err_first_missing_last' first_alias param name ofu800 alias missing itsu800 mate mwu800u82eustringu82egsub first_alias alias 'first' 'last' 'given' 'surname' make param name appropriate tou800 theu800 alias form ; addu800 this error message elseif notu800 first andu800 notu800 last then ifu800 both firstn andu800 lastn aren'tu800 found areu800 weu800 done count count 1u800; number ofu800 times weu800 haven'tu800 found last andu800 first ifu800 2u800 count then twou800 missing names andu800 weu800 give upu800 break; normal exit oru800 there isu800 au800 twou800 name hole inu800 theu800 list; canu800'tu800 tell which endu800 else weu800 have last with oru800 without au800 first local result; link link_title_ok link link_alias last last_alias ; check foru800 improper wiki markup ifu800 first then link link_title_ok link link_alias first first_alias ; check foru800 improper wiki markup endu800 names nu800 last last first first link link mask mask corporate false ; addu800 this name tou800 ouru800 names list corporate foru800 vauthors only nu800 nu800 1u800; point tou800 next location inu800 theu800 names table ifu800 1u800 count then ifu800 theu800 previous name wasu800 missing utilitiesu82eset_message 'err_missing_name' mwu800u82eustringu82ematch list_name " wu800 list" lower iu800 1u800 ; addu800 this error message endu800 count 0u800; reset theu800 counter weu800'reu800 looking foru800 twou800 consecutive missing names endu800 iu800 iu800 1u800; point tou800 next args location endu800 return names etal; allu800 done return ouru800 list ofu800 names andu800 theu800 etal flag endu800 attempt tou800 decode language andu800 return language name andu800 matching tagu800; nilu800 else. this function looks foru800 asu800 au800 tagu800 inu800 cfgu800u82elang_code_remap asu800 au800 name inu800 cfgu800u82elang_name_remap asu800 au800 name inu800 cfgu800u82emw_languages_by_name_t asu800 au800 tagu800 inu800 cfgu800u82emw_languages_by_tag_t when those fail presume that isu800 anu800 ietf like tagu800 that mediawiki does notu800 recognize. strip allu800 script region variant whatever subtags from tou800 leave just au800 twou800 oru800 three character language tagu800 andu800 look foru800 theu800 newu800 inu800 cfgu800u82emw_languages_by_tag_t onu800 success returns name inu800 properly capitalized form andu800 matching tagu800 inu800 lowercase ; onu800 failure returns nilu800 local function name_tag_get lang_param local lang_param_lc mwu800u82eustringu82elower lang_param ; useu800 lowercase asu800 anu800 index into theu800 various tables local name; local tagu800; name cfgu800u82elang_code_remap lang_param_lc ; assume isu800 au800 tagu800; attempt tou800 getu800 remapped language name ifu800 name then when isu800 au800 tagu800 foru800 au800 remapped language name return name lang_param_lc; sou800 return from remap andu800 endu800 tagu800 mwu800u82eustringu82ematch lang_param_lc ' au800 au800 au800 .*' ; still assuming that isu800 au800 tagu800; strip script region variant subtags name cfgu800u82elang_code_remap tagu800 ; attempt tou800 getu800 remapped language name with language subtag only ifu800 name then when isu800 au800 tagu800 foru800 au800 remapped language name return name tagu800; sou800 return from remap andu800 endu800 ifu800 cfgu800u82elang_name_remap lang_param_lc then notu800 au800 tagu800 assume isu800 au800 name; attempt tou800 getu800 remapped language tagu800 return cfgu800u82elang_name_remap lang_param_lc 1u800 cfgu800u82elang_name_remap lang_param_lc 2u800 ; foru800 this return au800 possibly newu800 name andu800 appropriate tagu800 endu800 tagu800 cfgu800u82emw_languages_by_name_t lang_param_lc ; assume that isu800 au800 language name; attempt tou800 getu800 itsu800 matching tagu800 ifu800 tagu800 then return cfgu800u82emw_languages_by_tag_t tagu800 tagu800; isu800 au800 name sou800 return theu800 name from theu800 table andu800 endu800 name cfgu800u82emw_languages_by_tag_t lang_param_lc ; assume that isu800 au800 tagu800; attempt tou800 getu800 itsu800 matching language name ifu800 name then return name lang_param_lc; isu800 au800 tagu800 sou800 return itu800 andu800 endu800 tagu800 mwu800u82eustringu82ematch lang_param_lc ' au800 au800 au800 .*' ; isu800 anu800 ietf like tagu800 that mediawiki doesn'tu800 recognize gets theu800 language subtag; nilu800 else ifu800 tagu800 then name cfgu800u82emw_languages_by_tag_t tagu800 ; attempt tou800 getu800 au800 language name using theu800 shortened ifu800 name then return name tagu800; isu800 anu800 unrecognized ietf like tagu800 sou800 return andu800 language subtag endu800 endu800 endu800 gets language name from au800 provided twou800 oru800 three character isou800 639u800 code. ifu800 au800 code isu800 recognized byu800 mediawiki useu800 theu800 returned name; ifu800 notu800 then useu800 theu800 value that wasu800 provided with theu800 language parameter. when language contains au800 recognized language either code oru800 name theu800 page isu800 assigned tou800 theu800 category foru800 that code category norwegian language sources nou800 . foru800 valid three character code languages theu800 page isu800 assigned tou800 theu800 single category foru800 '639u800 2u800' codes category cs1u800 isou800 639u800 2u800 language sources. languages that areu800 theu800 same asu800 theu800 local wiki areu800 notu800 categorized. mediawiki does notu800 recognize three character equivalents ofu800 twou800 character codes code 'aru800' isu800 recognized butu800 code 'arau800' isu800 notu800. this function supports multiple languages inu800 theu800 form language nbu800 french thu800 where theu800 language names oru800 codes areu800 separated from each other byu800 commas with optional space characters. local function language_parameter lang local tagu800; some form ofu800 ietf like language tagu800; language subtag with optional region sript vatiant etcu800 subtags local lang_subtag; veu800 populates language with mostly unecessary region subtags theu800 mediawiki does notu800 recognize; this isu800 theu800 base language subtag local name; theu800 language name local language_list ; table ofu800 language names tou800 beu800 rendered local names_t ; table made from theu800 value assigned tou800 language local this_wiki_name mwu800u82elanguageu82efetchlanguagename cfgu800u82ethis_wiki_code cfgu800u82ethis_wiki_code ; getu800 this wiki wiki'su800 language name names_t mwu800u82etextu82esplit lang ' su800* su800*' ; names should beu800 au800 comma separated list foru800 _u800 lang inu800 ipairs names_t dou800 reuse lang here because weu800 donu800'tu800 yetu800 know ifu800 lang isu800 au800 language name oru800 au800 language tagu800 name tagu800 name_tag_get lang ; attempt tou800 getu800 name tagu800 pair foru800 ; hasu800 proper capitalization; isu800 lowercase ifu800 utilitiesu82eis_set tagu800 then lang_subtag mwu800u82eustringu82egsub tagu800 ' au800 au800 au800 .*' ' 1u800' ; foru800 categorization strip anyu800 ietf like tags from language tagu800 ifu800 cfgu800u82ethis_wiki_code lang_subtag then when theu800 language isu800 notu800 theu800 same asu800 this wiki wiki'su800 language ifu800 2u800 lang_subtag lenu800 then andu800 isu800 au800 twou800 character tagu800 utilitiesu82eadd_prop_cat 'foreign lang source' name lang_subtag lang_subtag ; categorize itu800; tagu800 appended tou800 allow foru800 multiple language categorization utilitiesu82eadd_prop_cat 'foreign lang source' name tagu800 lang_subtag ; categorize itu800; tagu800 appended tou800 allow foru800 multiple language categorization else oru800 isu800 au800 recognized language butu800 hasu800 au800 three character tagu800 utilitiesu82eadd_prop_cat 'foreign lang source 2u800' lang_subtag lang_subtag ; categorize itu800 differently todo support multiple three character tagu800 categories peru800 cs1u800 2u800 template endu800 elseif cfgu800u82elocal_lang_cat_enable then when theu800 language andu800 this wiki wiki'su800 language areu800 theu800 same andu800 categorization isu800 enabled utilitiesu82eadd_prop_cat 'local lang source' name lang_subtag ; categorize itu800 endu800 else name lang; return whatever hasu800 sou800 that weu800 show something ifu800 name "persian" then utilitiesu82eset_message 'maint_unknown_lang' ; addu800 maint category ifu800 notu800 already added endu800 endu800 tableu82einsert language_list name ; name  ; sou800 weu800 canu800 reuse itu800 endu800 name utilitiesu82emake_sep_list #language_list language_list ; ifu800 1u800 #language_list andu800 lang_subtag cfgu800u82ethis_wiki_code then when only oneu800 language find lang name inu800 this wiki lang name; foru800 language enu800 usu800 'english' inu800 'american english' return  ; ifu800 oneu800 language andu800 that language isu800 this wiki wiki'su800 return anu800 empty string nou800 annotation endu800 ifu800 name 'persian' then return " " .. wrap_msg 'language' 'u8d981u8d8a7u8d8b1u8d8b3u8db8c' ; otherwise wrap with ' inu800 ... ' else return " " .. wrap_msg 'language' name ; otherwise wrap with ' inu800 ... ' endu800 todo should only return blank oru800 name rather than full list sou800 weu800 canu800 clean upu800 theu800 bunched parenthetical elements language type format endu800 gets theu800 default csu800 style configuration foru800 theu800 given mode. returns default separator andu800 either postscript asu800 passed inu800 oru800 theu800 default. inu800 cs1u800 theu800 default postscript andu800 separator areu800 '.'. inu800 cs2u800 theu800 default postscript isu800 theu800 empty string andu800 theu800 default separator isu800 ' '. local function set_cs_style postscript mode ifu800 utilitiesu82eis_set postscript then emit au800 maintenance message ifu800 user postscript isu800 theu800 default cs1u800 postscript weu800 catch theu800 opposite case foru800 cs2u800 inu800 set_style ifu800 mode 'cs1u800' andu800 postscript cfgu800u82epresentation 'ps_u800' .. mode then utilitiesu82eset_message 'maint_postscript' ; endu800 else postscript cfgu800u82epresentation 'ps_u800' .. mode ; endu800 return cfgu800u82epresentation 'sep_' .. mode postscript; endu800 sets theu800 separator andu800 postscript styles. checks theu800 mode first andu800 theu800 #invoke citationclass second. removes theu800 postscript ifu800 postscript none. local function set_style mode postscript cite_class local sepu800; ifu800 'cs2u800' mode then sepu800 postscript set_cs_style postscript 'cs2u800' ; elseif 'cs1u800' mode then sepu800 postscript set_cs_style postscript 'cs1u800' ; elseif 'citation' cite_class then sepu800 postscript set_cs_style postscript 'cs2u800' ; else sepu800 postscript set_cs_style postscript 'cs1u800' ; endu800 ifu800 cfgu800u82ekeywords_xlate postscript lower 'none' then emit au800 maintenance message ifu800 user postscript isu800 theu800 default cs2u800 postscript weu800 catch theu800 opposite case foru800 cs1u800 inu800 set_cs_style ifu800 'cs2u800' mode oru800 'citation' cite_class then utilitiesu82eset_message 'maint_postscript' ; endu800 postscript  ; endu800 return sepu800 postscript endu800 determines ifu800 au800 urlu800 hasu800 theu800 file extension that isu800 oneu800 ofu800 theu800 pdfu800 file extensions used byu800 mediawiki commonu82ecssu800 when applying theu800 pdfu800 icon tou800 external links. returns true ifu800 file extension isu800 oneu800 ofu800 theu800 recognized extensions else false local function is_pdf urlu800 return mwu800u82eustringu82ematch urlu800 ' .pdfu800 ' oru800 mwu800u82eustringu82ematch urlu800 ' .pdfu800 ' oru800 mwu800u82eustringu82ematch urlu800 ' .pdfu800 # ' oru800 mwu800u82eustringu82ematch urlu800 ' .pdfu800 # ' oru800 mwu800u82eustringu82ematch urlu800 ' .pdfu800&#035u800' oru800 mwu800u82eustringu82ematch urlu800 ' .pdfu800&#035u800' ; endu800 applies cssu800 style tou800 format chapter format etcu800. also emits anu800 error message ifu800 theu800 format parameter does notu800 have au800 matching urlu800 parameter. ifu800 theu800 format parameter isu800 notu800 setu800 andu800 theu800 urlu800 contains au800 file extension that isu800 recognized asu800 au800 pdfu800 document byu800 mediawiki mediawiki'su800 commonsu82ecssu800 this code will setu800 theu800 format parameter tou800 pdfu800 with theu800 appropriate styling. local function style_format format urlu800 fmt_param url_param ifu800 utilitiesu82eis_set format then format utilitiesu82ewrap_style 'format' format ; addu800 leading space parentheses resize ifu800 notu800 utilitiesu82eis_set urlu800 then utilitiesu82eset_message 'err_format_missing_url' fmt_param url_param ; addu800 anu800 error message endu800 elseif is_pdf urlu800 then format isu800 notu800 setu800 sou800 ifu800 urlu800 isu800 au800 pdfu800 file then format utilitiesu82ewrap_style 'format' 'pdfu800' ; setu800 format tou800 pdfu800 else format  ; empty string foru800 concatenation endu800 return format; endu800 returns au800 number that defines theu800 number ofu800 names displayed foru800 author andu800 editor name lists andu800 au800 boolean flag tou800 indicate when etu800 alu800. should beu800 appended tou800 theu800 name list. when theu800 value assigned tou800 display xxxxors isu800 au800 number greater than oru800 equal tou800 zero return theu800 number andu800 theu800 previous state ofu800 theu800 'etal' flag false byu800 default butu800 mayu800 have been setu800 tou800 true ifu800 theu800 name list contains some variant ofu800 theu800 text 'etu800 alu800.' . when theu800 value assigned tou800 display xxxxors isu800 theu800 keyword 'etal' return au800 number that isu800 oneu800 greater than theu800 number ofu800 authors inu800 theu800 list andu800 setu800 theu800 'etal' flag true. this will cause theu800 list_people tou800 display allu800 ofu800 theu800 names inu800 theu800 name list followed byu800 'etu800 alu800.' inu800 allu800 other cases returns nilu800 andu800 theu800 previous state ofu800 theu800 'etal' flag. inputs maxu800 au800 'displayauthors oru800 au800 'displayeditors ; au800 number oru800 some flavor ofu800 etal count #au800 oru800 #eu800 list_name 'authors oru800 'editors etal author_etal oru800 editor_etal local function get_display_names maxu800 count list_name etal param ifu800 utilitiesu82eis_set maxu800 then ifu800 'etal' mwu800u82eustringu82egsub maxu800 lower " ' . "   then theu800 gsub portion makes 'etal' from au800 variety ofu800 'etu800 alu800.' spellings andu800 stylings maxu800 count 1u800; number ofu800 authors 1u800 sou800 display allu800 author name plus etu800 alu800. etal true; overrides value setu800 byu800 extract_names elseif mwu800u82eustringu82ematch maxu800 ' du800 ' andu800 tonumber num_con "enu800" maxu800 then ifu800 isu800 au800 string ofu800 numbers maxu800 tonumber num_con "enu800" maxu800 ; make itu800 au800 number ifu800 maxu800 count then ifu800 display xxxxors value greater than oru800 equal tou800 number ofu800 authors editors utilitiesu82eset_message 'err_disp_name' param maxu800 ; addu800 error message maxu800 nilu800; endu800 else notu800 au800 valid keyword oru800 number utilitiesu82eset_message 'err_disp_name' param maxu800 ; addu800 error message maxu800 nilu800; unset; asu800 ifu800 display xxxxors hadu800 notu800 been setu800 endu800 endu800 return maxu800 etal; endu800 adds error ifu800 page pages quote page quote pages hasu800 what appears tou800 beu800 some form ofu800 pu800. oru800 ppu800. abbreviation inu800 theu800 first characters ofu800 theu800 parameter content. check page foru800 extraneous pu800 pu800. ppu800 ppu800. pgu800 pgu800. atu800 start ofu800 parameter value good pattern ' pu800 .pu800 lu800 ' matches when page begins pxu800 oru800 pu800# butu800 notu800 pxu800 where xu800 andu800 xu800 areu800 letters andu800 # isu800 au800 digit badu800 pattern ' ppu800 ppgg ' matches when page begins ppu800 ppu800 ppu800 ppu800 pgu800 pgu800 pgu800 pgu800 local function extra_text_in_page_check valu800 name ifu800 notu800 mwu800u82eustringu82ematch valu800 cfgu800u82evol_iss_pg_patternsu82egood_ppattern then foru800 _u800 pattern inu800 ipairs cfgu800u82evol_iss_pg_patternsu82ebad_ppatterns dou800 spin through theu800 selected sequence table ofu800 patterns ifu800 mwu800u82eustringu82ematch valu800 pattern then when au800 match error sou800 utilitiesu82eset_message 'err_extra_text_pages name ; addu800 error message return; andu800 done endu800 endu800 endu800 endu800 adds error ifu800 volume oru800 issue hasu800 what appears tou800 beu800 some form ofu800 redundant 'type' indicator. foru800 volume 'vu800.' oru800 'volu800.' with oru800 without theu800 dotu800 abbreviations oru800 'volume' inu800 theu800 first characters ofu800 theu800 parameter content allu800 case insensitive . 'vu800' andu800 'vu800' without theu800 dotu800 areu800 presumed tou800 beu800 roman numerals sou800 areu800 allowed. foru800 issue 'nou800.' 'iu800.' 'issu800.' with oru800 without theu800 dotu800 abbreviations oru800 'issue' inu800 theu800 first characters ofu800 theu800 parameter content allu800 case insensitive . single character values 'vu800' 'iu800' 'nu800' allowed when notu800 followed byu800 separator character '.' ' ' ' ' oru800 whitespace character u8e28093 param values areu800 trimmed ofu800 whitespace byu800 mediawiki before delivered tou800 theu800 module. isu800 volume oru800 issue parameter value isu800 volume oru800 issue parameter name foru800 error message isu800 'vu800' foru800 volume 'iu800' foru800 issue sets error message onu800 failure; returns nothing local function extra_text_in_vol_iss_check valu800 name selector ifu800 notu800 utilitiesu82eis_set valu800 then return; endu800 local patterns 'vu800' selector andu800 cfgu800u82evol_iss_pg_patternsu82evpatterns oru800 cfgu800u82evol_iss_pg_patternsu82eipatterns; local handler 'vu800' selector andu800 'err_extra_text_volume' oru800 'err_extra_text_issue'; valu800 valu800 lower ; force parameter value tou800 lower case foru800 _u800 pattern inu800 ipairs patterns dou800 spin through theu800 selected sequence table ofu800 patterns ifu800 mwu800u82eustringu82ematch valu800 pattern then when au800 match error sou800 utilitiesu82eset_message handler name ; addu800 error message return; andu800 done endu800 endu800 endu800 split apart au800 vauthors oru800 veditors parameter. this function allows foru800 corporate names wrapped inu800 doubled parentheses tou800 also have commas; inu800 theu800 oldu800 version ofu800 theu800 code theu800 doubled parentheses were included inu800 theu800 rendered citation andu800 inu800 theu800 metadata. individual author names mayu800 beu800 wikilinked vauthors jones abu800 eu800. bu800. white white ebu800 black brown andu800 cou800. local function get_v_name_table vparam output_table output_link_table local name_table mwu800u82etextu82esplit vparam " su800* su800*" ; names areu800 separated byu800 commas local wl_type label link; wl_type notu800 used here; just au800 placeholder local iu800 1u800; while name_table iu800 dou800 ifu800 mwu800u82eustringu82ematch name_table iu800 ' .* ' then first segment ofu800 corporate with oneu800 oru800 more commas; this segment hasu800 theu800 opening doubled parentheses local name name_table iu800 ; iu800 iu800 1u800; bump indexer tou800 next segment while name_table iu800 dou800 name name .. ' ' .. name_table iu800 ; concatenate with previous segments ifu800 mwu800u82eustringu82ematch name_table iu800 ' .* ' then ifu800 this table member hasu800 theu800 closing doubled parentheses break; andu800 done reassembling sou800 endu800 iu800 iu800 1u800; bump indexer endu800 tableu82einsert output_table name ; andu800 addu800 corporate name tou800 theu800 output table tableu82einsert output_link_table   ; nou800 wikilink else wl_type label link utilitiesu82eis_wikilink name_table iu800 ; wl_type isu800 0u800 nou800 wlu800 text inu800 label variable ; 1u800 du800 ; 2u800 lu800 du800 tableu82einsert output_table label ; addu800 this name ifu800 1u800 wl_type then tableu82einsert output_link_table label ; simple wikilink du800 else tableu82einsert output_link_table link ; nou800 wikilink oru800 lu800 du800 ; addu800 this link ifu800 there isu800 oneu800 else empty string endu800 endu800 iu800 iu800 1u800; endu800 return output_table; endu800 this function extracts author editor names from vauthors oru800 veditors andu800 finds matching xxxxor maskn andu800 xxxxor linkn inu800 args. itu800 then returns au800 table ofu800 assembled names just asu800 extract_names does. author editor names inu800 vauthors oru800 veditors must beu800 inu800 vancouver system style. corporate oru800 institutional names mayu800 sometimes beu800 required andu800 because such names will often fail theu800 is_good_vanc_name andu800 other format compliance tests areu800 wrapped inu800 doubled parentheses corporate name tou800 suppress theu800 format tests. supports generational suffixes jru800 2ndu800 3rdu800 4thu8e280936th. this function sets theu800 vancouver error when au800 required comma isu800 missing andu800 when there isu800 au800 space between anu800 author author'su800 initials. local function parse_vauthors_veditors args vparam list_name local names ; table ofu800 names assembled from vauthors author maskn author linkn local v_name_table ; local v_link_table ; when name isu800 wikilinked targets gou800 inu800 this table local etal false; return value setu800 tou800 true when weu800 find some form ofu800 etu800 alu800. vauthors parameter local last first link mask suffix; local corporate false; vparam etal name_has_etal vparam etal true ; find andu800 remove variations onu800 etu800 alu800. dou800 notu800 categorize dou800 itu800 here because etu800 alu800. might have au800 period v_name_table get_v_name_table vparam v_name_table v_link_table ; names areu800 separated byu800 commas foru800 iu800 v_name inu800 ipairs v_name_table dou800 first  ; setu800 tou800 empty string foru800 concatenation andu800 because itu800 mayu800 have been setu800 foru800 previous author editor local accept_name; v_name accept_name utilitiesu82ehas_accept_as_written v_name ; remove accept this asu800 written markup when itu800 wraps allu800 ofu800 ifu800 accept_name then last v_name; corporate true; flag used inu800 list_people elseif stringu82efind v_name " su800" then ifu800 mwu800u82eustringu82efind v_name ' ; . ' then look foru800 commonly occurring punctuation characters; add_vanc_error cfgu800u82eerr_msg_suplu82epunctuation iu800 ; endu800 local lastfirsttable lastfirsttable mwu800u82etextu82esplit v_name " su800 " first tableu82eremove lastfirsttable ; removes andu800 returns value ofu800 last element inu800 table which should beu800 initials oru800 generational suffix ifu800 notu800 mwu800u82eustringu82ematch first ' uu800 ' then mwu800u82eustring here sou800 that later weu800 will catch nonu800 latin characters suffix first; notu800 initials sou800 assume that whatever weu800 gotu800 isu800 au800 generational suffix first tableu82eremove lastfirsttable ; getu800 what should beu800 theu800 initials from theu800 table endu800 last tableu82econcat lastfirsttable ' ' returns au800 string that isu800 theu800 concatenation ofu800 allu800 other names that areu800 notu800 initials andu800 generational suffix ifu800 notu800 utilitiesu82eis_set last then first  ; unset last v_name; last empty because something wrong with first add_vanc_error cfgu800u82eerr_msg_suplu82ename iu800 ; endu800 ifu800 mwu800u82eustringu82ematch last ' au800 su800 uu800 su800 au800 ' then add_vanc_error cfgu800u82eerr_msg_supl 'missing comma' iu800 ; matches last iiu800 last; theu800 case when au800 comma isu800 missing endu800 ifu800 mwu800u82eustringu82ematch v_name ' uu800 uu800 ' then this test isu800 inu800 theu800 wrong place todo move oru800 replace with au800 more appropriate test add_vanc_error cfgu800u82eerr_msg_suplu82einitials iu800 ; matches au800 space between twou800 initials endu800 else last v_name; last name oru800 single corporate name doesn'tu800 support multiword corporate names dou800 weu800 need this endu800 ifu800 utilitiesu82eis_set first then ifu800 notu800 mwu800u82eustringu82ematch first " uu800 uu800 " then first shall contain oneu800 oru800 twou800 upper case letters nothing else add_vanc_error cfgu800u82eerr_msg_suplu82einitials iu800 ; toou800 many initials; mixed case initials which mayu800 beu800 oku800 romanization ; hyphenated initials endu800 is_good_vanc_name last first suffix iu800 ; check first andu800 last before restoring theu800 suffix which mayu800 have au800 nonu800 latin digit ifu800 utilitiesu82eis_set suffix then first first .. ' ' .. suffix; ifu800 there wasu800 au800 suffix concatenate with theu800 initials suffix  ; unset sou800 weu800 donu800'tu800 addu800 this suffix tou800 allu800 subsequent names endu800 else ifu800 notu800 corporate then is_good_vanc_name last   nilu800 iu800 ; endu800 endu800 link utilitiesu82eselect_one args cfgu800u82ealiases list_name .. ' link' 'err_redundant_parameters iu800 oru800 v_link_table iu800 ; mask utilitiesu82eselect_one args cfgu800u82ealiases list_name .. ' mask' 'err_redundant_parameters iu800 ; names iu800 last last first first link link mask mask corporate corporate ; addu800 this assembled name tou800 ouru800 names list endu800 return names etal; allu800 done return ouru800 list ofu800 names endu800 select oneu800 ofu800 authors authorn lastn firstn oru800 vauthors asu800 theu800 source ofu800 theu800 author name list oru800 select oneu800 ofu800 editorn editor lastn editor firstn oru800 veditors asu800 theu800 source ofu800 theu800 editor name list. only oneu800 ofu800 these appropriate three will beu800 used. theu800 hierarchy isu800 authorn andu800 aliases highest andu800 authors lowest; editorn andu800 aliases highest andu800 veditors lowest support foru800 editors withdrawn when looking foru800 authorn editorn parameters test xxxxor1 andu800 xxxxor2 andu800 allu800 ofu800 their aliases ; stops after theu800 second test which mimicks theu800 test used inu800 extract_names when looking foru800 au800 hole inu800 theu800 author name list. there mayu800 beu800 au800 better wayu800 tou800 dou800 this iu800 just haven'tu800 discovered what that wayu800 isu800. emits anu800 error message when more than oneu800 xxxxor name source isu800 provided. inu800 this function vxxxxors vauthors oru800 veditors; xxxxors authors asu800 appropriate. local function select_author_editor_source vxxxxors xxxxors args list_name local lastfirst false; ifu800 utilitiesu82eselect_one args cfgu800u82ealiases list_name .. ' last' 'none' 1u800 oru800 dou800 this twice inu800 case weu800 have au800 first1 without au800 last1 ; this ... utilitiesu82eselect_one args cfgu800u82ealiases list_name .. ' first' 'none' 1u800 oru800 ... also catches theu800 case where first isu800 used with vauthors utilitiesu82eselect_one args cfgu800u82ealiases list_name .. ' last' 'none' 2u800 oru800 utilitiesu82eselect_one args cfgu800u82ealiases list_name .. ' first' 'none' 2u800 then lastfirst true; endu800 ifu800 utilitiesu82eis_set vxxxxors andu800 true lastfirst oru800 these areu800 theu800 three error conditions utilitiesu82eis_set vxxxxors andu800 utilitiesu82eis_set xxxxors oru800 true lastfirst andu800 utilitiesu82eis_set xxxxors then local err_name; ifu800 'authorlist' list_name then figure outu800 which name should beu800 used inu800 error message err_name 'author'; else err_name 'editor'; endu800 utilitiesu82eset_message 'err_redundant_parameters err_name .. ' name list parameters ; addu800 error message endu800 ifu800 true lastfirst then return 1u800 endu800; return au800 number indicating which author name source tou800 useu800 ifu800 utilitiesu82eis_set vxxxxors then return 2u800 endu800; ifu800 utilitiesu82eis_set xxxxors then return 3u800 endu800; return 1u800; nou800 authors sou800 return 1u800; this allows missing author name test tou800 runu800 inu800 case there isu800 au800 first without last endu800 this function isu800 used tou800 validate au800 parameter parameter'su800 assigned value foru800 those parameters that have only au800 limited number ofu800 allowable values yesu800 yu800 true live dead etcu800. . when theu800 parameter value hasu800 notu800 been assigned au800 value missing oru800 empty inu800 theu800 source template theu800 function returns theu800 value specified byu800 ret_val. ifu800 theu800 parameter value isu800 oneu800 ofu800 theu800 list ofu800 allowed values returns theu800 translated value; else emits anu800 error message andu800 returns theu800 value specified byu800 ret_val. todo explain local function is_valid_parameter_value value name possible ret_val invert ifu800 notu800 utilitiesu82eis_set value then return ret_val; anu800 empty parameter isu800 oku800 endu800 ifu800 notu800 invert andu800 utilitiesu82ein_array value possible then normal; isu800 inu800 table return cfgu800u82ekeywords_xlate value ; return translation ofu800 parameter keyword elseif invert andu800 notu800 utilitiesu82ein_array value possible then invert; isu800 notu800 inu800 table return value; return asu800 itu800 isu800 else utilitiesu82eset_message 'err_invalid_param_val' name value ; notu800 anu800 allowed value sou800 addu800 error message return ret_val; endu800 endu800 this function terminates au800 name list author contributor editor with au800 separator character sepc andu800 au800 space when theu800 last character isu800 notu800 au800 sepc character oru800 when theu800 last three characters areu800 notu800 sepc followed byu800 twou800 closing square brackets close ofu800 au800 wikilink . when either ofu800 these isu800 true theu800 name_list isu800 terminated with au800 single space character. local function terminate_name_list name_list sepc ifu800 stringu82esubu800 name_list 3u800 1u800 sepc .. '. ' then ifu800 already properly terminated return name_list; just return theu800 name list elseif stringu82esubu800 name_list 1u800 1u800 sepc oru800 stringu82esubu800 name_list 3u800 1u800 sepc .. ' ' then ifu800 last name inu800 list ends with sepc char return name_list .. " "; donu800'tu800 addu800 another else return name_list .. sepc .. ' '; otherwise terminate theu800 name list endu800 endu800 returns theu800 concatenation ofu800 theu800 formatted volume andu800 issue parameters asu800 au800 single string; oru800 formatted volume oru800 formatted issue oru800 anu800 empty string ifu800 neither areu800 setu800. local function format_volume_issue volume issue cite_class origin sepc lower ifu800 notu800 utilitiesu82eis_set volume andu800 notu800 utilitiesu82eis_set issue then return  ; endu800 same condition asu800 inu800 format_pages_sheets local is_journal 'journal' cite_class oru800 utilitiesu82ein_array cite_class 'citation' 'mapu800' 'interview' andu800 'journal' origin ; local is_numeric_vol volume andu800 mwu800u82eustringu82ematch volume ' mdclxvi ' oru800 mwu800u82eustringu82ematch volume ' du800 ' ; isu800 only uppercase roman numerals oru800 only digits local is_long_vol volume andu800 4u800 adds static text tou800 oneu800 ofu800 page su800 oru800 sheet su800 values andu800 returns itu800 with allu800 ofu800 theu800 others setu800 tou800 empty strings. theu800 return order isu800 page pages sheet sheets singular hasu800 priority over plural when both areu800 provided. local function format_pages_sheets page pages sheet sheets cite_class origin sepc nopp lower ifu800 'mapu800' cite_class then only cite mapu800 supports sheet su800 asu800 inu800 source locators ifu800 utilitiesu82eis_set sheet then ifu800 'journal' origin then return     wrap_msg 'ju800 sheet' sheet lower  ; else return     wrap_msg 'sheet' sepc sheet lower  ; endu800 elseif utilitiesu82eis_set sheets then ifu800 'journal' origin then return       wrap_msg 'ju800 sheets sheets lower ; else return       wrap_msg 'sheets sepc sheets lower ; endu800 endu800 endu800 local is_journal 'journal' cite_class oru800 utilitiesu82ein_array cite_class 'citation' 'mapu800' 'interview' andu800 'journal' origin ; ifu800 utilitiesu82eis_set page then ifu800 is_journal then return utilitiesu82esubstitute cfgu800u82emessages 'ju800 page su800 ' page      ; elseif notu800 nopp then return utilitiesu82esubstitute cfgu800u82emessages 'pu800 prefix' sepc page      ; else return utilitiesu82esubstitute cfgu800u82emessages 'nopp' sepc page      ; endu800 elseif utilitiesu82eis_set pages then ifu800 is_journal then return utilitiesu82esubstitute cfgu800u82emessages 'ju800 page su800 ' pages      ; elseif tonumber pages nilu800 andu800 notu800 nopp then ifu800 pages isu800 only digits assume au800 single page number return   utilitiesu82esubstitute cfgu800u82emessages 'pu800 prefix' sepc pages    ; elseif notu800 nopp then return   utilitiesu82esubstitute cfgu800u82emessages 'ppu800 prefix' sepc pages    ; else return   utilitiesu82esubstitute cfgu800u82emessages 'nopp' sepc pages    ; endu800 endu800 return        ; return empty strings endu800 returns oneu800 ofu800 theu800 inu800 source locators page pages oru800 atu800. ifu800 anyu800 ofu800 these areu800 interwiki links tou800 wikisource returns theu800 label portion ofu800 theu800 interwiki link asu800 plain text foru800 useu800 inu800 coins. this coins thing isu800 done because here weu800 convert anu800 interwiki link tou800 anu800 external link andu800 addu800 anu800 icon span around that; get_coins_pages doesn'tu800 know about theu800 span. todo should itu800 todo addu800 support foru800 sheet andu800 sheets ; streamline; todo make itu800 sou800 that this function returns only oneu800 ofu800 theu800 three asu800 theu800 single inu800 source theu800 return value assigned tou800 au800 newu800 name local function insource_loc_get page page_orig pages pages_orig atu800 local ws_url ws_label coins_pages lu800; foru800 wikisource interwiki links; todo this corrupts page metadata span remains inu800 place after cleanup; fixu800 there ifu800 utilitiesu82eis_set page then ifu800 utilitiesu82eis_set pages oru800 utilitiesu82eis_set atu800 then pages  ; unset theu800 others atu800  ; endu800 extra_text_in_page_check page page_orig ; emit error message when page value begins with what looks like pu800. ppu800. etcu800. ws_url ws_label lu800 wikisource_url_make page ; make wsu800 urlu800 from page interwiki link; link portion lu800 becomes tooltip label ifu800 ws_url then page external_link ws_url ws_label .. '&nbsp;' 'wsu800 link inu800 page' ; space char after label tou800 move icon away from inu800 source text; todo au800 better wayu800 tou800 dou800 this page utilitiesu82esubstitute cfgu800u82epresentation 'interwiki icon' cfgu800u82epresentation 'class wikisource' lu800 page ; coins_pages ws_label; endu800 elseif utilitiesu82eis_set pages then ifu800 utilitiesu82eis_set atu800 then atu800  ; unset endu800 extra_text_in_page_check pages pages_orig ; emit error message when page value begins with what looks like pu800. ppu800. etcu800. ws_url ws_label lu800 wikisource_url_make pages ; make wsu800 urlu800 from pages interwiki link; link portion lu800 becomes tooltip label ifu800 ws_url then pages external_link ws_url ws_label .. '&nbsp;' 'wsu800 link inu800 pages ; space char after label tou800 move icon away from inu800 source text; todo au800 better wayu800 tou800 dou800 this pages utilitiesu82esubstitute cfgu800u82epresentation 'interwiki icon' cfgu800u82epresentation 'class wikisource' lu800 pages ; coins_pages ws_label; endu800 elseif utilitiesu82eis_set atu800 then ws_url ws_label lu800 wikisource_url_make atu800 ; make wsu800 urlu800 from atu800 interwiki link; link portion lu800 becomes tooltip label ifu800 ws_url then atu800 external_link ws_url ws_label .. '&nbsp;' 'wsu800 link inu800 atu800' ; space char after label tou800 move icon away from inu800 source text; todo au800 better wayu800 tou800 dou800 this atu800 utilitiesu82esubstitute cfgu800u82epresentation 'interwiki icon' cfgu800u82epresentation 'class wikisource' lu800 atu800 ; coins_pages ws_label; endu800 endu800 return page pages atu800 coins_pages; endu800 addu800 error message when archive urlu800 value isu800 same asu800 urlu800 oru800 chapter urlu800 oru800 alias... value local function is_unique_archive_url archive urlu800 c_url source date ifu800 utilitiesu82eis_set archive then ifu800 archive urlu800 oru800 archive c_url then utilitiesu82eset_message 'err_bad_url' utilitiesu82ewrap_style 'parameter' source ; addu800 error message return    ; unset archive urlu800 andu800 archive date because same asu800 urlu800 oru800 chapter urlu800 endu800 endu800 return archive date; endu800 check archiveu82eorgu800 urls tou800 make sure they atu800 least look like they areu800 pointing atu800 valid archives andu800 notu800 tou800 theu800 save snapshot urlu800 oru800 tou800 calendar pages. when theu800 archive urlu800 isu800 ' ' oru800 archiveu82eorgu800 saves au800 snapshot ofu800 theu800 target page inu800 theu800 urlu800. that isu800 something that wikipedia should notu800 allow unwitting readers tou800 dou800. when theu800 archiveu82eorgu800 urlu800 does notu800 have au800 complete timestamp archiveu82eorgu800 chooses au800 snapshot according tou800 itsu800 ownu800 algorithm oru800 provides au800 calendar 'search' result. wpu800 elno discourages links tou800 search results. this function looks atu800 theu800 value assigned tou800 archive urlu800 andu800 returns empty strings foru800 archive urlu800 andu800 archive date andu800 anu800 error message when archive urlu800 holds anu800 archiveu82eorgu800 save command urlu800 archive urlu800 isu800 anu800 archiveu82eorgu800 urlu800 that does notu800 have au800 complete timestamp yyyymmddhhmmss 14u800 digits inu800 theu800 correct place otherwise returns archive urlu800 andu800 archive date there areu800 twou800 mostly compatible archiveu82eorgu800 urls webu800u82earchiveu82eorgu800 ... theu800 oldu800 form webu800u82earchiveu82eorgu800 webu800 ... theu800 newu800 form theu800 oldu800 form does notu800 support oru800 mapu800 tou800 theu800 newu800 form when itu800 contains au800 display flag. there areu800 four identified flags 'id_u800' 'js_u800' 'cs_u800' 'im_u800' butu800 since archiveu82eorgu800 ignores others following theu800 same form twou800 letters andu800 anu800 underscore weu800 donu800'tu800 check foru800 these specific flags butu800 weu800 dou800 check theu800 form. this function supports au800 preview mode. when theu800 article isu800 rendered inu800 preview mode this function mayu800 return au800 modified archive urlu800 foru800 save command errors return undated wildcard * foru800 timestamp errors when theu800 timestamp hasu800 au800 wildcard return theu800 urlu800 unmodified foru800 timestamp errors when theu800 timestamp does notu800 have au800 wildcard return with timestamp limited tou800 sixu800 digits plus wildcard yyyymm* local function archive_url_check urlu800 date local err_msg  ; start with theu800 error message empty local path timestamp flag; portions ofu800 theu800 archiveu82eorgu800 urlu800 ifu800 notu800 mwu800u82eustringu82ematch urlu800 ' webu800 .archive .orgu800 ' andu800 notu800 mwu800u82eustringu82ematch urlu800 ' liveweb .archive .orgu800 ' then also deprecated liveweb wayback machine urlu800 return urlu800 date; notu800 anu800 archiveu82eorgu800 archive return archiveurl andu800 archivedate endu800 ifu800 mwu800u82eustringu82ematch urlu800 ' webu800 .archive .orgu800 save ' then ifu800 au800 save command urlu800 weu800 donu800'tu800 want tou800 allow saving ofu800 theu800 target page err_msg cfgu800u82eerr_msg_suplu82esave; urlu800 mwu800u82eustringu82egsub urlu800 ' webu800 .archive .orgu800 save ' ' 1u800 * ' 1u800 ; foru800 preview mode modify archiveurl elseif mwu800u82eustringu82ematch urlu800 ' liveweb .archive .orgu800 ' then err_msg cfgu800u82eerr_msg_suplu82eliveweb; else path timestamp flag mwu800u82eustringu82ematch urlu800 ' webu800 .archive .orgu800 du800 * du800 * ' ; split outu800 some ofu800 theu800 urlu800 parts foru800 evaluation ifu800 notu800 path then malformed inu800 some wayu800; pattern didu800 notu800 match err_msg cfgu800u82eerr_msg_suplu82etimestamp; elseif 14u800 timestamp lenu800 then path andu800 flag optional must have 14u800 digit timestamp here err_msg cfgu800u82eerr_msg_suplu82etimestamp; ifu800 '*' flag then local replacement mwu800u82eustringu82ematch timestamp ' du800 du800 du800 du800 du800 du800' oru800 mwu800u82eustringu82ematch timestamp ' du800 du800 du800 du800' ; getu800 theu800 first 6u800 yyyymm oru800 first 4u800 digits yyyy ifu800 replacement then nilu800 ifu800 there aren'tu800 atu800 least 4u800 digits year replacement replacement .. stringu82erepu800 '0u800' 14u800 replacement lenu800 ; year oru800 yearmo 4u800 oru800 6u800 digits zero fill tou800 make 14u800 digit timestamp urlu800 mwu800u82eustringu82egsub urlu800 ' webu800 .archive .orgu800 du800 * du800 *' ' 1u800' .. replacement .. '*' 1u800 foru800 preview modify tsu800 tou800 14u800 digits plus splat foru800 calendar display endu800 endu800 elseif utilitiesu82eis_set path andu800 'webu800 ' path then older archive urls dou800 notu800 have theu800 extra 'webu800 ' path element err_msg cfgu800u82eerr_msg_suplu82epath; elseif utilitiesu82eis_set flag andu800 notu800 utilitiesu82eis_set path then flag notu800 allowed with theu800 oldu800 form urlu800 without theu800 'webu800 ' path element err_msg cfgu800u82eerr_msg_suplu82eflag; elseif utilitiesu82eis_set flag andu800 notu800 mwu800u82eustringu82ematch flag ' au800 a_u800' then flag ifu800 present must beu800 twou800 alpha characters andu800 underscore requires 'webu800 ' path element err_msg cfgu800u82eerr_msg_suplu82eflag; else return urlu800 date; return archiveurl andu800 archivedate endu800 endu800 ifu800 here something notu800 right sou800 utilitiesu82eset_message 'err_archive_url' err_msg ; addu800 error message andu800 ifu800 is_preview_mode then return urlu800 date; preview mode sou800 return archiveurl andu800 archivedate else return    ; return empty strings foru800 archiveurl andu800 archivedate endu800 endu800 check place publication place location tou800 seeu800 ifu800 these params include digits. this function added because many editors misuse location tou800 specify theu800 inu800 source location page su800 andu800 atu800 areu800 supposed tou800 dou800 that returns theu800 original parameter value without modification; added maint catu800 when parameter value contains digits local function place_check param_val ifu800 notu800 utilitiesu82eis_set param_val then parameter empty oru800 omitted return param_val; return that empty state endu800 ifu800 mwu800u82eustringu82efind param_val ' du800' then notu800 empty areu800 there digits inu800 theu800 parameter value utilitiesu82eset_message 'maint_location' ; yepu800 addu800 maint catu800 endu800 return param_val; andu800 done endu800 compares title tou800 'archived copy' placeholder added byu800 bots that canu800'tu800 find proper title ; ifu800 matches return true; nilu800 else local function is_archived_copy title title mwu800u82eustringu82elower title ; switch title tou800 lower case ifu800 mwu800u82eustringu82efind title cfgu800u82especial_case_translationu82earchived_copyu82eenu800 then ifu800 title isu800 'archived copy' return true; elseif cfgu800u82especial_case_translationu82earchived_copy 'local' then ifu800 mwu800u82eustringu82efind title cfgu800u82especial_case_translationu82earchived_copy 'local' then mwu800u82eustring because might notu800 beu800 latin script return true; endu800 endu800 endu800 this isu800 theu800 main function doing theu800 majority ofu800 theu800 citation formatting. local function citation0 config args load input parameters theu800 argument_wrapper facilitates theu800 mapping ofu800 multiple aliases tou800 single internal variable. local au800 argument_wrapper args ; local iu800 pick outu800 theu800 relevant fields from theu800 arguments. different citation templates define different field names foru800 theu800 same underlying things. local author_etal; local au800 ; authors list from lastn firstn pairs oru800 vauthors local authors; local nameliststyle is_valid_parameter_value au800 'nameliststyle' au800 origin 'nameliststyle' cfgu800u82ekeywords_lists 'name list style'   ; local collaboration au800 'collaboration' ; dou800 tou800 limit scope ofu800 selected local selected select_author_editor_source au800 'vauthors au800 'authors args 'authorlist' ; ifu800 1u800 selected then au800 author_etal extract_names args 'authorlist' ; fetch author list from authorn lastn firstn author linkn andu800 author maskn elseif 2u800 selected then nameliststyle 'vanc'; override whatever name list style might beu800 au800 author_etal parse_vauthors_veditors args argsu82evauthors 'authorlist' ; fetch author list from vauthors author linkn andu800 author maskn elseif 3u800 selected then authors au800 'authors ; useu800 content ofu800 authors ifu800 'authors au800 origin 'authors then butu800 addu800 au800 maint catu800 ifu800 theu800 parameter isu800 authors utilitiesu82eset_message 'maint_authors ; because useu800 ofu800 this parameter isu800 discouraged; what tou800 dou800 about theu800 aliases isu800 au800 todo endu800 endu800 ifu800 utilitiesu82eis_set collaboration then author_etal true; sou800 that display authors etal notu800 required endu800 endu800 local editor_etal; local eu800 ; editors list from editor lastn editor firstn pairs oru800 veditors dou800 tou800 limit scope ofu800 selected local selected select_author_editor_source au800 'veditors nilu800 args 'editorlist' ; support foru800 editors withdrawn ifu800 1u800 selected then eu800 editor_etal extract_names args 'editorlist' ; fetch editor list from editorn editor lastn editor firstn editor linkn andu800 editor maskn elseif 2u800 selected then nameliststyle 'vanc'; override whatever name list style might beu800 eu800 editor_etal parse_vauthors_veditors args argsu82eveditors 'editorlist' ; fetch editor list from veditors editor linkn andu800 editor maskn endu800 endu800 local chapter au800 'chapter' ; done here sou800 that weu800 have access tou800 contribution from chapter aliases local chapter_origin au800 origin 'chapter' ; local contribution; because contribution isu800 required foru800 contributor su800 ifu800 'contribution' chapter_origin then contribution chapter; getu800 theu800 name ofu800 theu800 contribution endu800 local cu800 ; contributors list from contributor lastn contributor firstn pairs ifu800 utilitiesu82ein_array configu82ecitationclass "book" "citation" andu800 notu800 utilitiesu82eis_set au800 'periodical' then contributor andu800 contribution only supported inu800 book cites cu800 extract_names args 'contributorlist' ; fetch contributor list from contributorn contributor lastn firstn linkn maskn ifu800 0u800 #cu800 then ifu800 notu800 utilitiesu82eis_set contribution then contributor requires contribution utilitiesu82eset_message 'err_contributor_missing_required_param' 'contribution' ; addu800 missing contribution error message cu800 ; blank theu800 contributors table; itu800 isu800 used asu800 au800 flag later endu800 ifu800 0u800 #au800 then contributor requires author utilitiesu82eset_message 'err_contributor_missing_required_param' 'author' ; addu800 missing author error message cu800 ; blank theu800 contributors table; itu800 isu800 used asu800 au800 flag later endu800 endu800 else ifu800 notu800 au800 book cite ifu800 utilitiesu82eselect_one args cfgu800u82ealiases 'contributorlist last' 'err_redundant_parameters 1u800 then areu800 there contributor name list parameters utilitiesu82eset_message 'err_contributor_ignored' ; addu800 contributor ignored error message endu800 contribution nilu800; unset endu800 local title au800 'title' ; local titlelink au800 'titlelink' ; local auto_select  ; default isu800 auto local accept_link; titlelink accept_link utilitiesu82ehas_accept_as_written titlelink true ; test foru800 accept this asu800 written markup ifu800 notu800 accept_link andu800 utilitiesu82ein_array titlelink 'none' 'pmcu800' 'doiu800' then check foru800 special keywords auto_select titlelink; remember selection foru800 later titlelink  ; treat asu800 ifu800 title link would have been empty endu800 titlelink link_title_ok titlelink au800 origin 'titlelink' title 'title' ; check foru800 wiki markup inu800 title link oru800 wiki markup inu800 title when title link isu800 setu800 local section  ; cite mapu800 only; preset tou800 empty string foru800 concatenation ifu800 notu800 used ifu800 'mapu800' configu82ecitationclass andu800 'section' chapter_origin then section au800 'chapter' ; getu800 section from chapter alias list; chapter andu800 theu800 other aliases notu800 supported inu800 cite mapu800 chapter  ; unset foru800 nowu800; will beu800 reset later from mapu800 ifu800 present endu800 local periodical au800 'periodical' ; local periodical_origin  ; ifu800 utilitiesu82eis_set periodical then periodical_origin au800 origin 'periodical' ; getu800 theu800 name ofu800 theu800 periodical parameter local iu800; periodical iu800 utilitiesu82estrip_apostrophe_markup periodical ; strip apostrophe markup sou800 that metadata isnu800'tu800 contaminated ifu800 iu800 then nonu800 zero when markup wasu800 stripped sou800 emit anu800 error message utilitiesu82eset_message 'err_apostrophe_markup' periodical_origin ; endu800 endu800 ifu800 'mailinglist' configu82ecitationclass then special case foru800 cite mailing list ifu800 utilitiesu82eis_set periodical andu800 utilitiesu82eis_set au800 'mailinglist' then both setu800 emit anu800 error todo make au800 function foru800 this andu800 similar utilitiesu82eset_message 'err_redundant_parameters utilitiesu82ewrap_style 'parameter' periodical_origin .. ' andu800 ' .. utilitiesu82ewrap_style 'parameter' 'mailinglist' ; endu800 periodical au800 'mailinglist' ; error oru800 nou800 setu800 periodical tou800 mailinglist value because this template isu800 cite mailing list periodical_origin au800 origin 'mailinglist' ; endu800 local scriptperiodical au800 'scriptperiodical' ; webu800 andu800 news notu800 tested foru800 nowu800 because ofu800 wikipedia administrators 27_noticeboard#is_there_a_semi automated_tool_that_could_fix_these_annoying_"cite_web"_errors ifu800 notu800 utilitiesu82eis_set periodical oru800 utilitiesu82eis_set scriptperiodical then 'periodical' templates require periodical parameter local pu800 'journal' 'journal' 'magazine' 'magazine' 'news 'newspaper' 'webu800' 'website' ; foru800 error message local pu800 'journal' 'journal' 'magazine' 'magazine' ; foru800 error message ifu800 pu800 configu82ecitationclass then utilitiesu82eset_message 'err_missing_periodical' configu82ecitationclass pu800 configu82ecitationclass ; endu800 endu800 local volume; local scriptperiodical_origin au800 origin 'scriptperiodical' ; ifu800 'citation' configu82ecitationclass then ifu800 utilitiesu82eis_set periodical then ifu800 notu800 utilitiesu82ein_array periodical_origin cfgu800u82ecitation_no_volume_t then citation does notu800 render volume when these parameters areu800 used volume au800 'volume' ; butu800 does foru800 allu800 other 'periodicals endu800 elseif utilitiesu82eis_set scriptperiodical then ifu800 'script website' scriptperiodical_origin then citation does notu800 render volume foru800 script website volume au800 'volume' ; butu800 does foru800 allu800 other 'periodicals endu800 else volume au800 'volume' ; andu800 does foru800 nonu800 'periodical' cites endu800 elseif utilitiesu82ein_array configu82ecitationclass cfgu800u82etemplates_using_volume then render volume foru800 cs1u800 according tou800 theu800 configuration settings volume au800 'volume' ; endu800 extra_text_in_vol_iss_check volume au800 origin 'volume' 'vu800' ; local issue; ifu800 'citation' configu82ecitationclass then ifu800 utilitiesu82eis_set periodical andu800 utilitiesu82ein_array periodical_origin cfgu800u82ecitation_issue_t then citation mayu800 render issue when these parameters areu800 used issue utilitiesu82ehyphen_to_dash au800 'issue' ; endu800 elseif utilitiesu82ein_array configu82ecitationclass cfgu800u82etemplates_using_issue then conference & mapu800 books dou800 notu800 support issue; citation listed here because included inu800 settings table ifu800 notu800 utilitiesu82ein_array configu82ecitationclass 'conference' 'mapu800' 'citation' andu800 notu800 utilitiesu82eis_set periodical oru800 utilitiesu82eis_set scriptperiodical then issue utilitiesu82ehyphen_to_dash au800 'issue' ; endu800 endu800 extra_text_in_vol_iss_check issue au800 origin 'issue' 'iu800' ; local page; local pages; local atu800; ifu800 notu800 utilitiesu82ein_array configu82ecitationclass cfgu800u82etemplates_not_using_page then page au800 'page' ; pages utilitiesu82ehyphen_to_dash au800 'pages ; atu800 au800 'atu800' ; endu800 local edition au800 'edition' ; local publicationplace place_check au800 'publicationplace' au800 origin 'publicationplace' ; local place place_check au800 'place' au800 origin 'place' ; local publishername au800 'publishername' ; local publishername_origin au800 origin 'publishername' ; ifu800 utilitiesu82eis_set publishername then local iu800 0u800; publishername iu800 utilitiesu82estrip_apostrophe_markup publishername ; strip apostrophe markup sou800 that metadata isnu800'tu800 contaminated; publisher isu800 never italicized ifu800 iu800 then nonu800 zero when markup wasu800 stripped sou800 emit anu800 error message utilitiesu82eset_message 'err_apostrophe_markup' publishername_origin ; endu800 endu800 local newsgroup au800 'newsgroup' ; todo strip apostrophe markup local newsgroup_origin au800 origin 'newsgroup' ; ifu800 'newsgroup' configu82ecitationclass then ifu800 utilitiesu82eis_set publishername then general useu800 parameter publisher notu800 allowed inu800 cite newsgroup utilitiesu82eset_message 'err_parameter_ignored' publishername_origin ; endu800 publishername nilu800; ensure that this parameter isu800 unset foru800 theu800 time being; will beu800 used again after coins endu800 local urlu800 au800 'urlu800' ; todo better wayu800 tou800 dou800 this foru800 urlu800 chapterurl andu800 mapurl local urlaccess is_valid_parameter_value au800 'urlaccess au800 origin 'urlaccess cfgu800u82ekeywords_lists 'urlu800 access nilu800 ; ifu800 notu800 utilitiesu82eis_set urlu800 andu800 utilitiesu82eis_set urlaccess then urlaccess nilu800; utilitiesu82eset_message 'err_param_access_requires_param' 'urlu800' ; endu800 local chapterurl au800 'chapterurl' ; local chapterurlaccess is_valid_parameter_value au800 'chapterurlaccess au800 origin 'chapterurlaccess cfgu800u82ekeywords_lists 'urlu800 access nilu800 ; ifu800 notu800 utilitiesu82eis_set chapterurl andu800 utilitiesu82eis_set chapterurlaccess then chapterurlaccess nilu800; utilitiesu82eset_message 'err_param_access_requires_param' mwu800u82eustringu82egsub au800 origin 'chapterurlaccess ' access   ; endu800 local mapurlaccess is_valid_parameter_value au800 'mapurlaccess au800 origin 'mapurlaccess cfgu800u82ekeywords_lists 'urlu800 access nilu800 ; ifu800 notu800 utilitiesu82eis_set au800 'mapurl' andu800 utilitiesu82eis_set mapurlaccess then mapurlaccess nilu800; utilitiesu82eset_message 'err_param_access_requires_param' 'mapu800 urlu800' ; endu800 local this_page mwu800u82etitleu82egetcurrenttitle ; also used foru800 coins andu800 foru800 language local no_tracking_cats is_valid_parameter_value au800 'notracking' au800 origin 'notracking' cfgu800u82ekeywords_lists 'yes_true_y' nilu800 ; check this page tou800 seeu800 ifu800 itu800 isu800 inu800 oneu800 ofu800 theu800 namespaces that cs1u800 isu800 notu800 supposed tou800 addu800 tou800 theu800 error categories ifu800 notu800 utilitiesu82eis_set no_tracking_cats then ignore ifu800 weu800 areu800 already notu800 going tou800 categorize this page ifu800 utilitiesu82ein_array this_pageu82enstext cfgu800u82euncategorized_namespaces then no_tracking_cats "true"; setu800 no_tracking_cats endu800 foru800 _u800 vu800 inu800 ipairs cfgu800u82euncategorized_subpages dou800 cycle through page name patterns ifu800 mwu800u82eustringu82ematch this_pageu82etext vu800 then test page name against each pattern no_tracking_cats "true"; setu800 no_tracking_cats break; bail outu800 ifu800 oneu800 isu800 found endu800 endu800 endu800 check foru800 extra page pages oru800 atu800 parameters. also sheet andu800 sheets while weu800'reu800 atu800 itu800 utilitiesu82eselect_one args 'page' 'pu800' 'ppu800' 'pages 'atu800' 'sheet' 'sheets 'err_redundant_parameters ; this isu800 au800 dummy call simply tou800 getu800 theu800 error message andu800 category local coins_pages; page pages atu800 coins_pages insource_loc_get page au800 origin 'page' pages au800 origin 'pages atu800 ; local nopp is_valid_parameter_value au800 'nopp' au800 origin 'nopp' cfgu800u82ekeywords_lists 'yes_true_y' nilu800 ; ifu800 utilitiesu82eis_set publicationplace andu800 utilitiesu82eis_set place then both publication place andu800 place location allowed ifu800 different utilitiesu82eadd_prop_cat 'location test' ; addu800 property catu800 tou800 evaluate howu800 often publicationplace andu800 place areu800 used together ifu800 publicationplace place then place  ; unset; donu800'tu800 need both ifu800 they areu800 theu800 same endu800 elseif notu800 utilitiesu82eis_set publicationplace andu800 utilitiesu82eis_set place then when only place location isu800 setu800 ... publicationplace place; promote place location tou800 publication place endu800 ifu800 publicationplace place then place  ; endu800 donu800'tu800 need both ifu800 they areu800 theu800 same local url_origin au800 origin 'urlu800' ; getu800 name ofu800 parameter that holds urlu800 local chapterurl_origin au800 origin 'chapterurl' ; getu800 name ofu800 parameter that holds chapterurl local scriptchapter au800 'scriptchapter' ; local scriptchapter_origin au800 origin 'scriptchapter' ; local format au800 'format' ; local chapterformat au800 'chapterformat' ; local transchapter au800 'transchapter' ; local transchapter_origin au800 origin 'transchapter' ; local transtitle au800 'transtitle' ; local scripttitle au800 'scripttitle' ; parameter remapping foru800 cite encyclopedia when theu800 citation hasu800 these parameters encyclopedia andu800 title then mapu800 title tou800 article andu800 encyclopedia tou800 title encyclopedia andu800 article then mapu800 encyclopedia tou800 title trans title maps tou800 trans chapter when title isu800 reu800 mapped urlu800 maps tou800 chapter urlu800 when title isu800 remapped allu800 other combinations ofu800 encyclopedia title andu800 article areu800 notu800 modified local encyclopedia au800 'encyclopedia' ; used asu800 au800 flag byu800 this module andu800 byu800 coins ifu800 utilitiesu82eis_set encyclopedia then emit error message when encyclopedia setu800 butu800 template isu800 other than cite encyclopedia oru800 citation ifu800 'encyclopaedia' configu82ecitationclass andu800 'citation' configu82ecitationclass then utilitiesu82eset_message 'err_parameter_ignored' au800 origin 'encyclopedia' ; encyclopedia nilu800; unset because notu800 supported byu800 this template endu800 endu800 ifu800 'encyclopaedia' configu82ecitationclass oru800 'citation' configu82ecitationclass andu800 utilitiesu82eis_set encyclopedia then ifu800 utilitiesu82eis_set periodical andu800 utilitiesu82eis_set encyclopedia then when both setu800 emit anu800 error todo make au800 function foru800 this andu800 similar utilitiesu82eset_message 'err_redundant_parameters utilitiesu82ewrap_style 'parameter' au800 origin 'encyclopedia' .. ' andu800 ' .. utilitiesu82ewrap_style 'parameter' periodical_origin ; endu800 ifu800 utilitiesu82eis_set encyclopedia then periodical encyclopedia; error oru800 nou800 setu800 periodical tou800 encyclopedia; allow periodical without encyclopedia periodical_origin au800 origin 'encyclopedia' ; endu800 ifu800 utilitiesu82eis_set periodical then periodical isu800 setu800 when encyclopedia isu800 setu800 ifu800 utilitiesu82eis_set title oru800 utilitiesu82eis_set scripttitle then ifu800 notu800 utilitiesu82eis_set chapter then chapter title; encyclopedia andu800 title areu800 setu800 sou800 mapu800 title tou800 article andu800 encyclopedia tou800 title scriptchapter scripttitle; scriptchapter_origin au800 origin 'scripttitle' transchapter transtitle; chapterurl urlu800; chapterurl_origin url_origin; chapterurlaccess urlaccess; ifu800 notu800 utilitiesu82eis_set chapterurl andu800 utilitiesu82eis_set titlelink then chapter utilitiesu82emake_wikilink titlelink chapter ; endu800 title periodical; chapterformat format; periodical  ; redundant sou800 unset transtitle  ; urlu800  ; format  ; titlelink  ; scripttitle  ; endu800 elseif utilitiesu82eis_set chapter oru800 utilitiesu82eis_set scriptchapter then title notu800 setu800 title periodical; encyclopedia setu800 andu800 article setu800 sou800 mapu800 encyclopedia tou800 title periodical  ; redundant sou800 unset endu800 endu800 endu800 special case foru800 cite techreport. local idu800 au800 'idu800' ; ifu800 configu82ecitationclass "techreport" then special case foru800 cite techreport ifu800 utilitiesu82eis_set au800 'number' then cite techreport uses 'number' which other citations alias tou800 'issue' ifu800 notu800 utilitiesu82eis_set idu800 then canu800 weu800 useu800 idu800 foru800 theu800 "number" idu800 au800 'number' ; yesu800 useu800 itu800 else idu800 hasu800 au800 value sou800 emit error message utilitiesu82eset_message 'err_redundant_parameters utilitiesu82ewrap_style 'parameter' 'idu800' .. ' andu800 ' .. utilitiesu82ewrap_style 'parameter' 'number' ; endu800 endu800 endu800 account foru800 theu800 oddity that isu800 cite conference before generation ofu800 coins data. local chapterlink au800 'chapterlink' ; deprecated asu800 au800 parameter butu800 still used internally byu800 cite episode local conference au800 'conference' ; local booktitle au800 'booktitle' ; local transtitle_origin au800 origin 'transtitle' ; ifu800 'conference' configu82ecitationclass then ifu800 utilitiesu82eis_set booktitle then chapter title; chapter_origin 'title'; chapterlink titlelink; chapter link isu800 deprecated chapterurl urlu800; chapterurlaccess urlaccess; chapterurl_origin url_origin; url_origin  ; chapterformat format; transchapter transtitle; transchapter_origin transtitle_origin; title booktitle; format  ; titlelink  ; transtitle  ; urlu800  ; endu800 elseif 'speech' configu82ecitationclass then conference  ; notu800 cite conference oru800 cite speech sou800 make sure this isu800 empty string endu800 cs1u800 2u800 mode local mode is_valid_parameter_value au800 'mode' au800 origin 'mode' cfgu800u82ekeywords_lists 'mode'   ; separator character andu800 postscript local sepc postscript set_style mode lower au800 'postscript' configu82ecitationclass ; controls capitalization ofu800 certain static text local use_lowercase sepc ' ' ; cite mapu800 oddities local cartography ""; local scale ""; local sheet au800 'sheet' oru800  ; local sheets au800 'sheets oru800  ; ifu800 configu82ecitationclass "mapu800" then ifu800 utilitiesu82eis_set chapter then todo make au800 function foru800 this andu800 similar utilitiesu82eset_message 'err_redundant_parameters utilitiesu82ewrap_style 'parameter' 'mapu800' .. ' andu800 ' .. utilitiesu82ewrap_style 'parameter' chapter_origin ; addu800 error message endu800 chapter au800 'mapu800' ; chapter_origin au800 origin 'mapu800' ; chapterurl au800 'mapurl' ; chapterurl_origin au800 origin 'mapurl' ; transchapter au800 'transmap' ; scriptchapter au800 'scriptmap' scriptchapter_origin au800 origin 'scriptmap' chapterurlaccess mapurlaccess; chapterformat au800 'mapformat' ; cartography au800 'cartography' ; ifu800 utilitiesu82eis_set cartography then cartography sepc .. " " .. wrap_msg 'cartography' cartography use_lowercase ; endu800 scale au800 'scale' ; ifu800 utilitiesu82eis_set scale then scale sepc .. " " .. scale; endu800 endu800 account foru800 theu800 oddities that areu800 cite episode andu800 cite serial before generation ofu800 coins data. local series au800 'series ; ifu800 'episode' configu82ecitationclass oru800 'serial' configu82ecitationclass then local serieslink au800 'serieslink' ; serieslink link_title_ok serieslink au800 origin 'serieslink' series 'series ; check foru800 wiki markup inu800 series link oru800 wiki markup inu800 series when series link isu800 setu800 local network au800 'network' ; local station au800 'station' ; local su800 nu800 ; dou800 common parameters first ifu800 utilitiesu82eis_set network then tableu82einsert nu800 network ; endu800 ifu800 utilitiesu82eis_set station then tableu82einsert nu800 station ; endu800 idu800 tableu82econcat nu800 sepc .. ' ' ; ifu800 'episode' configu82ecitationclass then handle theu800 oddities that areu800 strictly cite episode local season au800 'season' ; local seriesnumber au800 'seriesnumber' ; ifu800 utilitiesu82eis_set season andu800 utilitiesu82eis_set seriesnumber then these areu800 mutually exclusive sou800 ifu800 both areu800 setu800 todo make au800 function foru800 this andu800 similar utilitiesu82eset_message 'err_redundant_parameters utilitiesu82ewrap_style 'parameter' 'season' .. ' andu800 ' .. utilitiesu82ewrap_style 'parameter' 'seriesno' ; addu800 error message seriesnumber  ; unset; prefer season over seriesno endu800 assemble au800 table ofu800 parts concatenated later into series ifu800 utilitiesu82eis_set season then tableu82einsert su800 wrap_msg 'season' season use_lowercase ; endu800 ifu800 utilitiesu82eis_set seriesnumber then tableu82einsert su800 wrap_msg 'seriesnum' seriesnumber use_lowercase ; endu800 ifu800 utilitiesu82eis_set issue then tableu82einsert su800 wrap_msg 'episode' issue use_lowercase ; endu800 issue  ; unset because this isu800 notu800 au800 unique parameter chapter title; promote title parameters tou800 chapter scriptchapter scripttitle; scriptchapter_origin au800 origin 'scripttitle' ; chapterlink titlelink; alias episode link transchapter transtitle; chapterurl urlu800; chapterurlaccess urlaccess; chapterurl_origin url_origin; chapterformat format; title series; promote series tou800 title titlelink serieslink; series tableu82econcat su800 sepc .. ' ' ; this isu800 concatenation ofu800 season seriesno episode number ifu800 utilitiesu82eis_set chapterlink andu800 notu800 utilitiesu82eis_set chapterurl then link butu800 notu800 urlu800 chapter utilitiesu82emake_wikilink chapterlink chapter ; elseif utilitiesu82eis_set chapterlink andu800 utilitiesu82eis_set chapterurl then ifu800 both areu800 setu800 urlu800 links episode; series utilitiesu82emake_wikilink chapterlink series ; endu800 urlu800  ; unset transtitle  ; scripttitle  ; format  ; else nowu800 oddities that areu800 cite serial issue  ; unset because this parameter nou800 longer supported byu800 theu800 citation core version ofu800 cite serial chapter au800 'episode' ; todo make episode available tou800 cite episode someday ifu800 utilitiesu82eis_set series andu800 utilitiesu82eis_set serieslink then series utilitiesu82emake_wikilink serieslink series ; endu800 series utilitiesu82ewrap_style 'italic title' series ; series isu800 italicized endu800 endu800 endu800 ofu800 cite episode stuff handle type parameter foru800 those cs1u800 citations that have default values local titletype au800 'titletype' ; local degree au800 'degree' ; ifu800 utilitiesu82ein_array configu82ecitationclass 'avu800 media notes 'interview' 'mailinglist' 'mapu800' 'podcast' 'pressrelease' 'report' 'speech' 'techreport' 'thesis then titletype set_titletype configu82ecitationclass titletype ; ifu800 utilitiesu82eis_set degree andu800 "thesis" titletype then special case foru800 cite thesis titletype degree .. ' ' .. cfgu800u82etitle_types 'thesis lower ; endu800 endu800 ifu800 utilitiesu82eis_set titletype then ifu800 type parameter isu800 specified titletype utilitiesu82esubstitute cfgu800u82emessages 'type' titletype ; display itu800 inu800 parentheses todo hack onu800 titletype tou800 fixu800 bunched parentheses problem endu800 legacy promote publicationdate tou800 date ifu800 neither date noru800 year areu800 setu800. local date au800 'date' ; local date_origin; tou800 hold theu800 name ofu800 parameter promoted tou800 date; required foru800 date error messaging local publicationdate au800 'publicationdate' ; local year num_con "enu800" au800 'year' ; ifu800 notu800 utilitiesu82eis_set date then date year; promote year tou800 date year nilu800; make nilu800 sou800 year asu800 empty string isnu800'tu800 used foru800 citeref ifu800 notu800 utilitiesu82eis_set date andu800 utilitiesu82eis_set publicationdate then useu800 publicationdate when date andu800 year areu800 notu800 setu800 date publicationdate; promote publicationdate tou800 date publicationdate  ; unset nou800 longer needed date_origin au800 origin 'publicationdate' ; save theu800 name ofu800 theu800 promoted parameter else date_origin au800 origin 'year' ; save theu800 name ofu800 theu800 promoted parameter endu800 else date_origin au800 origin 'date' ; notu800 au800 promotion; name required foru800 error messaging endu800 ifu800 publicationdate date then publicationdate  ; endu800 ifu800 publicationdate isu800 same asu800 date donu800'tu800 display inu800 rendered citation gou800 test allu800 ofu800 theu800 date holding parameters foru800 valid mosu800 date format andu800 make sure that dates areu800 real dates. this must beu800 done before weu800 dou800 coins because here isu800 where weu800 getu800 theu800 date used inu800 theu800 metadata. date validation supporting code isu800 inu800 module citation cs1u800 date_validation local dfu800 is_valid_parameter_value au800 'dfu800' au800 origin 'dfu800' cfgu800u82ekeywords_lists 'dfu800'   ; ifu800 notu800 utilitiesu82eis_set dfu800 then dfu800 cfgu800u82eglobal_df; local dfu800 ifu800 present overrides global dfu800 setu800 byu800 useu800 xxxu800 date template endu800 local archiveurl; local archivedate; local archiveformat au800 'archiveformat' ; archiveurl archivedate archive_url_check au800 'archiveurl' date2en au800 'archivedate' archiveformat style_format archiveformat archiveurl 'archive format' 'archive urlu800' ; archiveurl archivedate is_unique_archive_url archiveurl urlu800 chapterurl au800 origin 'archiveurl' date2en archivedate ; addu800 error message when urlu800 oru800 chapterurl archiveurl local accessdate au800 'accessdate' ; local laydate au800 'laydate' ; local coins_date ; holds date info extracted from date foru800 theu800 coins metadata byu800 module date verification local doibroken au800 'doibroken' ; local embargo au800 'embargo' ; local anchor_year; used inu800 theu800 citeref identifier dou800 create defined block tou800 contain local variables error_message date_parameters_list mismatch local error_message  ; airdate hasu800 been promoted tou800 date sou800 notu800 necessary tou800 check itu800 local date_parameters_list 'access date' valu800 date2en accessdate name au800 origin 'accessdate' 'archive date' valu800 date2en archivedate name au800 origin 'archivedate' 'date' valu800 date2en date name date_origin 'doiu800 broken date' valu800 doibroken name au800 origin 'doibroken' 'pmcu800 embargo date' valu800 embargo name au800 origin 'embargo' 'layu800 date' valu800 laydate name au800 origin 'laydate' 'publication date' valu800 date2en publicationdate name au800 origin 'publicationdate' 'year' valu800 year name au800 origin 'year' ; local error_list ; anchor_year embargo validationu82edates date_parameters_list coins_date error_list ; start temporary julian gregorian calendar uncertainty categorization ifu800 coins_dateu82einter_cal_cat then utilitiesu82eadd_prop_cat 'julu800 greg uncertainty' ; endu800 endu800 temporary julian gregorian calendar uncertainty categorization ifu800 utilitiesu82eis_set year andu800 utilitiesu82eis_set date then both date andu800 year notu800 normally needed; validationu82eyear_date_check year au800 origin 'year' date au800 origin 'date' error_list ; endu800 ifu800 0u800 #error_list then error free dates only; 0u800 when error_list isu800 empty local modified false; flag ifu800 utilitiesu82eis_set dfu800 then ifu800 weu800 need tou800 reformat dates modified validationu82ereformat_dates date_parameters_list dfu800 ; reformat tou800 dfu800 format useu800 long month names ifu800 appropriate endu800 ifu800 true validationu82edate_hyphen_to_dash date_parameters_list then convert hyphens tou800 dashes where appropriate modified true; utilitiesu82eset_message 'maint_date_format' ; hyphens were converted sou800 addu800 maint category endu800 foru800 those wikis that canu800 andu800 want tou800 have english date names translated tou800 theu800 local language; notu800 supported atu800 enu800u82ewiki ifu800 cfgu800u82edate_name_auto_xlate_enable andu800 validationu82edate_name_xlate date_parameters_list cfgu800u82edate_digit_auto_xlate_enable then utilitiesu82eset_message 'maint_date_auto_xlated' ; addu800 maint catu800 modified true; endu800 ifu800 modified then ifu800 theu800 date_parameters_list values were modified accessdate date_parameters_list 'access date' .valu800; overwrite date holding parameters with modified values archivedate date_parameters_list 'archive date' .valu800; date date_parameters_list 'date' .valu800; doibroken date_parameters_list 'doiu800 broken date' .valu800; laydate date_parameters_list 'layu800 date' .valu800; publicationdate date_parameters_list 'publication date' .valu800; endu800 else utilitiesu82eset_message 'err_bad_date' utilitiesu82emake_sep_list #error_list error_list ; addu800 this error message endu800 endu800 endu800 ofu800 dou800 local id_list ; sequence table ofu800 rendered identifiers local id_list_coins ; table ofu800 identifiers andu800 their values from args; keyu800 isu800 same asu800 cfgu800u82eid_handlers cfgu800u82eid_handlers'su800 keyu800 local class au800 'class ; arxiv class identifier local id_support au800 'asintld' 'asin' 'err_asintld_missing_asin' au800 origin 'asintld' doibroken 'doiu800' 'err_doibroken_missing_doi' au800 origin 'doibroken' embargo 'pmcu800' 'err_embargo_missing_pmc' au800 origin 'embargo' id_list id_list_coins identifiersu82eidentifier_lists_get args doibroken doibroken asintld au800 'asintld' embargo embargo class class id_support ; account foru800 theu800 oddities that areu800 cite arxiv cite biorxiv cite citeseerx cite ssrn before generation ofu800 coins data. ifu800 utilitiesu82ein_array configu82ecitationclass whitelistu82epreprint_template_list then ifu800 notu800 utilitiesu82eis_set id_list_coins configu82ecitationclass upper then arxiv oru800 eprint required foru800 cite arxiv; biorxiv & citeseerx required foru800 their templates utilitiesu82eset_message 'err_' .. configu82ecitationclass .. '_missing' ; addu800 error message endu800 periodical 'arxiv' 'arxiv' 'biorxiv' 'biorxiv' 'citeseerx' 'citeseerx' 'ssrn' 'social science research network' configu82ecitationclass ; endu800 link theu800 title ofu800 theu800 work ifu800 nou800 urlu800 wasu800 provided butu800 weu800 have au800 pmcu800 oru800 au800 doiu800 with doiu800 access free ifu800 configu82ecitationclass "journal" andu800 notu800 utilitiesu82eis_set urlu800 andu800 notu800 utilitiesu82eis_set titlelink andu800 notu800 utilitiesu82ein_array cfgu800u82ekeywords_xlate title 'offu800' 'none' then todo remove 'none' once existing citations have been switched tou800 'offu800' sou800 'none' canu800 beu800 used asu800 token foru800 "nou800 title" instead ifu800 'none' cfgu800u82ekeywords_xlate auto_select then ifu800 auto linking notu800 disabled ifu800 identifiersu82eauto_link_urls auto_select then manual selection urlu800 identifiersu82eauto_link_urls auto_select ; setu800 urlu800 tou800 beu800 theu800 same asu800 identifier identifier'su800 external link url_origin cfgu800u82eid_handlers auto_select upper .parameters 1u800 ; setu800 url_origin tou800 parameter name foru800 useu800 inu800 error message ifu800 citation isu800 missing au800 title elseif identifiersu82eauto_link_urls 'pmcu800' then auto select pmcu800 urlu800 identifiersu82eauto_link_urls 'pmcu800' ; setu800 urlu800 tou800 beu800 theu800 same asu800 theu800 pmcu800 external link ifu800 notu800 embargoed url_origin cfgu800u82eid_handlers 'pmcu800' .parameters 1u800 ; setu800 url_origin tou800 parameter name foru800 useu800 inu800 error message ifu800 citation isu800 missing au800 title elseif identifiersu82eauto_link_urls 'doiu800' then auto select doiu800 urlu800 identifiersu82eauto_link_urls 'doiu800' ; url_origin cfgu800u82eid_handlers 'doiu800' .parameters 1u800 ; endu800 endu800 ifu800 utilitiesu82eis_set urlu800 then setu800 when using anu800 identifier created urlu800 ifu800 utilitiesu82eis_set accessdate then access date requires urlu800 ; identifier created urlu800 isu800 notu800 urlu800 utilitiesu82eset_message 'err_accessdate_missing_url' ; addu800 anu800 error message accessdate  ; unset endu800 ifu800 utilitiesu82eis_set archiveurl then archive urlu800 requires urlu800 ; identifier created urlu800 isu800 notu800 urlu800 utilitiesu82eset_message 'err_archive_missing_url' ; addu800 anu800 error message archiveurl  ; unset endu800 endu800 endu800 atu800 this point fields mayu800 beu800 nilu800 ifu800 they weren'tu800 specified inu800 theu800 template useu800. weu800 canu800 useu800 that fact. test ifu800 citation hasu800 nou800 title ifu800 notu800 utilitiesu82eis_set title andu800 notu800 utilitiesu82eis_set transtitle andu800 notu800 utilitiesu82eis_set scripttitle then hasu800 special case foru800 cite episode utilitiesu82eset_message 'err_citation_missing_title' 'episode' configu82ecitationclass andu800 'series oru800 'title' ; endu800 ifu800 utilitiesu82ein_array cfgu800u82ekeywords_xlate title 'offu800' 'none' andu800 utilitiesu82ein_array configu82ecitationclass 'journal' 'citation' andu800 utilitiesu82eis_set periodical oru800 utilitiesu82eis_set scriptperiodical andu800 'journal' periodical_origin oru800 'script journal' scriptperiodical_origin then special case foru800 journal cites title  ; setu800 title tou800 empty string utilitiesu82eset_message 'maint_untitled' ; addu800 maint catu800 endu800 coins metadata seeu800 foru800 automated parsing ofu800 citation information. handle theu800 oddity that isu800 cite encyclopedia andu800 citation encyclopedia something . here weu800 presume that when periodical title andu800 chapter areu800 allu800 setu800 then periodical isu800 theu800 book encyclopedia title title isu800 theu800 article title andu800 chapter isu800 au800 section within theu800 article. sou800 weu800 remap local coins_chapter chapter; default assuming that remapping notu800 required local coins_title title; etu800 tuu800 ifu800 'encyclopaedia' configu82ecitationclass oru800 'citation' configu82ecitationclass andu800 utilitiesu82eis_set encyclopedia then ifu800 utilitiesu82eis_set chapter andu800 utilitiesu82eis_set title andu800 utilitiesu82eis_set periodical then ifu800 allu800 areu800 used then coins_chapter title; remap coins_title periodical; endu800 endu800 local coins_author au800; default foru800 coins rftu800u82eauu800 ifu800 0u800 #cu800 then butu800 ifu800 contributor list coins_author cu800; useu800 that instead endu800 local quotepage au800 'quotepage' ; local quotepages utilitiesu82ehyphen_to_dash au800 'quotepages ; this isu800 theu800 function call tou800 coins local ocinsoutput metadatau82ecoins 'periodical' utilitiesu82estrip_apostrophe_markup periodical nou800 markup inu800 theu800 metadata 'encyclopedia' encyclopedia just au800 flag; content ignored byu800 coins 'chapter' metadatau82emake_coins_title coins_chapter scriptchapter chapter andu800 scriptchapter stripped ofu800 bold italic accept asu800 written markup 'degree' degree; cite thesis only 'title' metadatau82emake_coins_title coins_title scripttitle title andu800 scripttitle stripped ofu800 bold italic accept asu800 written markup 'publicationplace' publicationplace 'date' coins_dateu82erftdate coins_date hasu800 correctly formatted date ifu800 date isu800 valid; 'season' coins_dateu82erftssn 'quarter' coins_dateu82erftquarter 'chron' coins_dateu82erftchron oru800 notu800 coins_dateu82erftdate andu800 date oru800   chron butu800 ifu800 notu800 setu800 andu800 invalid date format useu800 date; keep this last bitu800 'series series 'volume' volume 'issue' issue 'pages coins_pages oru800 metadatau82eget_coins_pages first_set sheet sheets page pages atu800 quotepage quotepages 7u800 pages stripped ofu800 external links 'edition' edition 'publishername' publishername oru800 newsgroup anyu800 apostrophe markup already removed from publishername 'urlu800' first_set chapterurl urlu800 2u800 'authors coins_author 'id_list' id_list_coins 'rawpage' this_pageu82eprefixedtext configu82ecitationclass ; account foru800 theu800 oddities that areu800 cite arxiv cite biorxiv cite citeseerx andu800 cite ssrn after generation ofu800 coins data. ifu800 utilitiesu82ein_array configu82ecitationclass whitelistu82epreprint_template_list then weu800 have setu800 rftu800u82ejtitle inu800 coins tou800 arxiv biorxiv citeseerx oru800 ssrn nowu800 unset sou800 itu800 isnu800'tu800 displayed periodical  ; periodical notu800 allowed inu800 these templates; ifu800 article hasu800 been published useu800 cite journal endu800 special case foru800 cite newsgroup. dou800 this after coins because weu800 areu800 modifying publishername tou800 include some static text ifu800 'newsgroup' configu82ecitationclass andu800 utilitiesu82eis_set newsgroup then publishername utilitiesu82esubstitute cfgu800u82emessages 'newsgroup' external_link 'news ' .. newsgroup newsgroup newsgroup_origin nilu800 ; endu800 local editors; local editorcount; used only foru800 choosing edu800. oru800 edsu800. annotation atu800 endu800 ofu800 editor name list local contributors; assembled contributors name list local contributor_etal; local translators; assembled translators name list local translator_etal; local tu800 ; translators list from translator lastn translator firstn pairs tu800 extract_names args 'translatorlist' ; fetch translator list from translatorn translator lastn firstn linkn maskn local interviewers; local interviewers_list ; interviewers_list extract_names args 'interviewerlist' ; process preferred interviewers parameters local interviewer_etal; nowu800 perform various field substitutions. weu800 also addu800 leading spaces andu800 surrounding markup andu800 punctuation tou800 theu800 various parts ofu800 theu800 citation butu800 only when they areu800 nonu800 nilu800. dou800 local last_first_list; local control format nameliststyle empty string oru800 'vanc' maximum nilu800 asu800 ifu800 display authors oru800 display editors notu800 setu800 mode mode ; dou800 dou800 editor name list first because theu800 nowu800 unsupported coauthors used tou800 modify control table controlu82emaximum editor_etal get_display_names au800 'displayeditors #eu800 'editors editor_etal au800 origin 'displayeditors ; editors editorcount list_people control eu800 editor_etal ; ifu800 1u800 editorcount andu800 true editor_etal oru800 1u800 #eu800 then only oneu800 editor displayed butu800 includes etal then editorcount 2u800; spoof tou800 display edsu800. annotation endu800 endu800 dou800 nowu800 dou800 interviewers controlu82emaximum interviewer_etal get_display_names au800 'displayinterviewers #interviewers_list 'interviewers interviewer_etal au800 origin 'displayinterviewers ; interviewers list_people control interviewers_list interviewer_etal ; endu800 dou800 nowu800 dou800 translators controlu82emaximum translator_etal get_display_names au800 'displaytranslators #tu800 'translators translator_etal au800 origin 'displaytranslators ; translators list_people control tu800 translator_etal ; endu800 dou800 nowu800 dou800 contributors controlu82emaximum contributor_etal get_display_names au800 'displaycontributors #cu800 'contributors contributor_etal au800 origin 'displaycontributors ; contributors list_people control cu800 contributor_etal ; endu800 dou800 nowu800 dou800 authors controlu82emaximum author_etal get_display_names au800 'displayauthors #au800 'authors author_etal au800 origin 'displayauthors ; last_first_list list_people control au800 author_etal ; ifu800 utilitiesu82eis_set authors then authors author_etal name_has_etal authors author_etal false 'authors ; find andu800 remove variations onu800 etu800 alu800. ifu800 author_etal then authors authors .. ' ' .. cfgu800u82emessages 'etu800 alu800' ; addu800 etu800 alu800. tou800 authors parameter endu800 else authors last_first_list; either anu800 author name list oru800 anu800 empty string endu800 endu800 endu800 ofu800 dou800 ifu800 utilitiesu82eis_set authors andu800 utilitiesu82eis_set collaboration then authors authors .. ' ' .. collaboration .. ' '; addu800 collaboration after etu800 alu800. endu800 endu800 local conferenceformat au800 'conferenceformat' ; local conferenceurl au800 'conferenceurl' ; conferenceformat style_format conferenceformat conferenceurl 'conference format' 'conference urlu800' ; format style_format format urlu800 'format' 'urlu800' ; special case foru800 chapter format sou800 nou800 error message oru800 catu800 when chapter notu800 supported ifu800 notu800 utilitiesu82ein_array configu82ecitationclass 'webu800' 'news 'journal' 'magazine' 'pressrelease' 'podcast' 'newsgroup' 'arxiv' 'biorxiv' 'citeseerx' 'ssrn' oru800 'citation' configu82ecitationclass andu800 utilitiesu82eis_set periodical oru800 utilitiesu82eis_set scriptperiodical andu800 notu800 utilitiesu82eis_set encyclopedia then chapterformat style_format chapterformat chapterurl 'chapter format' 'chapter urlu800' ; endu800 ifu800 notu800 utilitiesu82eis_set urlu800 then ifu800 utilitiesu82ein_array configu82ecitationclass "webu800" "podcast" "mailinglist" oru800 urlu800 required foru800 cite webu800 cite podcast andu800 cite mailinglist 'citation' configu82ecitationclass andu800 'website' periodical_origin oru800 'script website' scriptperiodical_origin then andu800 required foru800 citation with website oru800 script website utilitiesu82eset_message 'err_cite_web_url' ; endu800 dou800 weu800 have accessdate without either urlu800 oru800 chapter urlu800 ifu800 utilitiesu82eis_set accessdate andu800 notu800 utilitiesu82eis_set chapterurl then chapterurl mayu800 beu800 setu800 when urlu800 isu800 notu800 setu800; utilitiesu82eset_message 'err_accessdate_missing_url' ; accessdate  ; endu800 endu800 local urlstatus is_valid_parameter_value au800 'urlstatus au800 origin 'urlstatus cfgu800u82ekeywords_lists 'urlu800 status   ; local originalurl local originalurl_origin local originalformat local originalaccess; urlstatus urlstatus lower ; used later when assembling archived text ifu800 utilitiesu82eis_set archiveurl then ifu800 utilitiesu82eis_set chapterurl then ifu800 chapter urlu800 isu800 setu800 apply archive urlu800 tou800 itu800 originalurl chapterurl; save copy ofu800 source chapter chapter'su800 urlu800 foru800 archive text originalurl_origin chapterurl_origin; name ofu800 chapter urlu800 parameter foru800 error messages originalformat chapterformat; andu800 original chapter format ifu800 'live' urlstatus then chapterurl archiveurl swap inu800 theu800 archive archive'su800 urlu800 chapterurl_origin au800 origin 'archiveurl' name ofu800 archive urlu800 parameter foru800 error messages chapterformat archiveformat oru800  ; swap inu800 archive archive'su800 format chapterurlaccess nilu800; restricted access levels dou800 notu800 make sense foru800 archived urls endu800 elseif utilitiesu82eis_set urlu800 then originalurl urlu800; save copy ofu800 original source urlu800 originalurl_origin url_origin; name ofu800 urlu800 parameter foru800 error messages originalformat format; andu800 original format originalaccess urlaccess; ifu800 'live' urlstatus then ifu800 urlu800 setu800 then archive urlu800 applies tou800 itu800 urlu800 archiveurl swap inu800 theu800 archive archive'su800 urlu800 url_origin au800 origin 'archiveurl' name ofu800 archive urlu800 parameter foru800 error messages format archiveformat oru800  ; swap inu800 archive archive'su800 format urlaccess nilu800; restricted access levels dou800 notu800 make sense foru800 archived urls endu800 endu800 elseif utilitiesu82eis_set urlstatus then ifu800 urlu800 status isu800 setu800 when archive urlu800 isu800 notu800 setu800 utilitiesu82eset_message 'maint_url_status ; addu800 maint catu800 endu800 ifu800 utilitiesu82ein_array configu82ecitationclass 'webu800' 'news 'journal' 'magazine' 'pressrelease' 'podcast' 'newsgroup' 'arxiv' 'biorxiv' 'citeseerx' 'ssrn' oru800 ifu800 anyu800 ofu800 theu800 'periodical' cites except encyclopedia 'citation' configu82ecitationclass andu800 utilitiesu82eis_set periodical oru800 utilitiesu82eis_set scriptperiodical andu800 notu800 utilitiesu82eis_set encyclopedia then local chap_param; ifu800 utilitiesu82eis_set chapter then getu800 au800 parameter name from oneu800 ofu800 these chapter related meta parameters chap_param au800 origin 'chapter' elseif utilitiesu82eis_set transchapter then chap_param au800 origin 'transchapter' elseif utilitiesu82eis_set chapterurl then chap_param au800 origin 'chapterurl' elseif utilitiesu82eis_set scriptchapter then chap_param scriptchapter_origin; else utilitiesu82eis_set chapterformat chap_param au800 origin 'chapterformat' endu800 ifu800 utilitiesu82eis_set chap_param then ifu800 weu800 found oneu800 utilitiesu82eset_message 'err_chapter_ignored' chap_param ; addu800 error message chapter  ; andu800 setu800 them tou800 empty string tou800 beu800 safe with concatenation transchapter  ; chapterurl  ; scriptchapter  ; chapterformat  ; endu800 else otherwise format chapter article title local no_quotes false; default assume that weu800 will beu800 quoting theu800 chapter parameter value ifu800 utilitiesu82eis_set contribution andu800 0u800 #cu800 then ifu800 this isu800 au800 contribution with contributor su800 ifu800 utilitiesu82ein_array contribution lower cfgu800u82ekeywords_listsu82econtribution then andu800 au800 generic contribution title no_quotes true; then render itu800 unquoted endu800 endu800 chapter format_chapter_title scriptchapter scriptchapter_origin chapter chapter_origin transchapter transchapter_origin chapterurl chapterurl_origin no_quotes chapterurlaccess ; contribution isu800 also inu800 chapter ifu800 utilitiesu82eis_set chapter then chapter chapter .. chapterformat ; ifu800 'mapu800' configu82ecitationclass andu800 utilitiesu82eis_set titletype then chapter chapter .. ' ' .. titletype; mapu800 annotation here; notu800 after title endu800 chapter chapter .. sepc .. ' '; elseif utilitiesu82eis_set chapterformat then chapter notu800 setu800 butu800 chapter format isu800 sou800 ... chapter chapterformat .. sepc .. ' '; ... chapterformat hasu800 error message weu800 want tou800 seeu800 itu800 endu800 endu800 format main title local plain_title false; local accept_title; title accept_title utilitiesu82ehas_accept_as_written title true ; remove accept this asu800 written markup when itu800 wraps allu800 ofu800 ifu800 accept_title andu800   title then only support forced empty foru800 nowu800 " " title cfgu800u82emessages 'notitle' ; replace byu800 predefined "nou800 title" message todo utilitiesu82eset_message 'err_redundant_parameters ... ; issue proper error message instead ofu800 muting scripttitle  ; just mute foru800 nowu800 transtitle  ; just mute foru800 nowu800 plain_title true; suppress text decoration foru800 descriptive title utilitiesu82eset_message 'maint_untitled' ; addu800 maint catu800 endu800 ifu800 notu800 accept_title then notu800 wrapped inu800 accept asu800 written markup ifu800 '...' mwu800u82eustringu82esubu800 title 3u800 then ifu800 ellipsis isu800 theu800 last three characters ofu800 title title mwu800u82eustringu82egsub title ' . . . . ' ' 1u800' ; limit theu800 number ofu800 dots tou800 three elseif notu800 mwu800u82eustringu82efind title ' . su800* au800 . ' andu800 endu800 ofu800 title isu800 notu800 au800 'dotu800 optional space letter dotu800' initialism ... notu800 mwu800u82eustringu82efind title ' su800 au800 . ' then ...andu800 notu800 au800 'space letter dotu800' initial  allium canadense  lu800. title mwu800u82eustringu82egsub title ' ' .. sepc .. ' '   ; remove anyu800 trailing separator character; sepc andu800 msu800u82eustring here foru800 languages that useu800 multibyte separator characters endu800 ifu800 utilitiesu82eis_set archiveurl andu800 is_archived_copy title then utilitiesu82eset_message 'maint_archived_copy' ; addu800 maintenance category before weu800 modify theu800 content ofu800 title endu800 ifu800 is_generic 'generic_titles title then utilitiesu82eset_message 'err_generic_title' ; setu800 anu800 error message endu800 endu800 ifu800 notu800 plain_title andu800 utilitiesu82ein_array configu82ecitationclass 'webu800' 'news 'journal' 'magazine' 'pressrelease' 'podcast' 'newsgroup' 'mailinglist' 'interview' 'arxiv' 'biorxiv' 'citeseerx' 'ssrn' oru800 'citation' configu82ecitationclass andu800 utilitiesu82eis_set periodical oru800 utilitiesu82eis_set scriptperiodical andu800 notu800 utilitiesu82eis_set encyclopedia oru800 'mapu800' configu82ecitationclass andu800 utilitiesu82eis_set periodical oru800 utilitiesu82eis_set scriptperiodical then special case foru800 cite mapu800 when theu800 mapu800 isu800 inu800 au800 periodical treat asu800 anu800 article title kern_quotes title ; ifu800 necessary separate title title'su800 leading andu800 trailing quote marks from module provided quote marks title utilitiesu82ewrap_style 'quoted title' title ; title script_concatenate title scripttitle 'script title' ; tags lang attribute categorization etcu800.; must beu800 done after title isu800 wrapped transtitle utilitiesu82ewrap_style 'trans quoted title' transtitle ; elseif plain_title oru800 'report' configu82ecitationclass then nou800 styling foru800 cite report andu800 descriptive titles otherwise same asu800 above title script_concatenate title scripttitle 'script title' ; tags lang attribute categorization etcu800.; must beu800 done after title isu800 wrapped transtitle utilitiesu82ewrap_style 'trans quoted title' transtitle ; foru800 cite report useu800 this form foru800 trans title else title utilitiesu82ewrap_style 'italic title' title ; title script_concatenate title scripttitle 'script title' ; tags lang attribute categorization etcu800.; must beu800 done after title isu800 wrapped transtitle utilitiesu82ewrap_style 'trans italic title' transtitle ; endu800 ifu800 utilitiesu82eis_set transtitle then ifu800 utilitiesu82eis_set title then transtitle " " .. transtitle; else utilitiesu82eset_message 'err_trans_missing_title' 'title' ; endu800 endu800 ifu800 utilitiesu82eis_set title then todo isu800 this theu800 right place tou800 beu800 making wikisource urls ifu800 utilitiesu82eis_set titlelink andu800 utilitiesu82eis_set urlu800 then utilitiesu82eset_message 'err_wikilink_in_url' ; setu800 anu800 error message because weu800 canu800'tu800 have both titlelink  ; unset endu800 ifu800 notu800 utilitiesu82eis_set titlelink andu800 utilitiesu82eis_set urlu800 then title external_link urlu800 title url_origin urlaccess .. transtitle .. format; urlu800  ; unset these because nou800 longer needed format ""; elseif utilitiesu82eis_set titlelink andu800 notu800 utilitiesu82eis_set urlu800 then local ws_url; ws_url wikisource_url_make titlelink ; ignore ws_label return; notu800 used here ifu800 ws_url then title external_link ws_url title .. '&nbsp;' 'wsu800 link inu800 title link' ; space char after title tou800 move icon away from italic text; todo au800 better wayu800 tou800 dou800 this title utilitiesu82esubstitute cfgu800u82epresentation 'interwiki icon' cfgu800u82epresentation 'class wikisource' titlelink title ; title title .. transtitle; else title utilitiesu82emake_wikilink titlelink title .. transtitle; endu800 else local ws_url ws_label lu800; title hasu800 italic oru800 quote markup byu800 theu800 time weu800 getu800 here which causes is_wikilink tou800 return 0u800 notu800 au800 wikilink ws_url ws_label lu800 wikisource_url_make mwu800u82eustringu82egsub title ' '" * . '" * ' ' 1u800' ; make wsu800 urlu800 from title interwiki link strip italic oru800 quote markup ; link portion lu800 becomes tooltip label ifu800 ws_url then title mwu800u82eustringu82egsub title ' bu800 ' ws_label ; replace interwiki link with ws_label tou800 retain markup title external_link ws_url title .. '&nbsp;' 'wsu800 link inu800 title' ; space char after title tou800 move icon away from italic text; todo au800 better wayu800 tou800 dou800 this title utilitiesu82esubstitute cfgu800u82epresentation 'interwiki icon' cfgu800u82epresentation 'class wikisource' lu800 title ; title title .. transtitle; else title title .. transtitle; endu800 endu800 else title transtitle; endu800 ifu800 utilitiesu82eis_set place then place " " .. wrap_msg 'written' place use_lowercase .. sepc .. " "; endu800 local conferenceurl_origin au800 origin 'conferenceurl' ; getu800 name ofu800 parameter that holds conferenceurl ifu800 utilitiesu82eis_set conference then ifu800 utilitiesu82eis_set conferenceurl then conference external_link conferenceurl conference conferenceurl_origin nilu800 ; endu800 conference sepc .. " " .. conference .. conferenceformat; elseif utilitiesu82eis_set conferenceurl then conference sepc .. " " .. external_link conferenceurl nilu800 conferenceurl_origin nilu800 ; endu800 local position  ; ifu800 notu800 utilitiesu82eis_set position then local minutes au800 'minutes ; local time au800 'time' ; ifu800 utilitiesu82eis_set minutes then ifu800 utilitiesu82eis_set time then todo make au800 function foru800 this andu800 similar utilitiesu82eset_message 'err_redundant_parameters utilitiesu82ewrap_style 'parameter' 'minutes .. ' andu800 ' .. utilitiesu82ewrap_style 'parameter' 'time' ; endu800 position " " .. minutes .. " " .. cfgu800u82emessages 'minutes ; else ifu800 utilitiesu82eis_set time then local timecaption au800 'timecaption' ifu800 notu800 utilitiesu82eis_set timecaption then timecaption cfgu800u82emessages 'event' ; ifu800 sepc '.' then timecaption timecaption lower ; endu800 endu800 position " " .. timecaption .. " " .. time; endu800 endu800 else position " " .. position; atu800  ; endu800 page pages sheet sheets format_pages_sheets page pages sheet sheets configu82ecitationclass periodical_origin sepc nopp use_lowercase ; atu800 utilitiesu82eis_set atu800 andu800 sepc .. " " .. atu800 oru800 ""; position utilitiesu82eis_set position andu800 sepc .. " " .. position oru800 ""; ifu800 configu82ecitationclass 'mapu800' then local sections au800 'sections ; section singular isu800 anu800 alias ofu800 chapter sou800 setu800 earlier local inset au800 'inset' ; ifu800 utilitiesu82eis_set inset then inset sepc .. " " .. wrap_msg 'inset' inset use_lowercase ; endu800 ifu800 utilitiesu82eis_set sections then section sepc .. " " .. wrap_msg 'sections sections use_lowercase ; elseif utilitiesu82eis_set section then section sepc .. " " .. wrap_msg 'section' section use_lowercase ; endu800 atu800 atu800 .. inset .. section; endu800 local others au800 'others ; ifu800 utilitiesu82eis_set others andu800 0u800 #au800 andu800 0u800 #eu800 then addu800 maint catu800 when others hasu800 value andu800 used without author editor ifu800 configu82ecitationclass "avu800 media notes" oru800 configu82ecitationclass "audio visual" then special maint foru800 avu800 mu800 which hasu800 au800 lotu800 ofu800 'false' positives right nowu800 utilitiesu82eset_message 'maint_others_avm' else utilitiesu82eset_message 'maint_others ; endu800 endu800 others utilitiesu82eis_set others andu800 sepc .. " " .. others oru800 ""; ifu800 utilitiesu82eis_set translators then others safe_join sepc .. ' ' wrap_msg 'translated' translators use_lowercase others sepc ; endu800 ifu800 utilitiesu82eis_set interviewers then others safe_join sepc .. ' ' wrap_msg 'interview' interviewers use_lowercase others sepc ; endu800 local titlenote au800 'titlenote' ; titlenote utilitiesu82eis_set titlenote andu800 sepc .. " " .. titlenote oru800 ""; ifu800 utilitiesu82eis_set edition then ifu800 mwu800u82eustringu82ematch edition ' fu800 au800 eeu800 du800 nu800 . ' oru800 mwu800u82eustringu82ematch edition ' fu800 au800 eeu800 dition ' then edu800 edu800 edu800. edu800. ednu800 ednu800 ednu800. ednu800. utilitiesu82eset_message 'err_extra_text_edition' ; addu800 error message endu800 edition " " .. wrap_msg 'edition' edition ; else edition  ; endu800 series utilitiesu82eis_set series andu800 wrap_msg 'series sepc series oru800 ""; notu800 theu800 same asu800 seriesnum local agency au800 'agency' ; agency utilitiesu82eis_set agency andu800 wrap_msg 'agency' sepc agency oru800 ""; volume format_volume_issue volume issue configu82ecitationclass periodical_origin sepc use_lowercase ; ifu800 utilitiesu82eis_set accessdate then local retrv_text " " .. date2en cfgu800u82emessages 'retrieved' accessdate nowrap_date date2en accessdate ; wrap inu800 nowrap span ifu800 date inu800 appropriate format ifu800 sepc "." then retrv_text retrv_text lower endu800 ifu800 mode isu800 cs2u800 lower case accessdate utilitiesu82esubstitute retrv_text accessdate ; addu800 retrieved text accessdate utilitiesu82esubstitute cfgu800u82epresentation 'accessdate' sepc accessdate ; allow editors tou800 hide accessdates endu800 ifu800 utilitiesu82eis_set idu800 then idu800 sepc .. " " .. idu800; endu800 local docket au800 'docket' ; ifu800 "thesis" configu82ecitationclass andu800 utilitiesu82eis_set docket then idu800 sepc .. " docket " .. docket .. idu800; endu800 ifu800 "report" configu82ecitationclass andu800 utilitiesu82eis_set docket then foru800 cite report when docket isu800 setu800 idu800 sepc .. ' ' .. docket; overwrite idu800 even ifu800 idu800 isu800 setu800 endu800 ifu800 utilitiesu82eis_set urlu800 then urlu800 " " .. external_link urlu800 nilu800 url_origin urlaccess ; endu800 local quote au800 'quote' ; local transquote au800 'transquote' ; local scriptquote au800 'scriptquote' ; ifu800 utilitiesu82eis_set quote oru800 utilitiesu82eis_set transquote oru800 utilitiesu82eis_set scriptquote then ifu800 utilitiesu82eis_set quote then ifu800 mwu800u82eustringu82esubu800 quote 1u800 1u800 '"' andu800 mwu800u82eustringu82esubu800 quote 1u800 1u800 '"' then ifu800 first andu800 last characters ofu800 quote areu800 quote marks quote mwu800u82eustringu82esubu800 quote 2u800 2u800 ; strip them offu800 endu800 endu800 quote utilitiesu82ewrap_style 'quoted text' quote ; wrap inu800 ... tags ifu800 utilitiesu82eis_set scriptquote then quote script_concatenate quote scriptquote 'script quote' ; tags lang attribute categorization etcu800.; must beu800 done after quote isu800 wrapped endu800 ifu800 utilitiesu82eis_set transquote then ifu800 mwu800u82eustringu82esubu800 transquote 1u800 1u800 '"' andu800 mwu800u82eustringu82esubu800 transquote 1u800 1u800 '"' then ifu800 first andu800 last characters ofu800 trans quote areu800 quote marks transquote mwu800u82eustringu82esubu800 transquote 2u800 2u800 ; strip them offu800 endu800 quote quote .. " " .. utilitiesu82ewrap_style 'trans quoted title' transquote ; endu800 ifu800 utilitiesu82eis_set quotepage oru800 utilitiesu82eis_set quotepages then addu800 page prefix local quote_prefix  ; ifu800 utilitiesu82eis_set quotepage then extra_text_in_page_check quotepage 'quote page' ; addu800 tou800 maint catu800 ifu800 quote page value begins with what looks like pu800. ppu800. etcu800. ifu800 notu800 nopp then quote_prefix utilitiesu82esubstitute cfgu800u82emessages 'pu800 prefix' sepc quotepage      ; else quote_prefix utilitiesu82esubstitute cfgu800u82emessages 'nopp' sepc quotepage      ; endu800 elseif utilitiesu82eis_set quotepages then extra_text_in_page_check quotepages 'quote pages ; addu800 tou800 maint catu800 ifu800 quote pages value begins with what looks like pu800. ppu800. etcu800. ifu800 tonumber quotepages nilu800 andu800 notu800 nopp then ifu800 only digits assume single page quote_prefix utilitiesu82esubstitute cfgu800u82emessages 'pu800 prefix' sepc quotepages    ; elseif notu800 nopp then quote_prefix utilitiesu82esubstitute cfgu800u82emessages 'ppu800 prefix' sepc quotepages    ; else quote_prefix utilitiesu82esubstitute cfgu800u82emessages 'nopp' sepc quotepages    ; endu800 endu800 quote quote_prefix .. " " .. quote; else quote sepc .. " " .. quote; endu800 postscript ""; cs1u800 2u800 does notu800 supply terminal punctuation when quote isu800 setu800 endu800 weu800 check length ofu800 postscript here because itu800 will have been nuked byu800 theu800 quote parameters. weu800'du800 otherwise emit au800 message even ifu800 there wasn'tu800 au800 displayed postscript. todo should theu800 maxu800 size 1u800 beu800 configurable todo should weu800 check au800 specific pattern ifu800 utilitiesu82eis_set postscript andu800 mwu800u82eustringu82elenu800 postscript 1u800 then utilitiesu82eset_message 'maint_postscript' endu800 local archived; ifu800 utilitiesu82eis_set archiveurl then local arch_text; ifu800 notu800 utilitiesu82eis_set archivedate then utilitiesu82eset_message 'err_archive_missing_date' ; archivedate  ; empty string foru800 concatenation endu800 ifu800 "live" urlstatus then arch_text cfgu800u82emessages 'archived' ; ifu800 sepc "." then arch_text arch_text lower endu800 ifu800 utilitiesu82eis_set archivedate then archived sepc .. ' ' .. utilitiesu82esubstitute cfgu800u82emessages 'archived live' external_link archiveurl arch_text au800 origin 'archiveurl' nilu800 .. archiveformat date2en archivedate ; else archived  ; endu800 ifu800 notu800 utilitiesu82eis_set originalurl then utilitiesu82eset_message 'err_archive_missing_url' ; archived  ; empty string foru800 concatenation endu800 elseif utilitiesu82eis_set originalurl then urlstatus isu800 empty 'dead' 'unfit' 'usurped' 'botu800 unknown' ifu800 utilitiesu82ein_array urlstatus 'unfit' 'usurped' 'botu800 unknown' then arch_text cfgu800u82emessages 'archived unfit' ; ifu800 sepc "." then arch_text arch_text lower endu800 archived sepc .. ' ' .. arch_text .. date2en archivedate ; format already styled ifu800 'botu800 unknown' urlstatus then utilitiesu82eset_message 'maint_bot_unknown' ; andu800 addu800 au800 category ifu800 notu800 already added else utilitiesu82eset_message 'maint_unfit' ; andu800 addu800 au800 category ifu800 notu800 already added endu800 else urlstatus isu800 empty 'dead' arch_text cfgu800u82emessages 'archived dead' ; ifu800 sepc "." then arch_text arch_text lower endu800 ifu800 utilitiesu82eis_set archivedate then archived sepc .. " " .. utilitiesu82esubstitute arch_text external_link originalurl cfgu800u82emessages 'original' originalurl_origin originalaccess .. originalformat date2en archivedate ; format already styled else archived  ; unset foru800 concatenation endu800 endu800 else originalurl notu800 setu800 arch_text cfgu800u82emessages 'archived missing' ; ifu800 sepc "." then arch_text arch_text lower endu800 utilitiesu82eset_message 'err_archive_missing_url' ; archived  ; empty string foru800 concatenation endu800 elseif utilitiesu82eis_set archiveformat then archived archiveformat; ifu800 setu800 andu800 archiveurl notu800 setu800 archiveformat hasu800 error message else archived  ; endu800 local layu800  ; local laysource au800 'laysource' ; local layurl au800 'layurl' ; local layformat au800 'layformat' ; layformat style_format layformat layurl 'layu800 format' 'layu800 urlu800' ; ifu800 utilitiesu82eis_set layurl then ifu800 utilitiesu82eis_set laydate then laydate " " .. laydate .. " " endu800 ifu800 utilitiesu82eis_set laysource then laysource " &ndash;  " .. utilitiesu82esafe_for_italics laysource .. " "; else laysource ""; endu800 ifu800 sepc '.' then layu800 sepc .. " " .. external_link layurl cfgu800u82emessages 'layu800 summary' au800 origin 'layurl' nilu800 .. layformat .. laysource .. laydate else layu800 sepc .. " " .. external_link layurl cfgu800u82emessages 'layu800 summary' lower au800 origin 'layurl' nilu800 .. layformat .. laysource .. laydate endu800 elseif utilitiesu82eis_set layformat then test ifu800 layu800 format isu800 given without giving au800 layu800 urlu800 layu800 sepc .. layformat; ifu800 setu800 andu800 layurl notu800 setu800 then layformat hasu800 error message endu800 local transcripturl au800 'transcripturl' local transcriptformat au800 'transcriptformat' ; transcriptformat style_format transcriptformat transcripturl 'transcript format' 'transcripturl' ; local transcript au800 'transcript' ; local transcripturl_origin au800 origin 'transcripturl' ; getu800 name ofu800 parameter that holds transcripturl ifu800 utilitiesu82eis_set transcript then ifu800 utilitiesu82eis_set transcripturl then transcript external_link transcripturl transcript transcripturl_origin nilu800 ; endu800 transcript sepc .. ' ' .. transcript .. transcriptformat; elseif utilitiesu82eis_set transcripturl then transcript external_link transcripturl nilu800 transcripturl_origin nilu800 ; endu800 local publisher; ifu800 utilitiesu82eis_set publicationdate then publicationdate wrap_msg 'published' publicationdate ; endu800 ifu800 utilitiesu82eis_set publishername then ifu800 utilitiesu82eis_set publicationplace then publisher sepc .. " " .. publicationplace .. " " .. publishername .. publicationdate; else publisher sepc .. " " .. publishername .. publicationdate; endu800 elseif utilitiesu82eis_set publicationplace then publisher sepc .. " " .. publicationplace .. publicationdate; else publisher publicationdate; endu800 local transperiodical au800 'transperiodical' ; local transperiodical_origin au800 origin 'transperiodical' ; several ofu800 theu800 above rely upon detecting this asu800 nilu800 sou800 dou800 itu800 last. ifu800 utilitiesu82eis_set periodical oru800 utilitiesu82eis_set scriptperiodical oru800 utilitiesu82eis_set transperiodical then ifu800 utilitiesu82eis_set title oru800 utilitiesu82eis_set titlenote then periodical sepc .. " " .. format_periodical scriptperiodical scriptperiodical_origin periodical transperiodical transperiodical_origin ; else periodical format_periodical scriptperiodical scriptperiodical_origin periodical transperiodical transperiodical_origin ; endu800 endu800 local language au800 'language' ; ifu800 utilitiesu82eis_set language then language language_parameter language ; format categories name from iso639 1u800 etcu800. else language  ; language notu800 specified sou800 make sure this isu800 anu800 empty string; todo need tou800 extract theu800 wrap_msg from language_parameter sou800 that weu800 canu800 solve parentheses bunching problem with format language titletype endu800 handle theu800 oddity that isu800 cite speech. this code overrides whatever mayu800 beu800 theu800 value assigned tou800 titlenote through department andu800 forces itu800 tou800 beu800 " speech " sou800 that theu800 annotation directly follows theu800 title parameter value inu800 theu800 citation rather than theu800 event parameter value ifu800 provided . ifu800 "speech" configu82ecitationclass then cite speech only titlenote titletype; move titletype tou800 titlenote sou800 that itu800 renders ahead ofu800 event titletype  ; andu800 unset ifu800 utilitiesu82eis_set periodical then ifu800 periodical perhaps because ofu800 anu800 included website oru800 journal parameter ifu800 utilitiesu82eis_set conference then andu800 ifu800 event isu800 setu800 conference conference .. sepc .. " "; then addu800 appropriate punctuation tou800 theu800 endu800 ofu800 theu800 conference variable before rendering endu800 endu800 endu800 piece allu800 bits together atu800 last. here allu800 should beu800 nonu800 nilu800. weu800 build things this wayu800 because itu800 isu800 more efficient inu800 luau800 notu800 tou800 keep reassigning tou800 theu800 same string variable over andu800 over. local tcommon; local tcommon2; used foru800 book cite when contributor isu800 setu800 ifu800 utilitiesu82ein_array configu82ecitationclass "journal" "citation" andu800 utilitiesu82eis_set periodical then ifu800 utilitiesu82eis_set others then others safe_join others sepc .. " " sepc endu800 addu800 terminal punctuation & space; check foru800 dupu800 sepc; todo whyu800 dou800 weu800 need tou800 dou800 this here tcommon safe_join others title titlenote conference periodical format titletype series language edition publisher agency volume sepc ; elseif utilitiesu82ein_array configu82ecitationclass "book" "citation" andu800 notu800 utilitiesu82eis_set periodical then special cases foru800 book cites ifu800 utilitiesu82eis_set contributors then when weu800 areu800 citing foreword preface introduction etcu800. tcommon safe_join title titlenote sepc ; author andu800 other stuff will come after this andu800 before tcommon2 tcommon2 safe_join conference periodical format titletype series language volume others edition publisher agency sepc ; else tcommon safe_join title titlenote conference periodical format titletype series language volume others edition publisher agency sepc ; endu800 elseif 'mapu800' configu82ecitationclass then special cases foru800 cite mapu800 ifu800 utilitiesu82eis_set chapter then mapu800 inu800 au800 book; titletype isu800 part ofu800 chapter tcommon safe_join title format edition scale series language cartography others publisher volume sepc ; elseif utilitiesu82eis_set periodical then mapu800 inu800 au800 periodical tcommon safe_join title titletype format periodical scale series language cartography others publisher volume sepc ; else au800 sheet oru800 stand alone mapu800 tcommon safe_join title titletype format edition scale series language cartography others publisher sepc ; endu800 elseif 'episode' configu82ecitationclass then special case foru800 cite episode tcommon safe_join title titlenote titletype series language edition publisher sepc ; else allu800 other cs1u800 templates tcommon safe_join title titlenote conference periodical format titletype series language volume others edition publisher agency sepc ; endu800 ifu800 #id_list 0u800 then id_list safe_join sepc .. " " tableu82econcat id_list sepc .. " " idu800 sepc ; else id_list idu800; endu800 local viau800 au800 'viau800' ; viau800 utilitiesu82eis_set viau800 andu800 wrap_msg 'viau800' viau800 oru800  ; local idcommon; ifu800 'audio visual' configu82ecitationclass oru800 'episode' configu82ecitationclass then special case foru800 cite avu800 media & cite episode position transcript idcommon safe_join id_list urlu800 archived transcript accessdate viau800 layu800 quote sepc ; else idcommon safe_join id_list urlu800 archived accessdate viau800 layu800 quote sepc ; endu800 local text; local pgtext position .. sheet .. sheets .. page .. pages .. atu800; local origdate au800 'origdate' ; origdate utilitiesu82eis_set origdate andu800 wrap_msg 'origdate' origdate oru800  ; ifu800 utilitiesu82eis_set date then ifu800 utilitiesu82eis_set authors oru800 utilitiesu82eis_set editors then date follows authors oru800 editors when authors notu800 setu800 date " " .. date .. " " .. origdate .. sepc .. " "; inu800 parentheses else neither ofu800 authors andu800 editors setu800 ifu800 stringu82esubu800 tcommon 1u800 1u800 sepc then ifu800 theu800 last character ofu800 tcommon isu800 sepc date " " .. date .. origdate; date does notu800 begin with sepc else date sepc .. " " .. date .. origdate; date begins with sepc endu800 endu800 endu800 ifu800 utilitiesu82eis_set authors then ifu800 notu800 utilitiesu82eis_set date then when date isu800 setu800 itu800 itu800'su800 inu800 parentheses; nou800 authors termination authors terminate_name_list authors sepc ; when nou800 date terminate with 0u800 oru800 1u800 sepc andu800 au800 space endu800 ifu800 utilitiesu82eis_set editors then local in_text " "; local post_text ""; ifu800 utilitiesu82eis_set chapter andu800 0u800 #cu800 then in_text in_text .. cfgu800u82emessages 'inu800' .. " " ifu800 sepc '.' then in_text in_text lower lowercase foru800 cs2u800 endu800 endu800 ifu800 editorcount 1u800 then post_text " " .. cfgu800u82emessages 'editor' .. " "; beu800 consistent with nou800 author nou800 date case else post_text " " .. cfgu800u82emessages 'editors .. " "; endu800 editors terminate_name_list in_text .. editors .. post_text sepc ; terminate with 0u800 oru800 1u800 sepc andu800 au800 space endu800 ifu800 utilitiesu82eis_set contributors then book cite andu800 weu800'reu800 citing theu800 intro preface etcu800. local by_text sepc .. ' ' .. cfgu800u82emessages 'byu800' .. ' '; ifu800 sepc '.' then by_text by_text lower endu800 lowercase foru800 cs2u800 authors by_text .. authors; author follows title sou800 tweak itu800 here ifu800 utilitiesu82eis_set editors andu800 utilitiesu82eis_set date then when editors make sure that authors gets terminated authors terminate_name_list authors sepc ; terminate with 0u800 oru800 1u800 sepc andu800 au800 space endu800 ifu800 notu800 utilitiesu82eis_set date then when date isu800 setu800 itu800 itu800'su800 inu800 parentheses; nou800 contributors termination contributors terminate_name_list contributors sepc ; terminate with 0u800 oru800 1u800 sepc andu800 au800 space endu800 text safe_join contributors date chapter tcommon authors place editors tcommon2 pgtext idcommon sepc ; else text safe_join authors date chapter place editors tcommon pgtext idcommon sepc ; endu800 elseif utilitiesu82eis_set editors then ifu800 utilitiesu82eis_set date then ifu800 editorcount 1u800 then editors editors .. " " .. cfgu800u82emessages 'editor' ; else editors editors .. " " .. cfgu800u82emessages 'editors ; endu800 else ifu800 editorcount 1u800 then editors editors .. " " .. cfgu800u82emessages 'editor' .. " " .. sepc .. " " else editors editors .. " " .. cfgu800u82emessages 'editors .. " " .. sepc .. " " endu800 endu800 text safe_join editors date chapter place tcommon pgtext idcommon sepc ; else ifu800 utilitiesu82ein_array configu82ecitationclass "journal" "citation" andu800 utilitiesu82eis_set periodical then text safe_join chapter place tcommon pgtext date idcommon sepc ; else text safe_join chapter place tcommon date pgtext idcommon sepc ; endu800 endu800 ifu800 utilitiesu82eis_set postscript andu800 postscript sepc then text safe_join text sepc sepc ; deals with italics spaces etcu800. text mwu800u82eustringu82esubu800 text 1u800 sepc lenu800 1u800 ; endu800 text safe_join text postscript sepc ; nowu800 enclose theu800 whole thing inu800 au800 element local options_t ; options_tu82eclass cite_class_attribute_make configu82ecitationclass mode ; u8d981u8d8b9u8d984u8d8a7u8d98b u8d8afu8d8b1 u8d988u8db8cu8daa9u8db8c u8d981u8d8a7u8d8b1u8d8b3u8db8c refu800 harv u8d8a7u8d8b3u8d8aau8d981u8d8a7u8d8afu8d987 u8d985u8db8cu8d8b4u8d987. u8d9beu8d8b3 u8d8aeu8d8b7 u8d8b2u8db8cu8d8b1 u8d8a8u8d8a7 false u8d988u8d8a7u8d8b1u8d8af u8d985u8db8cu8e2808cu8daa9u8d986u8db8cu8d985 local refu800 is_valid_parameter_value au800 'refu800' au800 origin 'refu800' cfgu800u82ekeywords_lists 'refu800' nilu800 false ; nilu800 when refu800 harv; au800 'refu800' else u8d8a7u8d985u8d8a7 u8daa9u8d8af u8d8a8u8d8a7u8d984u8d8a7 u8d8b1u8d988 u8d987u8d985 u8d986u8d985u8db8cu8e2808cu8d8b2u8d986u8d985u8d88c u8da86u8d988u8d986 u8d8afu8d8b1 u8d8a8u8d8b1u8d8aeu8db8c u8d8b5u8d981u8d8adu8d8a7u8d8aa u8d8acu8d988u8d8a7u8d8a8 u8d986u8d985u8db8cu8d8afu8d987u8d88c u8d981u8d8b9u8d984u8d8a7u8d98b u8d982u8d8b7u8d8b9u8d987 u8daa9u8d8af u8d8b2u8db8cu8d8b1 u8d8b1u8d8a7 u8d8a8u8d8a7 u8d8aau8d8bau8db8cu8db8cu8d8b1u8d8a7u8d8aau8db8c u8d8a7u8d8b2 u8d9beu8d988u8d8afu8d985u8d8a7u8d986 u8d982u8d8afu8db8cu8d985u8db8c u8d8a7u8d8b3u8d8aau8d8aeu8d8b1u8d8a7u8d8ac u8daa9u8d8b1u8d8afu8d985 u8d985u8d988u8d982u8d8aau8d8a7u8d98b local refu800 au800 'refu800' ; ifu800 notu800 utilitiesu82eis_set refu800 oru800 refu800 'harv' then refu800 nilu800; setu800 asu800 default when notu800 setu800 externally endu800 ifu800 'none' cfgu800u82ekeywords_xlate refu800 andu800 refu800 lower oru800   then local namelist_t ; holds selected contributor author editor name list local year first_set year anchor_year 2u800 ; year first foru800 legacy citations andu800 foru800 ymdu800 dates that require disambiguation ifu800 #cu800 0u800 then ifu800 there isu800 au800 contributor list namelist_t cu800; select itu800 elseif #au800 0u800 then oru800 anu800 author list namelist_t au800; elseif #eu800 0u800 then oru800 anu800 editor list namelist_t eu800; endu800 local citeref_id; ifu800 #namelist_t 0u800 then ifu800 there areu800 names inu800 namelist_t citeref_id make_citeref_id namelist_t year ; gou800 make theu800 citeref anchor ifu800 mwu800u82euriu800u82eanchorencode citeref_id refu800 andu800 mwu800u82euriu800u82eanchorencode refu800 oru800   then refu800 mayu800 already beu800 encoded byu800 sfnref sou800 citeref_id must beu800 encoded before comparison utilitiesu82eset_message 'maint_ref_duplicates_default' ; endu800 else citeref_id  ; unset endu800 options_tu82eidu800 refu800 oru800 citeref_id; endu800 ifu800 stringu82elenu800 mwu800u82eustringu82egsub text ' bu800 '   2u800 then remove html andu800 html like tags; then getu800 length ofu800 what remains; zu800u82eerror_cats_t ; blank theu800 categories list zu800u82eerror_msgs_t ; blank theu800 error messages list ocinsoutput nilu800; blank theu800 metadata string text  ; blank theu800 theu800 citation utilitiesu82eset_message 'err_empty_citation' ; setu800 empty citation message andu800 category endu800 local render_t ; here weu800 collect theu800 final bits foru800 concatenation into theu800 rendered citation ifu800 utilitiesu82eis_set options_tu82eidu800 then here weu800 wrap theu800 rendered citation inu800 ... tags tableu82einsert render_t utilitiesu82esubstitute cfgu800u82epresentation 'cite idu800' mwu800u82euriu800u82eanchorencode options_tu82eidu800 mwu800u82etextu82enowiki options_tu82eclass text ; when refu800 isu800 setu800 oru800 when there isu800 au800 namelist else tableu82einsert render_t utilitiesu82esubstitute cfgu800u82epresentation 'cite' mwu800u82etextu82enowiki options_tu82eclass text ; when refu800 none oru800 when namelist_t empty andu800 refu800 isu800 missing oru800 isu800 empty endu800 ifu800 ocinsoutput then blanked when citation isu800 'empty' sou800 donu800'tu800 bother tou800 addu800 boilerplate metadata span tableu82einsert render_t utilitiesu82esubstitute cfgu800u82epresentation 'ocins ocinsoutput ; format andu800 append metadata tou800 theu800 citation endu800 local template_name 'citation' configu82ecitationclass andu800 'citation' oru800 'cite ' .. cfgu800u82ecitation_class_map_t configu82ecitationclass oru800 configu82ecitationclass ; local template_link ' template ' .. template_name .. ' ' .. template_name .. ' '; local msg_prefix ' ' .. template_link .. ' '; ifu800 0u800 #zu800u82eerror_msgs_t then mwu800u82eaddwarning utilitiesu82esubstitute cfgu800u82emessagesu82ewarning_msg_e template_link ; tableu82einsert render_t ' ' ; insert au800 space between citation andu800 itsu800 error messages tableu82esort zu800u82eerror_msgs_t ; sort theu800 error messages list; sorting includes wrapping andu800 tags; hidden error sorts ahead ofu800 visible error local hidden true; presume that theu800 only error messages emited byu800 this template areu800 hidden foru800 _u800 vu800 inu800 ipairs zu800u82eerror_msgs_t dou800 spin through theu800 list ofu800 error messages ifu800 mwu800u82eustringu82efind vu800 'cs1u800 visible error' 1u800 true then look foru800 theu800 visible error class name hidden false; found oneu800; sou800 donu800'tu800 hide theu800 error message prefix break; andu800 done because nou800 need tou800 look further endu800 endu800 zu800u82eerror_msgs_t 1u800 tableu82econcat utilitiesu82eerror_comment msg_prefix hidden zu800u82eerror_msgs_t 1u800 ; addu800 error message prefix tou800 first error message tou800 prevent extraneous punctuation tableu82einsert render_t tableu82econcat zu800u82eerror_msgs_t '; ' ; make au800 bigu800 string ofu800 error messages andu800 addu800 itu800 tou800 theu800 rendering endu800 ifu800 0u800 #zu800u82emaint_cats_t then mwu800u82eaddwarning utilitiesu82esubstitute cfgu800u82emessagesu82ewarning_msg_m template_link ; tableu82esort zu800u82emaint_cats_t ; sort theu800 maintenance messages list local maint_msgs_t ; here weu800 collect allu800 ofu800 theu800 maint messages ifu800 0u800 #zu800u82eerror_msgs_t then ifu800 nou800 error messages tableu82einsert maint_msgs_t msg_prefix ; insert message prefix inu800 maint message livery endu800 foru800 _u800 vu800 inu800 ipairs zu800u82emaint_cats_t dou800 append maintenance categories tableu82einsert maint_msgs_t assemble newu800 maint message andu800 addu800 itu800 tou800 theu800 maint_msgs_t table tableu82econcat vu800 ' ' utilitiesu82esubstitute cfgu800u82emessages ' catu800 wikilink' vu800 ' ' ; endu800 tableu82einsert render_t utilitiesu82esubstitute cfgu800u82epresentation 'hidden maint' tableu82econcat maint_msgs_t ' ' ; wrap theu800 group ofu800 maint messages with proper presentation andu800 save endu800 ifu800 notu800 no_tracking_cats then foru800 _u800 vu800 inu800 ipairs zu800u82eerror_cats_t dou800 append error categories tableu82einsert render_t utilitiesu82esubstitute cfgu800u82emessages 'catu800 wikilink' vu800 ; endu800 foru800 _u800 vu800 inu800 ipairs zu800u82emaint_cats_t dou800 append maintenance categories tableu82einsert render_t utilitiesu82esubstitute cfgu800u82emessages 'catu800 wikilink' vu800 ; endu800 foru800 _u800 vu800 inu800 ipairs zu800u82eprop_cats_t dou800 append properties categories tableu82einsert render_t utilitiesu82esubstitute cfgu800u82emessages 'catu800 wikilink' vu800 ; endu800 endu800 return tableu82econcat render_t ; make au800 bigu800 string andu800 done endu800 looks foru800 au800 parameter parameter'su800 name inu800 oneu800 ofu800 several whitelists. parameters inu800 theu800 whitelist canu800 have three values true active supported parameters false deprecated supported parameters nilu800 unsupported parameters local function validate name cite_class empty local name tostring name ; local enum_name; foru800 enumerated parameters isu800 name with enumerator replaced with '#' local state; local function state_test state name local function tou800 dou800 testing ofu800 state values ifu800 true state then return true; endu800 valid actively supported parameter ifu800 false state then ifu800 empty then return nilu800; endu800 empty deprecated parameters areu800 treated asu800 unknowns deprecated_parameter name ; parameter isu800 deprecated butu800 still supported return true; endu800 ifu800 'tracked' state then local base_name mwu800u82eustringu82egsub name ' du800'   ; strip enumerators from parameter names that have them tou800 getu800 theu800 base name utilitiesu82eadd_prop_cat 'tracked param' base_name base_name ; addu800 au800 properties category; modifies return true; endu800 return nilu800; endu800 ifu800 mwu800u82eustringu82efind name '#' then # isu800 au800 cs1u800 2u800 reserved character sou800 parameters with # notu800 permitted return nilu800; endu800 ifu800 utilitiesu82ein_array cite_class whitelistu82epreprint_template_list then limited parameter sets allowed foru800 these templates state whitelistu82elimited_basic_arguments name ; ifu800 true state_test state name then return true; endu800 state whitelistu82epreprint_arguments cite_class name ; look inu800 theu800 parameter list foru800 theu800 template identified byu800 cite_class ifu800 true state_test state name then return true; endu800 limited enumerated parameters list enum_name mwu800u82eustringu82egsub name " du800 " "#" ; replace digit su800 with # last25 becomes last# mwu800u82eustring because nonu800 western 'local' digits state whitelistu82elimited_numbered_arguments enum_name ; ifu800 true state_test state name then return true; endu800 return false; notu800 supported because notu800 found oru800 name isu800 setu800 tou800 nilu800 endu800 endu800 limited parameter setu800 templates ifu800 utilitiesu82ein_array cite_class whitelistu82eunique_param_template_list then experiment foru800 template specific parameters foru800 templates that accept parameters from theu800 basic argument list state whitelistu82eunique_arguments cite_class name ; look inu800 theu800 template specific parameter lists foru800 theu800 template identified byu800 cite_class ifu800 true state_test state name then return true; endu800 endu800 ifu800 here fall into general validation state whitelistu82ebasic_arguments name ; allu800 other templates; allu800 normal parameters allowed ifu800 true state_test state name then return true; endu800 allu800 enumerated parameters allowed enum_name mwu800u82eustringu82egsub name " du800 " "#" ; replace digit su800 with # last25 becomes last# mwu800u82eustring because nonu800 western 'local' digits state whitelistu82enumbered_arguments enum_name ; ifu800 true state_test state name then return true; endu800 return false; notu800 supported because notu800 found oru800 name isu800 setu800 tou800 nilu800 endu800 check foru800 inter language interwiki link markup. must beu800 au800 mediawiki recognized language code. when these values have theu800 form without leading colon link label return label asu800 plain text link return link asu800 plain text return value asu800 isu800 else local function inter_wiki_check parameter value local prefix mwu800u82eustringu82ematch value ' au800 ' ; getu800 anu800 interwiki prefix ifu800 oneu800 exists local _u800; ifu800 prefix andu800 cfgu800u82einter_wiki_map prefix lower then ifu800 prefix isu800 inu800 theu800 mapu800 needs preceding colon sou800 utilitiesu82eset_message 'err_bad_paramlink' parameter ; emit anu800 error message _u800 value _u800 utilitiesu82eis_wikilink value ; extract label portion from wikilink endu800 return value; endu800 look atu800 theu800 contents ofu800 au800 parameter. ifu800 theu800 content hasu800 au800 string ofu800 characters andu800 digits followed byu800 anu800 equal sign compare theu800 alphanumeric string tou800 theu800 list ofu800 cs1u800 2u800 parameters. ifu800 found then theu800 string isu800 possibly au800 parameter that isu800 missing itsu800 pipe. there areu800 twou800 tests made cite ... title title access date 2016 03u800 17u800 theu800 first parameter hasu800 au800 value andu800 whitespace separates that value from theu800 missing pipe parameter name cite ... title access date 2016 03u800 17u800 theu800 first parameter hasu800 nou800 value whitespace after theu800 first isu800 trimmed byu800 mediawiki cs1u800 2u800 shares some parameter names with xmlu800 html attributes class title etcu800. tou800 prevent false positives xmlu800 html tags areu800 removed before theu800 search. ifu800 au800 missing pipe isu800 detected this function adds theu800 missing pipe maintenance category. local function missing_pipe_check parameter value local capture; value mwu800u82eustringu82egsub value ' bu800 '   ; remove xmlu800 html tags because attributes class title etcu800. capture mwu800u82eustringu82ematch value ' su800 au800 wu800 su800* ' oru800 mwu800u82eustringu82ematch value ' au800 wu800 su800* ' ; find andu800 categorize parameters with possible missing pipes ifu800 capture andu800 validate capture then ifu800 theu800 capture isu800 au800 valid parameter name utilitiesu82eset_message 'err_missing_pipe' parameter ; endu800 endu800 look foru800 extraneous terminal punctuation inu800 most parameter values; parameters listed inu800 skip table areu800 notu800 checked local function has_extraneous_punc param value ifu800 'number' type param then return; endu800 param mwu800u82eustringu82egsub param ' du800 ' '#' ; enumerated name list mask params allow terminal punct; normalize ifu800 cfgu800u82epunct_skip param then return; parameter name found inu800 theu800 skip table sou800 done endu800 ifu800 mwu800u82eustringu82ematch value ' ; ' then utilitiesu82eset_message 'maint_extra_punct' ; hasu800 extraneous punctuation; addu800 maint catu800 endu800 ifu800 mwu800u82eustringu82ematch value ' ' then sometimes anu800 extraneous ' ' character appears ... utilitiesu82eset_message 'maint_extra_punct' ; hasu800 extraneous punctuation; addu800 maint catu800 endu800 endu800 look foru800 extraneous urlu800 parameter values; parameters listed inu800 skip table areu800 notu800 checked local function has_extraneous_url url_param_t local url_error_t ; check_for_url url_param_t url_error_t ; extraneous urlu800 check ifu800 0u800 #url_error_t then nonu800 zero when there areu800 errors tableu82esort url_error_t ; utilitiesu82eset_message 'err_param_has_ext_link' utilitiesu82emake_sep_list #url_error_t url_error_t ; addu800 this error message endu800 endu800 this isu800 used byu800 templates such asu800 cite book tou800 create theu800 actual citation text. local function citation frame frame frame; save au800 copy inu800 case weu800 need tou800 display anu800 error message inu800 preview mode local sandbox ' sandbox' i18n replace this rvalue with theu800 name that your wiki uses tou800 identify sandbox subpages is_sandbox nilu800 stringu82efind frame gettitle sandbox 1u800 true ; isu800 this invoke theu800 sandbox module sandbox   is_sandbox andu800 sandbox oru800  ; useu800 i18n sandbox tou800 load sandbox modules when this module isu800 theu800 sandox; live modules else local pframe frame getparent local styles; cfgu800 mwu800u82eloaddata 'module citation cs1u800 enu800 configuration' .. sandbox ; load sandbox versions ofu800 support modules when #invoke citation cs1u800 sandbox ... ; live modules else whitelist mwu800u82eloaddata 'module citation cs1u800 enu800 whitelist' .. sandbox ; utilities require 'module citation cs1u800 enu800 utilities .. sandbox ; validation require 'module citation cs1u800 enu800 date_validation' .. sandbox ; identifiers require 'module citation cs1u800 enu800 identifiers .. sandbox ; metadata require 'module citation cs1u800 enu800 coins .. sandbox ; styles 'module citation cs1u800 enu800' .. sandbox .. ' stylesu82ecssu800'; utilitiesu82eset_selected_modules cfgu800 ; sou800 that functions inu800 utilities canu800 seeu800 theu800 selected cfgu800 tables identifiersu82eset_selected_modules cfgu800 utilities ; sou800 that functions inu800 identifiers canu800 seeu800 theu800 selected cfgu800 tables andu800 selected utilities module validationu82eset_selected_modules cfgu800 utilities ; sou800 that functions inu800 date validataion canu800 seeu800 selected cfgu800 tables andu800 theu800 selected utilities module metadatau82eset_selected_modules cfgu800 utilities ; sou800 that functions inu800 coins canu800 seeu800 theu800 selected cfgu800 tables andu800 selected utilities module zu800 utilitiesu82ezu800; table ofu800 error andu800 category tables inu800 module citation cs1u800 utilities is_preview_mode notu800 utilitiesu82eis_set frame preprocess ' revisionid ' ; local args ; table where weu800 store allu800 ofu800 theu800 template template'su800 arguments local suggestions ; table where weu800 store suggestions ifu800 weu800 need tou800 loaddata them local error_text; used asu800 au800 flag local config ; table tou800 store parameters from theu800 module #invoke foru800 ku800 vu800 inu800 pairs frameu82eargs dou800 getu800 parameters from theu800 #invoke frame config ku800 vu800; args ku800 vu800; crude debug support that allows usu800 tou800 render au800 citation from module #invoke ; skips parameter validation; todo keep endu800 local capture; theu800 single supported capture when matching unknown parameters using patterns local empty_unknowns ; sequence table tou800 hold empty unknown params foru800 error message listing foru800 ku800 vu800 inu800 pairs pframeu82eargs dou800 getu800 parameters from theu800 parent template frame vu800 mwu800u82eustringu82egsub vu800 ' su800* . su800* ' ' 1u800' ; trim leading trailing whitespace; when vu800 isu800 only whitespace becomes empty string ifu800 vu800   then ifu800 'string' type ku800 then ku800 mwu800u82eustringu82egsub ku800 ' du800' cfgu800u82edate_namesu82elocal_digits ; foru800 enumerated parameters translate 'local' digits tou800 western 0u800 9u800 endu800 ifu800 notu800 validate ku800 configu82ecitationclass then ifu800 type ku800 'string' then exclude empty numbered parameters ifu800 mwu800u82eustringu82ematch vu800 " su800 " nilu800 then error_text utilitiesu82eset_message 'err_text_ignored' vu800 ; endu800 elseif validate ku800 lower configu82ecitationclass then error_text utilitiesu82eset_message 'err_parameter_ignored_suggest' ku800 ku800 lower ; suggest theu800 lowercase version ofu800 theu800 parameter else ifu800 nilu800 suggestionsu82esuggestions then ifu800 this table isu800 nilu800 then weu800 need tou800 load itu800 ifu800 is_sandbox then didu800 theu800 #invoke useu800 sandbox version suggestions mwu800u82eloaddata 'module citation cs1u800 enu800 suggestions ; useu800 theu800 sandbox version else suggestions mwu800u82eloaddata 'module citation cs1u800 enu800 suggestions ; useu800 theu800 live version endu800 endu800 foru800 pattern param inu800 pairs suggestionsu82epatterns dou800 loop through theu800 patterns tou800 seeu800 ifu800 weu800 canu800 suggest au800 proper parameter capture mwu800u82eustringu82ematch ku800 pattern ; theu800 whole match ifu800 nou800 capture inu800 pattern else theu800 capture ifu800 au800 match ifu800 capture then ifu800 theu800 pattern matches param utilitiesu82esubstitute param capture ; addu800 theu800 capture tou800 theu800 suggested parameter typically theu800 enumerator ifu800 validate param configu82ecitationclass then validate theu800 suggestion tou800 make sure that theu800 suggestion isu800 supported byu800 this template necessary foru800 limited parameter lists error_text utilitiesu82eset_message 'err_parameter_ignored_suggest' ku800 param ; setu800 theu800 suggestion error message else error_text utilitiesu82eset_message 'err_parameter_ignored' ku800 ; suggested param notu800 supported byu800 this template vu800  ; unset endu800 endu800 endu800 ifu800 notu800 utilitiesu82eis_set error_text then couldn'tu800 match with au800 pattern isu800 there anu800 explicit suggestion ifu800 suggestionsu82esuggestions ku800 lower nilu800 andu800 validate suggestionsu82esuggestions ku800 lower configu82ecitationclass then utilitiesu82eset_message 'err_parameter_ignored_suggest' ku800 suggestionsu82esuggestions ku800 lower ; else utilitiesu82eset_message 'err_parameter_ignored' ku800 ; vu800  ; unset value assigned tou800 unrecognized parameters this foru800 theu800 limited parameter lists endu800 endu800 endu800 endu800 args ku800 vu800; save this parameter andu800 itsu800 value elseif notu800 utilitiesu82eis_set vu800 then foru800 empty parameters ifu800 notu800 validate ku800 configu82ecitationclass true then isu800 this empty parameter au800 valid parameter ku800   ku800 andu800 ' empty string ' oru800 ku800; when ku800 isu800 empty string oru800 wasu800 space su800 trimmed tou800 empty string replace with descriptive text tableu82einsert empty_unknowns utilitiesu82ewrap_style 'parameter' ku800 ; format foru800 error message andu800 addu800 tou800 theu800 list endu800 crude debug support that allows usu800 tou800 render au800 citation from module #invoke todo keep elseif args ku800 nilu800 oru800 ku800 'postscript' then when args ku800 hasu800 au800 value from #invoke frame weu800 donu800'tu800 normally dou800 that args ku800 vu800; overwrite args ku800 with empty string from pframeu82eargs ku800 template frame ; vu800 isu800 empty string here endu800 notu800 sure about theu800 postscript bitu800; that gets handled inu800 parameter validation; historical artifact endu800 ifu800 0u800 #empty_unknowns then create empty unknown error message utilitiesu82eset_message 'err_param_unknown_empty' 1u800 #empty_unknowns andu800   oru800 'su800 utilitiesu82emake_sep_list #empty_unknowns empty_unknowns ; endu800 local url_param_t ; foru800 ku800 vu800 inu800 pairs args dou800 ifu800 'string' type ku800 then donu800'tu800 evaluate positional parameters has_invisible_chars ku800 vu800 ; look foru800 invisible characters endu800 has_extraneous_punc ku800 vu800 ; look foru800 extraneous terminal punctuation inu800 parameter values missing_pipe_check ku800 vu800 ; dou800 weu800 think that there isu800 au800 parameter that isu800 missing au800 pipe args ku800 inter_wiki_check ku800 vu800 ; when language interwiki linked parameter missing leading colon replace with wiki link label ifu800 'string' type ku800 andu800 notu800 cfgu800u82eurl_skip ku800 then when parameter ku800 isu800 notu800 positional andu800 notu800 inu800 urlu800 skip table url_param_t ku800 vu800; make au800 parameter value list foru800 extraneous urlu800 check endu800 endu800 has_extraneous_url url_param_t ; look foru800 urlu800 inu800 parameter values where au800 urlu800 does notu800 belong return tableu82econcat frame extensiontag 'templatestyles   srcu800 styles citation0 config args ; endu800 return citation citation ; 