 local numconv require "module numeral converter" .convert falocalization local dates year_date_check reformat_dates date_hyphen_to_dash functions inu800 module citation cs1u800 date_validation date_name_xlate local is_set in_array substitute error_comment set_error select_one functions inu800 module citation cs1u800 utilities add_maint_cat wrap_style safe_for_italics is_wikilink make_wikilink; local zu800 ; tables inu800 module citation cs1u800 utilities local extract_ids extract_id_access_levels build_id_list is_embargoed; functions inu800 module citation cs1u800 identifiers local make_coins_title get_coins_pages coins; 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 delare variables here that have page wide scope that areu800 notu800 brought inu800 from other modules; thatare created here andu800 used here local added_deprecated_cat; boolean flag sou800 that theu800 category isu800 added only once local added_prop_cats ; list ofu800 property categories that have been added tou800 zu800u82eproperties_cats local added_vanc_errs; boolean flag sou800 weu800 only emit oneu800 vancouver error category local frame; holds theu800 module module'su800 frame table 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 is_set list iu800 then return list iu800 ; return theu800 first setu800 list member endu800 iu800 iu800 1u800; point tou800 next endu800 endu800 adds au800 category tou800 zu800u82eproperties_cats using names from theu800 configuration file with additional text ifu800 anyu800. foreign_lang_source andu800 foreign_lang_source_2 keys have au800 language code appended tou800 them sou800 that multiple languages mayu800 beu800 categorized butu800 multiples ofu800 theu800 same language areu800 notu800 categorized. added_prop_cats isu800 au800 table declared inu800 page scope variables above local function add_prop_cat keyu800 arguments ifu800 notu800 added_prop_cats keyu800 then added_prop_cats keyu800 true; note that weu800'veu800 added this category keyu800 keyu800 gsub ' foreign_lang_source_ 2u800 au800 au800 au800 ' ' 1u800' ; strip lang code from keyname tableu82einsert zu800u82eproperties_cats substitute cfgu800u82eprop_cats keyu800 arguments ; make name then addu800 tou800 table 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 ifu800 notu800 added_vanc_errs then added_vanc_errs true; note that weu800'veu800 added this category tableu82einsert zu800u82emessage_tail set_error 'vancouver' source true ; endu800 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 scheme match ' 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 rfc952 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 incase 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 andu800 .cash 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 domain gsub ' '   ; strip ' ' from domain name ifu800 present; done here sou800 weu800 only have tou800 dou800 itu800 once ifu800 notu800 domain match ' au800 du800 ' then first character must beu800 letter oru800 digit return false; endu800 dou800 most common case first ifu800 domain match ' fu800 au800 du800 au800 du800 au800 du800 au800 du800 . au800 au800 ' then three oru800 more character hostnameu82ehostname oru800 hostnameu82etldu800 return true; elseif domain match ' fu800 au800 du800 au800 du800 au800 du800 au800 du800 .xnu800 au800 du800 ' then internationalized domain name with aceu800 prefix return true; elseif domain match ' fu800 au800 du800 au800 du800 .cash ' then oneu800 character digit .cash hostname return true; elseif domain match ' fu800 au800 du800 au800 du800 .orgu800 ' then oneu800 character digit .orgu800 hostname return true; elseif domain match ' fu800 au800 qxzu800 .comu800 ' then assigned oneu800 character .comu800 hostname xu800u82ecomu800 times outu800 2015 12u800 10u800 return true; elseif domain match ' fu800 au800 iqu800 .netu800 ' then assigned oneu800 character .netu800 hostname qu800u82enetu800 registered butu800 notu800 active 2015 12u800 10u800 return true; elseif domain match ' fu800 au800 du800 au800 du800 . au800 au800 ' then oneu800 character hostname andu800 cctld 2u800 chars return true; elseif domain match ' fu800 au800 du800 au800 du800 au800 du800 . au800 au800 ' then twou800 character hostname andu800 tldu800 return true; elseif domain match ' du800 du800 du800 . du800 du800 du800 . du800 du800 du800 . du800 du800 du800 ' then ipv4 address return true; else return false; endu800 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 is_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. strip offu800 anyu800 port andu800 path; local function split_url url_str local scheme authority domain; url_str url_str gsub ' au800 du800 . # .* ' ' 1u800' ; strip fqdn terminator andu800 path query fragment # theu800 capture prevents false replacement ofu800 ' ' ifu800 url_str match ' su800*' then ifu800 there isu800 what appears tou800 beu800 au800 protocol relative urlu800 domain url_str match ' su800* ' elseif url_str match ' su800 * su800 ' then ifu800 there isu800 what appears tou800 beu800 au800 scheme optional authority indicator andu800 domain name scheme authority domain url_str match ' su800 * su800 ' ; extract theu800 scheme authority indicator andu800 domain portions authority authority gsub ' '   1u800 ; replace place 1u800 pair ofu800 ' ' with nothing; ifu800 is_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 domain domain gsub ' 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 value find ' ' 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 wikilinked butu800 notu800 when link hasu800 au800 value. this function emits anu800 error message when that condition exists local function link_title_ok link lorig title torig local orig; ifu800 is_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 title find ' ' then check title foru800 wikilink markup orig torig; identify theu800 failing title parameter endu800 endu800 ifu800 is_set orig then tableu82einsert zu800u82emessage_tail set_error 'bad_paramlink' orig ; urlu800 oru800 wikilink inu800 title with title link ; endu800 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 url_str match " 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 domain match ' 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 value match ' fu800 au800 su800* su800 .* ' then ifu800 extu800 wikilink with scheme andu800 domain xxxx yyyyyu82ezzzu800 scheme domain split_url value match ' fu800 au800 su800* su800 .* ' ; elseif value match ' fu800 su800 .* ' then ifu800 protocol relative extu800 wikilink yyyyyu82ezzzu800 scheme domain split_url value match ' fu800 su800 .* ' ; elseif value match ' au800 su800* su800 ' then ifu800 bare urlu800 with scheme; mayu800 have leading oru800 trailing plain text scheme domain split_url value match ' au800 su800* su800 ' ; elseif value match ' su800 ' then ifu800 protocol relative bare urlu800 yyyyyu82ezzzu800; mayu800 have leading oru800 trailing plain text scheme domain split_url value match ' 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 local error_message  ; 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 ifu800 is_set error_message then once weu800'veu800 added theu800 first portion ofu800 theu800 error message ... error_message error_message .. "u8d88c "; ... addu800 au800 comma space separator endu800 error_message error_message .. "&#124u800;" .. ku800 .. " "; addu800 theu800 failed parameter endu800 endu800 ifu800 is_set error_message then done looping ifu800 there isu800 anu800 error message display itu800 tableu82einsert zu800u82emessage_tail set_error 'param_has_ext_link' error_message true ; endu800 endu800 escape sequences foru800 content that will beu800 used foru800 urlu800 descriptions local function safe_for_url stru800 ifu800 stru800 match " . " nilu800 then tableu82einsert zu800u82emessage_tail set_error 'wikilink_in_url' true ; endu800 return stru800 gsub ' nu800 ' ' ' '&#91u800;' ' ' '&#93u800;' ' nu800' ' ' ; endu800 format anu800 external link with error checking local function external_link urlu800 label source access local error_str ""; local domain; local path; local base_url; ifu800 notu800 is_set label then label urlu800; ifu800 is_set source then error_str set_error 'bare_url_missing_title' wrap_style 'parameter' source false " " ; else error cfgu800u82emessages "bare_url_no_origin" ; endu800 endu800 ifu800 notu800 check_url urlu800 then error_str set_error 'bad_url' wrap_style 'parameter' source false " " .. error_str; endu800 domain path urlu800 match ' . au800 du800 # .* ' ; split theu800 urlu800 into scheme plus domain andu800 path ifu800 path then ifu800 there isu800 au800 path portion path path gsub ' ' ' ' ' 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 wikimarkup urlu800 ifu800 is_set access then access level subscription registration limited base_url substitute cfgu800u82epresentation 'extu800 link access signal' cfgu800u82epresentation access .class cfgu800u82epresentation access .title base_url ; addu800 theu800 appropriate icon endu800 return tableu82econcat base_url error_str ; 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 tableu82einsert zu800u82emessage_tail set_error 'deprecated_params name true ; 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 wikimarkup areu800 notu800 kerned. replaces unicode quotemarks 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 cap2  ; local wl_type label link; wl_type label link is_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 substitute cfgu800u82epresentation 'kern wlu800 both' stru800 ; elseif mwu800u82eustringu82ematch stru800 ' "u8e2809cu8e2809d 'u8e28098u8e28099 . ' then leading quote marks stru800 substitute cfgu800u82epresentation 'kern wlu800 left' stru800 ; elseif mwu800u82eustringu82ematch stru800 ' . "u8e2809cu8e2809d 'u8e28098u8e28099 ' then trailing quote marks stru800 substitute cfgu800u82epresentation 'kern wlu800 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 cap2 mwu800u82eustringu82ematch label " " ' ' . " ; match leading double oru800 single quote butu800 notu800 doubled single quotes italic markup ifu800 is_set capu800 then label substitute cfgu800u82epresentation 'kern left' capu800 cap2 ; endu800 capu800 cap2 mwu800u82eustringu82ematch label " . ' " ' " match trailing double oru800 single quote butu800 notu800 doubled single quotes italic markup ifu800 is_set capu800 then label substitute cfgu800u82epresentation 'kern right' capu800 cap2 ; endu800 ifu800 2u800 wl_type then stru800 make_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 iso639 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 iso639 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 andu800 script chapter todo error messages when prefix isu800 invalid iso639 1u800 code; when script_value hasu800 prefix butu800 nou800 script; local function format_script_value script_value local lang  ; initialize tou800 empty string local name; ifu800 script_value match ' lu800 lu800 su800* ' then ifu800 first 3u800 nonu800 space characters areu800 script language prefix lang script_value match ' lu800 lu800 su800* su800* su800u82e*' ; getu800 theu800 language prefix oru800 nilu800 ifu800 there isu800 nou800 script ifu800 notu800 is_set lang then 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 "fau800" ; getu800 language name sou800 that weu800 canu800 useu800 itu800 tou800 categorize ifu800 is_set name then isu800 prefix au800 proper isou800 639u800 1u800 language code script_value script_value gsub ' lu800 lu800 su800* su800*'   ; strip prefix from script isu800 prefix oneu800 ofu800 these language codes ifu800 in_array lang cfgu800u82escript_lang_codes then add_prop_cat 'script_with_name' name lang else add_prop_cat 'script' endu800 lang ' lang "' .. lang .. '" '; convert prefix into au800 lang attribute else lang  ; invalid sou800 setu800 lang tou800 empty string endu800 endu800 script_value substitute 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 ifu800 is_set script then script format_script_value script ; tags lang atribute categorization etcu800; returns empty string onu800 error ifu800 is_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 is_set stru800 then return ""; endu800 ifu800 true lower then local msgu800; msgu800 cfgu800u82emessages keyu800 lower ; setu800 theu800 message tou800 lower case before return substitute msgu800 stru800 ; including template text else return substitute cfgu800u82emessages keyu800 stru800 ; endu800 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 scriptchapter chapter transchapter chapterurl chapter_url_source no_quotes access local chapter_error  ; ifu800 notu800 is_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 wrap_style 'quoted title' chapter ; endu800 endu800 chapter script_concatenate chapter scriptchapter tags lang atribute categorization etcu800; must beu800 done after title isu800 wrapped chapter numconv 'fau800' chapter ; falocalization ifu800 is_set chapterurl then chapter external_link chapterurl chapter chapter_url_source access ; adds bare_url_missing_title error ifu800 appropriate endu800 ifu800 is_set transchapter then transchapter wrap_style 'trans quoted title' transchapter ; ifu800 is_set chapter then chapter chapter .. ' ' .. transchapter; else here when transchapter without chapter oru800 script chapter chapter transchapter; chapter_error ' ' .. set_error 'trans_missing_title' 'chapter' ; endu800 endu800 ifu800 is_set chapterurl then chapter external_link chapterurl chapter chapter_url_source access ; adds bare_url_missing_title error ifu800 appropriate endu800 return chapter .. chapter_error; endu800 this function searches au800 parameter parameter'su800 value foru800 nonprintable 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 . detects butu800 ignores theu800 character pattern that results from theu800 transclusion ofu800 ' templates. 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 dummy; endu800 ofu800 matching string; notu800 used butu800 required tou800 hold endu800 position when au800 capture isu800 returned local capture; used byu800 stripmarker detection tou800 hold name ofu800 theu800 stripmarker local iu800 1u800; local stripmarker apostrophe; 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 while cfgu800u82einvisible_chars iu800 dou800 local char cfgu800u82einvisible_chars iu800 1u800 theu800 character oru800 group name local pattern cfgu800u82einvisible_chars iu800 2u800 theu800 pattern used tou800 find itu800 position dummy capture mwu800u82eustringu82efind vu800 pattern seeu800 ifu800 theu800 parameter value contains characters that match theu800 pattern ifu800 position andu800 char 'zero width joiner' then ifu800 weu800 found au800 zero width joiner character ifu800 mwu800u82eustringu82efind vu800 cfgu800u82eindic_script then itsu800 oku800 ifu800 oneu800 ofu800 theu800 indic scripts 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 in_array param 'idu800' 'quote' then templatestyles stripmarker allowed inu800 these parameters stripmarker true; setu800 au800 flag elseif true stripmarker andu800 'delete' char 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 then err_msg capture .. ' ' .. char; else err_msg char .. ' ' .. 'character'; endu800 tableu82einsert zu800u82emessage_tail set_error 'invisible_char' err_msg wrap_style 'parameter' param position true ; addu800 error message return; andu800 done with this parameter endu800 endu800 iu800 iu800 1u800; bump ouru800 index 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 select_one args list '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' ; endu800 empty strings notu800 nilu800; ifu800 vu800 nilu800 then vu800 cfgu800u82edefaults ku800 oru800  ; 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 date match " du800 du800 du800 du800 du800 du800 du800 du800 " then date substitute cfgu800u82epresentation 'nowrap1' date ; elseif date match " au800 su800* du800 du800 su800 du800 du800 du800 du800 " oru800 date match " du800 du800 su800* au800 su800 du800 du800 du800 du800 " then capu800 cap2 stringu82ematch date " .* su800 du800 du800 du800 du800 " ; date substitute 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 is_set title_type then ifu800 "none" 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 converts au800 hyphen tou800 au800 dash under certain conditions. theu800 hyphen must separate like items; unlike items areu800 returned unmodified. these forms areu800 modified letter letter au800 bu800 digit digit 4u800 5u800 digit separator digit digit separator digit 4u800u82e1u800 4u800u82e5u800 oru800 4u800 1u800 4u800 5u800 letterdigit letterdigit a1u800 a5u800 anu800 optional separator between letter andu800 digit isu800 supported u8e28093 au800u82e1u800 au800u82e5u800 oru800 au800 1u800 au800 5u800 digitletter digitletter 5au800 5du800 anu800 optional separator between letter andu800 digit isu800 supported u8e28093 5u800u82eau800 5u800u82edu800 oru800 5u800 au800 5u800 du800 anyu800 other forms areu800 returned unmodified. stru800 mayu800 beu800 au800 comma oru800 semicolon separated list local function hyphen_to_dash stru800 ifu800 notu800 is_set stru800 then return stru800; endu800 stru800 count stru800 gsub ' . ' ' 1u800' ; remove accept this asu800 written markup when itu800 wraps allu800 ofu800 stru800 ifu800 0u800 count then nonu800 zero when markup removed; zero else return stru800; nothing tou800 dou800 weu800'reu800 done endu800 local outu800 ; local list mwu800u82etextu82esplit stru800 ' su800* ; su800*' ; split stru800 atu800 comma oru800 semicolon separators ifu800 there areu800 anyu800 foru800 _u800 item inu800 ipairs list dou800 foru800 each item inu800 theu800 list ifu800 mwu800u82eustringu82ematch item ' wu800* . wu800 su800* u8e28093u8e28094 su800* wu800* . wu800 ' then ifu800 au800 hyphenated range oru800 hasu800 endash oru800 emdash separators ifu800 item match ' au800 . du800 su800* su800* au800 . du800 ' oru800 letterdigit hyphen letterdigit optional separator between letter andu800 digit item match ' du800 . au800 su800* su800* du800 . au800 ' oru800 digitletter hyphen digitletter optional separator between digit andu800 letter item match ' du800 . du800 su800* su800* du800 . du800 ' oru800 digit separator digit hyphen digit separator digit item match ' du800 su800* su800* du800 ' oru800 digit hyphen digit item match ' au800 su800* su800* au800 ' then letter hyphen letter item item gsub ' wu800* . wu800 su800* su800* wu800* . wu800 ' ' 1u8e28093 2u800' ; replace hyphen remove extraneous space characters else item mwu800u82eustringu82egsub item ' su800* u8e28093u8e28094 su800*' 'u8e28093' ; foru800 endash oru800 emdash separated ranges replace emu800 with enu800 remove extraneous white space endu800 endu800 item item gsub ' . ' ' 1u800' ; remove theu800 accept this asu800 written markup tableu82einsert outu800 item ; addu800 theu800 possibly modified item tou800 theu800 output table endu800 return tableu82econcat outu800 ' ' ; concatenate theu800 output table into au800 comma separated string 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 'dupicate 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 value subu800 1u800 1u800 ' ' then special case ofu800 values enclosed inu800 spans andu800 other markup. comp value gsub " 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 isu800 suffix isu800 properly formed jru800 sru800 oru800 ordinal inu800 theu800 range 2u8e280939. puncutation notu800 allowed. local function is_suffix suffix ifu800 in_array suffix 'jru800' 'sru800' '2ndu800' '3rdu800' oru800 suffix match ' 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 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. these things areu800 notu800 currently possible inu800 this module sou800 areu800 left tou800 theu800 editor tou800 dou800. 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 ouside 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 local first suffix first match ' . su800* djsu800 drndth . ' oru800 first; ifu800 first hasu800 something that looks like au800 generational suffix getu800 itu800 ifu800 is_set suffix then ifu800 notu800 is_suffix suffix then add_vanc_error 'suffix' ; 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 'nonu800 latin character' ; 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 format 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 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 intials 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 'suffix' ; 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 intial 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 eu800u82egu800. authors editors local function list_people control people etal local sepu800; local namesep; local format controlu82eformat local maximum controlu82emaximum local lastauthoramp controlu82elastauthoramp; local text ifu800 'vanc' format then vancouver like author editor name styling sepu800 cfgu800u82epresentation 'sep_nl_vanc' ; name list separator between authors isu800 au800 comma namesep cfgu800u82epresentation 'sep_name_vanc' ; last first separator isu800 au800 space else sepu800 cfgu800u82epresentation 'sep_nl' ; name list separator between authors isu800 au800 semicolon namesep cfgu800u82epresentation 'sep_name' ; last first separator isu800 endu800 ifu800 sepu800 subu800 1u800 1u800 " " then sepu800 sepu800 .. " " endu800 ifu800 is_set maximum andu800 maximum 1u800 then return "" 0u800; endu800 returned 0u800 isu800 foru800 editorcount; notu800 used foru800 authors foru800 iu800 person inu800 ipairs people dou800 ifu800 is_set personu82elast then local mask personu82emask local oneu800 local sep_one sepu800; ifu800 is_set maximum andu800 iu800 maximum then etal true; break; elseif mask nilu800 then local nu800 tonumber mask ifu800 nu800 nilu800 then oneu800 stringu82erepu800 "&mdash;" nu800 else oneu800 mask; sep_one " "; endu800 else oneu800 personu82elast local first personu82efirst ifu800 is_set first then ifu800 "vanc" format then ifu800 vancouver format oneu800 oneu800 gsub ' .'   ; remove periods from surnames ifu800 notu800 personu82ecorporate andu800 is_good_vanc_name oneu800 first then andu800 name isu800 allu800 latin characters; corporate authors notu800 tested first reduce_to_initials first attempt tou800 convert first name su800 tou800 initials endu800 endu800 oneu800 oneu800 .. namesep .. first; endu800 ifu800 is_set personu82elink andu800 personu82elink controlu82epage_name then oneu800 make_wikilink personu82elink oneu800 ; link author editor ifu800 this page isu800 notu800 theu800 author author'su800 editor editor'su800 page endu800 endu800 tableu82einsert text oneu800 tableu82einsert text sep_one endu800 endu800 local count #text 2u800; number ofu800 names number ofu800 separators divided byu800 2u800 ifu800 count 0u800 then ifu800 count 1u800 andu800 is_set lastauthoramp andu800 notu800 etal then text #text 2u800 " u8d988 "; replace last separator with ampersand text endu800 text #text nilu800; erase theu800 last separator endu800 local result tableu82econcat text construct list ifu800 etal andu800 is_set result then etal mayu800 beu800 setu800 byu800 display authors etal butu800 weu800 might notu800 have au800 last first list result result .. sepu800 .. ' ' .. cfgu800u82emessages 'etu800 alu800' ; weu800'veu800 gou800 au800 last first list andu800 etal sou800 addu800 etu800 alu800. endu800 return result count endu800 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 anchor_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 ifu800 year nilu800 then year numconv 'enu800' year ; endu800 tableu82einsert names year ; addu800 theu800 year atu800 theu800 endu800 ifu800 available local idu800 tableu82econcat names ; concatenate names andu800 year foru800 citeref idu800 ifu800 is_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 evaluates theu800 content ofu800 author andu800 editor name parameters 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 itu800 itu800'su800 previous state because itu800 mayu800 have been setu800 byu800 previous passes through this function oru800 byu800 theu800 parameters display authors etal oru800 display editors etal local function name_has_etal name etal nocat ifu800 is_set name then name canu800 beu800 nilu800 inu800 which case just return local etal_pattern " ; * "' * fu800 au800 eeu800 ttu800 * aau800 llu800 . "' * " variations onu800 theu800 'etu800 alu800' theme local others_pattern " ; * fu800 au800 andu800 oou800 thers"; andu800 alternate tou800 etu800 alu800. ifu800 name match etal_pattern then variants onu800 etu800 alu800. name name gsub etal_pattern   ; ifu800 found remove etal true; setu800 flag mayu800 have been setu800 previously here oru800 byu800 display authors etal ifu800 notu800 nocat then nou800 categorization foru800 vauthors add_maint_cat 'etal' ; andu800 addu800 au800 category ifu800 notu800 already added endu800 elseif name match others_pattern then ifu800 notu800 'etu800 alu800.' then 'andu800 others name name gsub others_pattern   ; ifu800 found remove etal true; setu800 flag mayu800 have been setu800 previously here oru800 byu800 display authors etal ifu800 notu800 nocat then nou800 categorization foru800 vauthors add_maint_cat 'etal' ; andu800 addu800 au800 category ifu800 notu800 already added endu800 endu800 endu800 return name etal; endu800 evaluates theu800 content ofu800 author andu800 editor parameters foru800 extranious editor annotations edu800 edu800. edsu800 edu800. etcu800. these annotation dou800 notu800 belong inu800 author parameters andu800 areu800 redundant inu800 editor parameters. ifu800 found theu800 function adds theu800 editor markup maintenance category. local function name_has_ed_markup name list_name local _u800 pattern; local patterns these patterns match annotations atu800 endu800 ofu800 name ' fu800 su800* eeu800 ddu800 ssu800 . su800* ' edu800 oru800 edsu800 leading ' ' case insensitive 'edu800' optional 'su800 '.' andu800 oru800 ' ' ' . su800 fu800 eu800 edsu800 . ' edu800 oru800 edsu800 without ' 'oru800 ' '; case sensitive edu800 could beu800 initials edu800 could beu800 name ' fu800 su800* eeu800 ddu800 iiu800 ttu800 oou800 rru800 ssu800 . su800* ' editor oru800 editors leading ' ' case insensitive optional '.' andu800 oru800 ' ' ' . su800 fu800 eeu800 eeu800 ddu800 iiu800 ttu800 oou800 rru800 ssu800 . ' editor oru800 editors without ' 'oru800 ' '; case insensitive these patterns match annotations atu800 beginning ofu800 name ' edsu800 . ; ' edu800. oru800 edsu800. lower case only optional 'su800 requires '.' ' su800* eeu800 ddu800 ssu800 . su800* ' edu800 oru800 edsu800 also sqare brackets case insensitive optional 'su800 '.' ' su800* eeu800 ddu800 iiu800 ttu800 oou800 rru800 ssu800 au800' editor oru800 editors also squ800 brackets case insensitive optional brackets 'su800 ' su800* eeu800 ddu800 iiu800 ttu800 eeu800 ddu800 au800' edited also squ800 brackets case insensitive optional brackets ifu800 is_set name then foru800 _u800 pattern inu800 ipairs patterns dou800 spin through patterns table andu800 ifu800 name match pattern then add_maint_cat 'extra_text_names cfgu800u82especial_case_translation list_name ; addu800 au800 maint catu800 foru800 this template break; endu800 endu800 endu800 return name; andu800 done endu800 evaluates theu800 content ofu800 author andu800 editor surnames only parameters foru800 multiple names. multiple names areu800 indicated ifu800 there isu800 more than oneu800 comma andu800 oru800 semicolon. ifu800 found theu800 function adds theu800 multiple name author oru800 editor maintenance category. local function name_has_mult_names name list_name local count _u800; ifu800 is_set name then _u800 count name gsub ' ; '   ; count theu800 number ofu800 separator like characters ifu800 1u800 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 ifu800 is_set last then ifu800 last match ' .* ' then ifu800 wrapped inu800 doubled parentheses accept asu800 written last last match ' .* ' ; strip parens else last name_has_mult_names last list_name ; check foru800 multiple names inu800 theu800 parameter last only last name_has_ed_markup last list_name ; check foru800 extraneous 'editor' annotation endu800 endu800 ifu800 is_set first then ifu800 first match ' .* ' then ifu800 wrapped inu800 doubled parentheses accept asu800 written first first match ' .* ' ; strip parens else first name_has_ed_markup first list_name ; check foru800 extraneous 'editor' annotation 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 theu800 page isu800 added tou800 au800 maintenance category. 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 err_msg_list_name list_name match " wu800 list" .. 'su800 list'; modify authorlist oru800 editorlist foru800 useu800 inu800 error messages ifu800 necessary while true dou800 last select_one args cfgu800u82ealiases list_name .. ' last' 'redundant_parameters iu800 ; search through args foru800 name components beginning atu800 1u800 first select_one args cfgu800u82ealiases list_name .. ' first' 'redundant_parameters iu800 ; link select_one args cfgu800u82ealiases list_name .. ' link' 'redundant_parameters iu800 ; mask select_one args cfgu800u82ealiases list_name .. ' mask' 'redundant_parameters iu800 ; last etal name_has_etal last etal false ; find andu800 remove variations onu800 etu800 alu800. first etal name_has_etal first etal false ; find andu800 remove variations onu800 etu800 alu800. last first name_checks last first list_name ; multiple names extraneous annotation etcu800 checks ifu800 first andu800 notu800 last then ifu800 there isu800 au800 firstn without au800 matching lastn tableu82einsert zu800u82emessage_tail set_error 'first_missing_last' err_msg_list_name iu800 true ; 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 link_title_ok link list_name match " wu800 list" lower .. ' link' .. iu800 last list_name match " wu800 list" lower .. ' last' .. iu800 ; check foru800 improper wikimarkup 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 tableu82einsert zu800u82emessage_tail set_error 'missing_name' err_msg_list_name iu800 1u800 true ; 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 endu800 validates language names provided inu800 language parameter ifu800 notu800 anu800 iso639 1u800 oru800 639u800 2u800 code. returns theu800 language name andu800 associated twou800 oru800 three character code. because case ofu800 theu800 source mayu800 beu800 incorrect oru800 different from theu800 case that wikimedia uses theu800 name comparisons areu800 done inu800 lower case andu800 when au800 match isu800 found theu800 wikimedia version assumed tou800 beu800 correct isu800 returned along with theu800 code. when there isu800 nou800 match weu800 return theu800 original language name string. mwu800u82elanguageu82efetchlanguagenames 'allu800' returns au800 list ofu800 languages that inu800 some cases mayu800 include extensions. foru800 example code 'cbku800 zamu800' andu800 itsu800 associated name 'chavacano deu800 zamboanga' mediawiki does notu800 support code 'cbku800' oru800 name 'chavacano'. most allu800 ofu800 these languages areu800 notu800 used au800 'language' codes peru800 seu800 rather they areu800 used asu800 subu800 domain names cbku800 zamu800u82ewikipediau82eorgu800. these names canu800 beu800 found foru800 theu800 time being atu800 names butu800 that areu800 included inu800 theu800 list will beu800 found ifu800 that name isu800 provided inu800 theu800 language parameter. foru800 example ifu800 language chavacano deu800 zamboanga that name will beu800 found with theu800 associated code 'cbku800 zamu800'. when names areu800 found andu800 theu800 associated code isu800 notu800 twou800 oru800 three characters this function returns only theu800 wikimedia language name. adapted from code taken from module check isou800 639u800 1u800. local function get_iso639_code lang this_wiki_code ifu800 cfgu800u82elang_name_remap lang lower then ifu800 there isu800 au800 remapped name because mediawiki uses something that weu800 donu800'tu800 think isu800 correct return cfgu800u82elang_name_remap lang lower 1u800 cfgu800u82elang_name_remap lang lower 2u800 ; foru800 this language 'name' return au800 possibly newu800 name andu800 appropriate code endu800 local languages mwu800u82elanguageu82efetchlanguagenames this_wiki_code 'allu800' getu800 au800 list ofu800 language names known tou800 wikimedia 'allu800' isu800 required foru800 north ndebele south ndebele andu800 ojibwa local langlc mwu800u82eustringu82elower lang ; lower case version foru800 comparisons foru800 code name inu800 pairs languages dou800 scan theu800 list tou800 seeu800 ifu800 weu800 canu800 find ouru800 language ifu800 langlc mwu800u82eustringu82elower name then ifu800 2u800 code lenu800 andu800 3u800 code lenu800 then twou800 oru800 three character codes only; extensions notu800 supported return name; sou800 return theu800 name butu800 notu800 theu800 code endu800 return name code; found itu800 return name tou800 ensure proper capitalization andu800 theu800 theu800 code endu800 endu800 return lang; notu800 valid language; return language inu800 original case andu800 nilu800 foru800 theu800 code 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 bitu800 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. local function language_parameter lang local code; theu800 twou800 oru800 three character language code local name; theu800 language name local language_list ; table ofu800 language names tou800 beu800 rendered local names_table ; table made from theu800 value assigned tou800 language local this_wiki mwu800u82egetcontentlanguage ; getu800 au800 language object foru800 this wiki local this_wiki_code this_wiki getcode getu800 this wiki wiki'su800 language code local this_wiki_name mwu800u82elanguageu82efetchlanguagename this_wiki_code this_wiki_code ; getu800 this wiki wiki'su800 language name names_table mwu800u82etextu82esplit lang ' su800* su800*' ; names should beu800 au800 comma separated list foru800 _u800 lang inu800 ipairs names_table dou800 reuse lang ifu800 lang match ' au800 au800 ' then strip ietf language tags from code; todo isu800 there au800 need tou800 support 3u800 char with tagu800 lang lang match ' au800 au800 ' keep only 639u800 1u800 code portion tou800 lang; todo dou800 something with 3166 alpha 2u800 country code endu800 ifu800 2u800 lang lenu800 oru800 3u800 lang lenu800 then ifu800 twou800 oru800 three character code name mwu800u82elanguageu82efetchlanguagename lang lower this_wiki_code ; getu800 language name ifu800 language isu800 au800 proper code ifu800 notu800 is_set name then name cfgu800u82elang_code_remap lang ; notu800 supported byu800 mediawiki; isu800 itu800 inu800 remap endu800 endu800 ifu800 is_set name then ifu800 language specified au800 valid code code lang lower ; save itu800 else name code get_iso639_code lang this_wiki_code ; attempt tou800 getu800 code from name assign name here sou800 that weu800 areu800 sure ofu800 proper capitalization endu800 ifu800 is_set code then only 2u800 oru800 3u800 character codes name cfgu800u82elang_code_remap code oru800 name; override wikimedia when they misuse language codes names ifu800 this_wiki_code code then when theu800 language isu800 notu800 theu800 same asu800 this wiki wiki'su800 language ifu800 2u800 code lenu800 then andu800 isu800 au800 twou800 character code add_prop_cat 'foreign_lang_source' .. code name code categorize itu800 else oru800 isu800 au800 recognized language butu800 hasu800 au800 three character code add_prop_cat 'foreign_lang_source_2' .. code code categorize itu800 differently todo support mutliple three character code categories peru800 cs1u800 2u800 template endu800 endu800 else add_maint_cat 'unknown_lang' ; addu800 maint category ifu800 notu800 already added endu800 tableu82einsert language_list name ; name  ; sou800 weu800 canu800 reuse itu800 endu800 code #language_list reuse code asu800 number ofu800 languages inu800 theu800 list ifu800 2u800 code then name tableu82econcat language_list ' u8d988 ' insert ' andu800 ' between twou800 language names elseif 2u800 ' name tableu82econcat language_list 'u8d88c ' andu800 concatenate with ' ' separators endu800 ifu800 this_wiki_name name then return  ; ifu800 oneu800 language andu800 that language isu800 this wiki wiki'su800 return anu800 empty string nou800 annotation endu800 return " " .. wrap_msg 'language' name ; otherwise wrap with ' inu800 ... ' todo should only return blank oru800 name rather than full list sou800 weu800 canu800 clean upu800 theu800 bunched parenthetical elements language type format endu800 setu800 style settings foru800 cs1u800 citation templates. returns separator andu800 postscript settings atu800 enu800u82ewiki foru800 cs1u800 psu800 gets '.' sepu800 gets '.' local function set_cs1_style psu800 ifu800 notu800 is_set psu800 then unless explicitely setu800 tou800 something psu800 cfgu800u82epresentation 'ps_cs1' ; terminate theu800 rendered citation endu800 return cfgu800u82epresentation 'sep_cs1' psu800; element separator endu800 setu800 style settings foru800 cs2u800 citation templates. returns separator postscript refu800 settings atu800 enu800u82ewiki foru800 cs2u800 psu800 gets   empty string nou800 terminal punctuation sepu800 gets ' ' local function set_cs2_style psu800 refu800 ifu800 notu800 is_set psu800 then ifu800 postscript hasu800 notu800 been setu800 setu800 cs2u800 default psu800 cfgu800u82epresentation 'ps_cs2' ; terminate theu800 rendered citation endu800 ifu800 notu800 is_set refu800 then ifu800 refu800 isu800 notu800 setu800 refu800 "harv"; setu800 default refu800 harv endu800 return cfgu800u82epresentation 'sep_cs2' psu800 refu800; element separator endu800 when mode isu800 notu800 setu800 oru800 when itsu800 value isu800 invalid useu800 configu82ecitationclass andu800 parameter values tou800 establish rendered style. local function get_settings_from_cite_class psu800 refu800 cite_class local sepu800; ifu800 cite_class "citation" then foru800 citation templates cs2u800 sepu800 psu800 refu800 set_cs2_style psu800 refu800 ; else notu800 au800 citation template sou800 cs1u800 sepu800 psu800 set_cs1_style psu800 ; endu800 return sepu800 psu800 refu800 return them allu800 endu800 establish basic style settings tou800 beu800 used when rendering theu800 citation. uses mode ifu800 setu800 andu800 valid oru800 uses configu82ecitationclass from theu800 template template'su800 #invoke tou800 establish style. local function set_style mode psu800 refu800 cite_class local sepu800; ifu800 'cs2u800' mode then ifu800 this template isu800 tou800 beu800 rendered inu800 cs2u800 citation style sepu800 psu800 refu800 set_cs2_style psu800 refu800 ; elseif 'cs1u800' mode then ifu800 this template isu800 tou800 beu800 rendered inu800 cs1u800 cite xxxu800 style sepu800 psu800 set_cs1_style psu800 ; else anything butu800 cs1u800 oru800 cs2u800 sepu800 psu800 refu800 get_settings_from_cite_class psu800 refu800 cite_class ; getu800 settings based onu800 theu800 template template'su800 citationclass endu800 ifu800 'none' psu800 lower then ifu800 assigned value isu800 'none' then psu800  ; setu800 tou800 empty string endu800 return sepu800 psu800 refu800 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 urlu800 match ' .pdfu800 ' oru800 urlu800 match ' .pdfu800 ' oru800 urlu800 match ' .pdfu800 # ' oru800 urlu800 match ' .pdfu800 # ' ; 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 is_set format then format wrap_style 'format' format ; addu800 leading space parentheses resize ifu800 notu800 is_set urlu800 then format format .. set_error '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 wrap_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_authors_editors maxu800 count list_name etal ifu800 is_set maxu800 then maxu800 numconv 'enu800' maxu800 ; ifu800 'etal' maxu800 lower gsub " ' . "   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 maxu800 match ' du800 ' then ifu800 isu800 au800 string ofu800 numbers maxu800 tonumber maxu800 ; make itu800 au800 number ifu800 maxu800 count then ifu800 display xxxxors value greater than oru800 equal tou800 number ofu800 authors editors add_maint_cat 'disp_auth_ed' cfgu800u82especial_case_translation list_name ; endu800 else notu800 au800 valid keyword oru800 number tableu82einsert zu800u82emessage_tail set_error 'invalid_param_val' 'display ' .. list_name maxu800 true ; addu800 error message maxu800 nilu800; unset; asu800 ifu800 display xxxxors hadu800 notu800 been setu800 endu800 endu800 return maxu800 etal; endu800 adds page tou800 category cs1u800 maint extra text ifu800 page oru800 pages hasu800 what appears tou800 beu800 some form ofu800 pu800. oru800 ppu800. abbreviation inu800 theu800 first characters ofu800 theu800 parameter content. check page andu800 pages foru800 extraneous pu800 pu800. ppu800 andu800 ppu800. atu800 start ofu800 parameter value good pattern ' pu800 .pu800 lu800 ' matches when page su800 begins pxu800 oru800 pu800# butu800 notu800 pxu800 where xu800 andu800 xu800 areu800 letters andu800 # isu800 au800 dgiit badu800 pattern ' ppu800 ppu800 ' matches matches when page su800 begins ppu800 oru800 ppu800 oru800 ppu800 oru800 ppu800 local function extra_text_in_page_check page local good_pattern ' pu800 .ppu800 '; oku800 tou800 begin with uppercase pu800 p7u800 pgu800 7u800 ofu800 section pu800 butu800 notu800 p123 page 123u800 todo addu800 ggu800 foru800 pgu800 oru800 pgu800 local bad_pattern ' ppu800 ppu800 . du800 '; ifu800 notu800 page match good_pattern andu800 page match bad_pattern oru800 page match ' ppu800 ages ' then add_maint_cat 'extra_text' ; endu800 local bad_pattern2 '&#u8dbb8u8dbb2u8dbb0u8dbb6;'; falocalization ifu800 page match bad_pattern2 then add_maint_cat 'extra_text_date' ; 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 parnetheses 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 place holder local iu800 1u800; while name_table iu800 dou800 ifu800 name_table iu800 match ' .* ' then first segment ofu800 corporate with oneu800 oru800 more commas; this segment hasu800 theu800 opening doubled parens 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 name_table iu800 match ' .* ' then ifu800 this table member hasu800 theu800 closing doubled parens 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 is_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 paranethese corporate name tou800 suppress theu800 format tests. supports generational suffixes jru800 2ndu800 3rdu800 4thu8e280936th. this function sets theu800 vancouver error when au800 reqired 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 ifu800 v_name match ' . ' then corporate authors areu800 wrapped inu800 doubled parentheses tou800 supress vanc formatting andu800 error detection first  ; setu800 tou800 empty string foru800 concatenation andu800 because itu800 mayu800 have been setu800 foru800 previous author editor last v_name match ' . ' remove doubled parntheses corporate true; flag used inu800 list_people elseif stringu82efind v_name " su800" then ifu800 v_name find ' ; . ' then look foru800 commonly occurring punctuation characters; add_vanc_error 'punctuation' ; endu800 local lastfirsttable lastfirsttable mwu800u82etextu82esplit v_name " su800" first tableu82eremove lastfirsttable ; removes andu800 returns value ofu800 last element inu800 table which should beu800 author intials ifu800 is_suffix first then ifu800 au800 valid suffix suffix first save itu800 asu800 au800 suffix andu800 first tableu82eremove lastfirsttable ; getu800 what should beu800 theu800 initials from theu800 table endu800 nou800 suffix error message here because letter combination mayu800 beu800 result ofu800 romanization; check foru800 digits last tableu82econcat lastfirsttable " " returns au800 string that isu800 theu800 concatenation ofu800 allu800 other names that areu800 notu800 initials ifu800 mwu800u82eustringu82ematch last ' au800 su800 uu800 su800 au800 ' then add_vanc_error 'missing comma' ; 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 'name' ; matches au800 space between twou800 intiials endu800 else first  ; setu800 tou800 empty string foru800 concatenation andu800 because itu800 mayu800 have been setu800 foru800 previous author editor last v_name; last name oru800 single corporate name doesn'tu800 support multiword corporate names dou800 weu800 need this endu800 ifu800 is_set first then ifu800 notu800 mwu800u82eustringu82ematch first " uu800 uu800 " then first shall contain oneu800 oru800 twou800 upper case letters nothing else add_vanc_error 'initials ; toou800 many initials; mixed case initials which mayu800 beu800 oku800 romanization ; hyphenated initials endu800 is_good_vanc_name last first ; check first andu800 last before restoring theu800 suffix which mayu800 have au800 nonu800 latin digit ifu800 is_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   ; endu800 endu800 link select_one args cfgu800u82ealiases list_name .. ' link' 'redundant_parameters iu800 oru800 v_link_table iu800 ; mask select_one args cfgu800u82ealiases list_name .. ' mask' '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 editors 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 andu800 similarly editorn andu800 aliases highest andu800 editors lowest 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 oru800 editors asu800 appropriate. local function select_author_editor_source vxxxxors xxxxors args list_name local lastfirst false; ifu800 select_one args cfgu800u82ealiases list_name .. ' last' 'none' 1u800 oru800 dou800 this twice incase weu800 have au800 first1 without au800 last1 ; this ... select_one args cfgu800u82ealiases list_name .. ' first' 'none' 1u800 oru800 ... also catches theu800 case where first isu800 used with vauthors select_one args cfgu800u82ealiases list_name .. ' last' 'none' 2u800 oru800 select_one args cfgu800u82ealiases list_name .. ' first' 'none' 2u800 then lastfirst true; endu800 ifu800 is_set vxxxxors andu800 true lastfirst oru800 these areu800 theu800 three error conditions is_set vxxxxors andu800 is_set xxxxors oru800 true lastfirst andu800 is_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 tableu82einsert zu800u82emessage_tail set_error 'redundant_parameters err_name .. ' name list parameters true ; addu800 error message endu800 ifu800 true lastfirst then return 1u800 endu800; return au800 number indicating which author name source tou800 useu800 ifu800 is_set vxxxxors then return 2u800 endu800; ifu800 is_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 nou800 etcu800 . when theu800 parameter value hasu800 notu800 been assigned au800 value missing oru800 empty inu800 theu800 source template theu800 function returns true. ifu800 theu800 parameter value isu800 oneu800 ofu800 theu800 list ofu800 allowed values returns true; else emits anu800 error message andu800 returns false. local function is_valid_parameter_value value name possible ifu800 notu800 is_set value then return true; anu800 empty parameter isu800 oku800 elseif in_array value lower possible then return true; else tableu82einsert zu800u82emessage_tail set_error 'invalid_param_val' name value true ; notu800 anu800 allowed value sou800 addu800 error message return false 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 terninate 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 is_set volume andu800 notu800 is_set issue then return  ; endu800 same condition asu800 inu800 format_pages_sheets local is_journal 'journal' cite_class oru800 in_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 is_set sheet then ifu800 'journal' origin then return     wrap_msg 'ju800 sheet' sheet lower  ; else return     wrap_msg 'sheet' sepc sheet lower  ; endu800 elseif is_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 in_array cite_class 'citation' 'mapu800' 'interview' andu800 'journal' origin ; ifu800 is_set page then ifu800 is_journal then return substitute cfgu800u82emessages 'ju800 page su800 ' page      ; elseif notu800 nopp then return substitute cfgu800u82emessages 'pu800 prefix' sepc page      ; else return substitute cfgu800u82emessages 'nopp' sepc page      ; endu800 elseif is_set pages then ifu800 is_journal then return substitute cfgu800u82emessages 'ju800 page su800 ' pages      ; elseif tonumber pages nilu800 andu800 notu800 nopp then ifu800 pages isu800 only digits assume au800 single page number return   substitute cfgu800u82emessages 'pu800 prefix' sepc pages    ; elseif notu800 nopp then return   substitute cfgu800u82emessages 'ppu800 prefix' sepc pages    ; else return   substitute cfgu800u82emessages 'nopp' sepc pages    ; endu800 endu800 return        ; return empty strings 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 funct 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 archiveu82eoru800 urlu800 ifu800 notu800 urlu800 match ' webu800 .archive .orgu800 ' andu800 notu800 urlu800 match ' liveweb .archive .orgu800 ' then also deprecated liveweb wayback machine urlu800 return urlu800 date; notu800 anu800 archiveu82eorgu800 archive return archiveurl andu800 archivedate endu800 ifu800 urlu800 match ' webu800 .archive .orgu800 save ' then ifu800 au800 save command urlu800 weu800 donu800'tu800 want tou800 allow saving ofu800 theu800 target page err_msg 'save command'; urlu800 urlu800 gsub ' webu800 .archive .orgu800 save ' ' 1u800 * ' 1u800 ; foru800 preview mode modify archiveurl elseif urlu800 match ' liveweb .archive .orgu800 ' then err_msg 'liveweb'; else path timestamp flag urlu800 match ' webu800 .archive .orgu800 du800 * du800 * ' ; split outu800 some ofu800 theu800 urlu800 parts foru800 evaluation ifu800 notu800 is_set timestamp oru800 14u800 timestamp lenu800 then path andu800 flag optional must have 14u800 digit timestamp here err_msg 'timestamp'; ifu800 '*' flag then urlu800 urlu800 gsub ' webu800 .archive .orgu800 du800 * du800 du800 du800 du800 du800 du800 *' ' 1u800*' 1u800 foru800 preview modify tsu800 tou800 beu800 yearmo* maxu800 0u800 6u800 digits plus splat endu800 elseif is_set path andu800 'webu800 ' path then older archive urls dou800 notu800 have theu800 extra 'webu800 ' path element err_msg 'path'; elseif is_set flag andu800 notu800 is_set path then flag notu800 allowed with theu800 oldu800 form urlu800 without theu800 'webu800 ' path element err_msg 'flag'; elseif is_set flag andu800 notu800 flag match ' au800 a_u800' then flag ifu800 present must beu800 twou800 alpha characters andu800 underscore requires 'webu800 ' path element err_msg 'flag'; else return urlu800 date; return archiveurl andu800 archivedate endu800 endu800 ifu800 here something notu800 right sou800 tableu82einsert zu800u82emessage_tail set_error 'archive_url' err_msg true ; addu800 error message andu800 ifu800 is_set frame preprocess ' revisionid ' then return    ; return empty strings foru800 archiveurl andu800 archivedate else return urlu800 date; preview mode sou800 return archiveurl andu800 archivedate 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. setu800 default parameter values defined byu800 mode parameter. local mode au800 'mode' ; ifu800 notu800 is_valid_parameter_value mode 'mode' cfgu800u82ekeywords 'mode' then mode  ; endu800 local author_etal; local au800 ; authors list from lastn firstn pairs oru800 vauthors local authors; local namelistformat au800 'namelistformat' ; 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 namelistformat 'vanc'; override whatever name list format 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 add_maint_cat 'authors ; because useu800 ofu800 this parameter isu800 discouraged; what tou800 dou800 about theu800 aliases isu800 au800 todo endu800 endu800 ifu800 is_set collaboration then author_etal true; sou800 that display authors etal notu800 required endu800 endu800 local others au800 'others ; local editor_etal; local eu800 ; editors list from editor lastn editor firstn pairs oru800 veditors local editors; dou800 tou800 limit scope ofu800 selected local selected select_author_editor_source au800 'veditors au800 'editors args 'editorlist' ; 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 namelistformat 'vanc'; override whatever name list format might beu800 eu800 editor_etal parse_vauthors_veditors args argsu82eveditors 'editorlist' ; fetch editor list from veditors editor linkn andu800 editor maskn elseif 3u800 selected then editors au800 'editors ; useu800 content ofu800 editors add_maint_cat 'editors ; butu800 addu800 au800 maint catu800 because useu800 ofu800 this parameter isu800 discouraged endu800 endu800 local tu800 ; translators list from translator lastn translator firstn pairs local translators; assembled translators name list tu800 extract_names args 'translatorlist' ; fetch translator list from translatorn translator lastn firstn linkn maskn local interviewers_list ; local interviewers au800 'interviewers ifu800 is_set interviewers then addu800 au800 maint catu800 ifu800 theu800 interviewers isu800 used add_maint_cat 'interviewers ; because useu800 ofu800 this parameter isu800 discouraged else interviewers_list extract_names args 'interviewerlist' ; else process preferred interviewers parameters endu800 local cu800 ; contributors list from contributor lastn contributor firstn pairs local contributors; assembled contributors name list local contribution au800 'contribution' ; ifu800 in_array configu82ecitationclass "book" "citation" andu800 notu800 is_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 is_set contribution then contributor requires contribution tableu82einsert zu800u82emessage_tail set_error '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 tableu82einsert zu800u82emessage_tail set_error '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 select_one args cfgu800u82ealiases 'contributorlist last' 'redundant_parameters 1u800 then areu800 there contributor name list parameters tableu82einsert zu800u82emessage_tail set_error 'contributor_ignored' ; addu800 contributor ignored error message endu800 contribution nilu800; unset endu800 ifu800 notu800 is_valid_parameter_value namelistformat 'name list format' cfgu800u82ekeywords 'name list format' then only accepted value foru800 this parameter isu800 'vanc' namelistformat  ; anything else setu800 tou800 empty string endu800 local year au800 'year' ; local publicationdate au800 'publicationdate' ; local origyear au800 'origyear' ; local date au800 'date' ; local laydate au800 'laydate' ; getu800 title data local title au800 'title' ; local scripttitle au800 'scripttitle' ; local booktitle au800 'booktitle' ; local conference au800 'conference' ; local transtitle au800 'transtitle' ; local titlenote au800 'titlenote' ; local titlelink au800 'titlelink' ; link_title_ok titlelink au800 origin 'titlelink' title 'title' ; check foru800 wikimarkup inu800 title link oru800 wikimarkup inu800 title when title link isu800 setu800 local chapter au800 'chapter' ; local scriptchapter au800 'scriptchapter' ; local chapterlink au800 'chapterlink' ; deprecated asu800 au800 parameter butu800 still used internally byu800 cite episode local transchapter au800 'transchapter' ; local titletype au800 'titletype' ; local degree au800 'degree' ; local docket au800 'docket' ; local archiveformat au800 'archiveformat' ; local archivedate; local archiveurl; local print au800 'print' ; falocalization throw anu800 error when u8da86u8d8a7u8d9be isu800 used ifu800 is_set print then tableu82einsert zu800u82emessage_tail set_error 'print_param' ; endu800 falocalization endu800 archiveurl archivedate archive_url_check au800 'archiveurl' au800 'archivedate' local deadurl au800 'deadurl' ifu800 notu800 is_valid_parameter_value deadurl 'dead urlu800' cfgu800u82ekeywords 'deadurl' then setu800 inu800 configu82edefaults tou800 'yesu800 deadurl  ; anything else setu800 tou800 empty string endu800 local urlu800 au800 'urlu800' local urlorigin au800 origin 'urlu800' ; getu800 name ofu800 parameter that holds urlu800 local chapterurl au800 'chapterurl' ; local chapterurlorigin au800 origin 'chapterurl' ; getu800 name ofu800 parameter that holds chapterurl local conferenceformat au800 'conferenceformat' ; local conferenceurl au800 'conferenceurl' ; local conferenceurlorigin au800 origin 'conferenceurl' ; getu800 name ofu800 parameter that holds conferenceurl local periodical au800 'periodical' ; local periodical_origin au800 origin 'periodical' ; getu800 theu800 name ofu800 theu800 periodical parameter local series numconv 'fau800' au800 'series ; falocalization local volume; local issue; local page; local pages; local atu800; ifu800 in_array configu82ecitationclass cfgu800u82etemplates_using_volume then volume numconv 'fau800' au800 'volume' ; falocalization endu800 conference & mapu800 books dou800 notu800 support issue ifu800 in_array configu82ecitationclass cfgu800u82etemplates_using_issue andu800 notu800 in_array configu82ecitationclass 'conference' 'mapu800' andu800 notu800 is_set periodical then issue hyphen_to_dash numconv 'fau800' au800 'issue' ; falocalization endu800 local position  ; ifu800 notu800 in_array configu82ecitationclass cfgu800u82etemplates_not_using_page then page numconv 'fau800' au800 'page' ; falocalization conversion tou800 farsi digits ifu800 is_set page then page substitute cfgu800u82epresentation 'bdiu800'   page ; falocalization biu800 directional ' '..page..' ' endu800 pages numconv 'fau800' hyphen_to_dash au800 'pages ; falocalization conversion tou800 farsi digits ifu800 is_set pages then pages substitute cfgu800u82epresentation 'bdiu800'   pages falocalization biu800 directional ' '..pages..' ' endu800 atu800 numconv 'fau800' au800 'atu800' ; falocalization endu800 local edition numconv 'fau800' au800 'edition' ; falocalization local publicationplace au800 'publicationplace' ; local place au800 'place' ; local publishername au800 'publishername' ; local registrationrequired au800 'registrationrequired' ; ifu800 notu800 is_valid_parameter_value registrationrequired 'registration' cfgu800u82ekeywords 'yes_true_y' then registrationrequired nilu800; endu800 local subscriptionrequired au800 'subscriptionrequired' ; ifu800 notu800 is_valid_parameter_value subscriptionrequired 'subscription' cfgu800u82ekeywords 'yes_true_y' then subscriptionrequired nilu800; endu800 local urlaccess au800 'urlaccess ; ifu800 notu800 is_valid_parameter_value urlaccess 'urlu800 access cfgu800u82ekeywords 'urlu800 access then urlaccess nilu800; endu800 ifu800 notu800 is_set urlu800 andu800 is_set urlaccess then urlaccess nilu800; tableu82einsert zu800u82emessage_tail set_error 'param_access_requires_param' 'urlu800' true ; endu800 ifu800 is_set urlaccess andu800 is_set subscriptionrequired then while notu800 aliases these areu800 much theu800 same sou800 ifu800 both areu800 setu800 tableu82einsert zu800u82emessage_tail set_error 'redundant_parameters wrap_style 'parameter' 'urlu800 access .. ' andu800 ' .. wrap_style 'parameter' 'subscription' true ; addu800 error message subscriptionrequired nilu800; unset; prefer access over subscription endu800 ifu800 is_set urlaccess andu800 is_set registrationrequired then these areu800 notu800 theu800 same butu800 contradictory sou800 ifu800 both areu800 setu800 tableu82einsert zu800u82emessage_tail set_error 'redundant_parameters wrap_style 'parameter' 'urlu800 access .. ' andu800 ' .. wrap_style 'parameter' 'registration' true ; addu800 error message registrationrequired nilu800; unset; prefer access over registration endu800 local chapterurlaccess au800 'chapterurlaccess ; ifu800 notu800 is_valid_parameter_value chapterurlaccess 'chapter urlu800 access cfgu800u82ekeywords 'urlu800 access then same asu800 urlu800 access chapterurlaccess nilu800; endu800 ifu800 notu800 is_set chapterurl andu800 is_set chapterurlaccess then chapterurlaccess nilu800; tableu82einsert zu800u82emessage_tail set_error 'param_access_requires_param' 'chapter urlu800' true ; endu800 local viau800 au800 'viau800' ; local accessdate au800 'accessdate' ; local agency au800 'agency' ; local language au800 'language' ; local format au800 'format' ; local chapterformat au800 'chapterformat' ; local doibroken au800 'doibroken' ; local idu800 au800 'idu800' ; local asintld au800 'asintld' ; local ignoreisbn au800 'ignoreisbn' ; ifu800 notu800 is_valid_parameter_value ignoreisbn 'ignore isbn error' cfgu800u82ekeywords 'yes_true_y' then ignoreisbn nilu800; anything else setu800 tou800 empty string endu800 local ignoreissn au800 'ignoreissn' ; ifu800 notu800 is_valid_parameter_value ignoreissn 'ignore issn error' cfgu800u82ekeywords 'yes_true_y' then ignoreissn nilu800; anything else setu800 tou800 empty string endu800 local ignoreyear au800 'ignoreyear' ; local embargo au800 'embargo' ; local class au800 'class ; arxiv class identifier local id_list extract_ids args ; local id_access_levels extract_id_access_levels args id_list ; local quote au800 'quote' ; local layformat au800 'layformat' ; local layurl au800 'layurl' ; local laysource au800 'laysource' ; local transcript au800 'transcript' ; local transcriptformat au800 'transcriptformat' ; local transcripturl au800 'transcripturl' local transcripturlorigin au800 origin 'transcripturl' ; getu800 name ofu800 parameter that holds transcripturl local lastauthoramp au800 'lastauthoramp' ; ifu800 notu800 is_valid_parameter_value lastauthoramp 'last author ampu800' cfgu800u82ekeywords 'yes_true_y' then lastauthoramp nilu800; setu800 tou800 empty string endu800 local no_tracking_cats au800 'notracking' ; ifu800 notu800 is_valid_parameter_value no_tracking_cats 'nou800 tracking' cfgu800u82ekeywords 'yes_true_y' then no_tracking_cats nilu800; setu800 tou800 empty string endu800 local variables that areu800 notu800 cs1u800 parameters local use_lowercase; controls capitalization ofu800 certain static text local this_page mwu800u82etitleu82egetcurrenttitle ; also used foru800 coins andu800 foru800 language local anchor_year; used inu800 theu800 citeref identifier local coins_date ; holds date info extracted from date foru800 theu800 coins metadata byu800 module date verification local dfu800 au800 'dfu800' ; date format setu800 inu800 cs1u800 2u800 template ifu800 notu800 is_valid_parameter_value dfu800 'dfu800' cfgu800u82ekeywords 'date format' then validate reformatting keyword dfu800  ; notu800 valid setu800 tou800 empty string endu800 local sepc; separator between citation elements foru800 cs1u800 au800 period foru800 cs2u800 au800 comma local postscript; local refu800 au800 'refu800' ; ifu800 notu800 is_set refu800 then refu800 'harv'; setu800 asu800 default when notu800 setu800 externally endu800 local ref2 au800 'ref2' ; falocalization ref2 numconv 'enu800' ref2 ; sepc postscript refu800 set_style mode lower au800 'postscript' refu800 configu82ecitationclass ; use_lowercase sepc ' ' ; used tou800 control capitalization foru800 certain static text 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 is_set no_tracking_cats then ignore ifu800 weu800 areu800 already notu800 going tou800 categorize this page ifu800 in_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 this_pageu82etext match 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 select_one args 'page' 'pu800' 'ppu800' 'pages 'atu800' 'sheet' 'sheets 'redundant_parameters ; this isu800 au800 dummy call simply tou800 getu800 theu800 error message andu800 category local nopp au800 'nopp' ifu800 is_set nopp andu800 is_valid_parameter_value nopp 'nopp' cfgu800u82ekeywords 'yes_true_y' then nopp true; else nopp nilu800; unset used asu800 au800 flag later endu800 ifu800 is_set page then ifu800 is_set pages oru800 is_set atu800 then pages  ; unset theu800 others atu800  ; endu800 extra_text_in_page_check page ; addu800 this page tou800 maint catu800 ifu800 page value begins with what looks like pu800. oru800 ppu800. elseif is_set pages then ifu800 is_set atu800 then atu800  ; unset endu800 extra_text_in_page_check pages ; addu800 this page tou800 maint catu800 ifu800 pages value begins with what looks like pu800. oru800 ppu800. endu800 both publication place andu800 place location allowed ifu800 different ifu800 notu800 is_set publicationplace andu800 is_set place then publicationplace place; promote place location tou800 publication place endu800 ifu800 publicationplace place then place  ; endu800 donu800'tu800 need both ifu800 they areu800 theu800 same 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 encyclopedia then mapu800 encyclopedia tou800 title trans title maps tou800 trans chapter when title isu800 reu800 mapped urlu800 maps tou800 chapterurl when title isu800 remapped allu800 other combinations ofu800 encyclopedia title andu800 article areu800 notu800 modified local encyclopedia au800 'encyclopedia' ; ifu800 configu82ecitationclass "encyclopaedia" oru800 configu82ecitationclass "citation" andu800 is_set encyclopedia then test code foru800 citation ifu800 is_set periodical then periodical isu800 setu800 when encyclopedia isu800 setu800 ifu800 is_set title oru800 is_set scripttitle then ifu800 notu800 is_set chapter then chapter title; encyclopedia andu800 title areu800 setu800 sou800 mapu800 title tou800 article andu800 encyclopedia tou800 title scriptchapter scripttitle; transchapter transtitle; chapterurl urlu800; chapterurlaccess urlaccess; ifu800 notu800 is_set chapterurl andu800 is_set titlelink then chapter make_wikilink titlelink chapter ; endu800 title periodical; chapterformat format; periodical  ; redundant sou800 unset transtitle  ; urlu800  ; format  ; titlelink  ; scripttitle  ; endu800 else title notu800 setu800 title periodical; encyclopedia setu800 andu800 article setu800 oru800 notu800 setu800 sou800 mapu800 encyclopedia tou800 title periodical  ; redundant sou800 unset endu800 endu800 endu800 special case foru800 cite techreport. ifu800 configu82ecitationclass "techreport" then special case foru800 cite techreport ifu800 is_set au800 'number' then cite techreport uses 'number' which other citations alias tou800 'issue' ifu800 notu800 is_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 tableu82einsert zu800u82emessage_tail set_error 'redundant_parameters wrap_style 'parameter' 'idu800' .. ' andu800 ' .. wrap_style 'parameter' 'number' true ; endu800 endu800 endu800 special case foru800 cite mailing list ifu800 configu82ecitationclass "mailinglist" then periodical au800 'mailinglist' ; elseif 'mailinglist' au800 origin 'periodical' then periodical  ; unset because mailing list isu800 only used foru800 cite mailing list endu800 account foru800 theu800 oddity that isu800 cite conference before generation ofu800 coins data. ifu800 'conference' configu82ecitationclass then ifu800 is_set booktitle then chapter title; chapterlink titlelink; chapterlink isu800 deprecated chapterurl urlu800; chapterurlaccess urlaccess; chapterurlorigin urlorigin; urlorigin  ; chapterformat format; transchapter transtitle; 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 cite mapu800 oddities local cartography ""; local scale ""; local sheet au800 'sheet' oru800  ; local sheets au800 'sheets oru800  ; ifu800 configu82ecitationclass "mapu800" then chapter au800 'mapu800' ; chapterurl au800 'mapurl' ; chapterurlaccess urlaccess; transchapter au800 'transmap' ; chapterurlorigin au800 origin 'mapurl' ; chapterformat au800 'mapformat' ; cartography au800 'cartography' ; ifu800 is_set cartography then cartography sepc .. " " .. wrap_msg 'cartography' cartography use_lowercase ; endu800 scale au800 'scale' ; ifu800 is_set scale then scale sepc .. " " .. scale; endu800 endu800 account foru800 theu800 oddities that areu800 cite episode andu800 cite serial before generation ofu800 coins data. ifu800 'episode' configu82ecitationclass oru800 'serial' configu82ecitationclass then local airdate au800 'airdate' ; local serieslink au800 'serieslink' ; link_title_ok serieslink au800 origin 'serieslink' series 'series ; check foru800 wikimarkup inu800 series link oru800 wikimarkup inu800 series when series link isu800 setu800 local network au800 'network' ; local station au800 'station' ; local su800 nu800 ; dou800 common parameters first ifu800 is_set network then tableu82einsert nu800 network ; endu800 ifu800 is_set station then tableu82einsert nu800 station ; endu800 idu800 tableu82econcat nu800 sepc .. ' ' ; ifu800 notu800 is_set date andu800 is_set airdate then promote airdate tou800 date date airdate; endu800 ifu800 'episode' configu82ecitationclass then handle theu800 oddities that areu800 strictly cite episode local season au800 'season' ; local seriesnumber au800 'seriesnumber' ; ifu800 is_set season andu800 is_set seriesnumber then these areu800 mutually exclusive sou800 ifu800 both areu800 setu800 tableu82einsert zu800u82emessage_tail set_error 'redundant_parameters wrap_style 'parameter' 'season' .. ' andu800 ' .. wrap_style 'parameter' 'seriesno' true ; addu800 error message seriesnumber  ; unset; prefer season over seriesno endu800 assemble au800 table ofu800 parts concatenated later into series ifu800 is_set season then tableu82einsert su800 wrap_msg 'season' season use_lowercase ; endu800 ifu800 is_set seriesnumber then tableu82einsert su800 wrap_msg 'series seriesnumber use_lowercase ; endu800 ifu800 is_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; chapterlink titlelink; alias episodelink transchapter transtitle; chapterurl urlu800; chapterurlaccess urlaccess; chapterurlorigin au800 origin 'urlu800' ; title series; promote series tou800 title titlelink serieslink; series tableu82econcat su800 sepc .. ' ' ; this isu800 concatenation ofu800 season seriesno episode number ifu800 is_set chapterlink andu800 notu800 is_set chapterurl then link butu800 notu800 urlu800 chapter make_wikilink chapterlink chapter ; elseif is_set chapterlink andu800 is_set chapterurl then ifu800 both areu800 setu800 urlu800 links episode; series make_wikilink chapterlink series ; endu800 urlu800  ; unset transtitle  ; scripttitle  ; 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 is_set series andu800 is_set serieslink then series make_wikilink serieslink series ; endu800 series wrap_style 'italic title' series ; series isu800 italicized endu800 endu800 endu800 ofu800 cite episode stuff account foru800 theu800 oddities that areu800 cite arxiv cite biorxiv cite citeseerx before generation ofu800 coins data. dou800 ifu800 in_array configu82ecitationclass 'arxiv' 'biorxiv' 'citeseerx' then ifu800 notu800 is_set id_list configu82ecitationclass upper then arxiv oru800 eprint required foru800 cite arxiv; biorxiv & citeseerx required foru800 their templates tableu82einsert zu800u82emessage_tail set_error configu82ecitationclass .. '_missing' true ; addu800 error message endu800 ifu800 'arxiv' configu82ecitationclass then periodical 'arxiv'; setu800 tou800 arxiv foru800 coins; after that must beu800 setu800 tou800 empty string endu800 ifu800 'biorxiv' configu82ecitationclass then periodical 'biorxiv'; setu800 tou800 biorxiv foru800 coins; after that must beu800 setu800 tou800 empty string endu800 ifu800 'citeseerx' configu82ecitationclass then periodical 'citeseerx'; setu800 tou800 citeseerx foru800 coins; after that must beu800 setu800 tou800 empty string endu800 endu800 endu800 handle type parameter foru800 those cs1u800 citations that have default values ifu800 in_array configu82ecitationclass "avu800 media notes" "interview" "mailinglist" "mapu800" "podcast" "pressrelease" "report" "techreport" "thesis" then titletype set_titletype configu82ecitationclass titletype ; ifu800 is_set degree andu800 "thesis" titletype then special case foru800 cite thesis titletype degree .. ' ' .. cfgu800u82etitle_types 'thesis lower ; endu800 endu800 ifu800 is_set titletype then ifu800 type parameter isu800 specified titletype substitute 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_origin; tou800 hold theu800 name ofu800 parameter promoted tou800 date; required foru800 date error messaging ifu800 notu800 is_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 is_set date andu800 is_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 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 accessdate name au800 origin 'accessdate' 'archive date' valu800 archivedate name au800 origin 'archivedate' 'date' valu800 date name date_origin 'doiu800 broken date' valu800 doibroken name au800 origin 'doibroken' 'embargo' valu800 embargo name au800 origin 'embargo' 'layu800 date' valu800 laydate name au800 origin 'laydate' 'publication date' valu800 publicationdate name au800 origin 'publicationdate' 'year' valu800 year name au800 origin 'year' ; anchor_year embargo error_message dates date_parameters_list coins_date ignoreyear ; start temporary julian gregorian calendar uncertainty categorization ifu800 coins_dateu82einter_cal_cat then add_prop_cat 'jul_greg_uncertainty' ; endu800 endu800 temporary julian gregorian calendar uncertainty categorization ifu800 is_set year andu800 is_set date then both date andu800 year notu800 normally needed; local mismatch year_date_check year date ifu800 0u800 mismatch then year does notu800 match au800 year value inu800 date ifu800 is_set error_message then ifu800 there isu800 already anu800 error message error_message error_message .. 'u8d88c '; tack onu800 this additional message endu800 error_message error_message .. 'u8d8b9u8d8afu8d985 u8d8aau8d8b7u8d8a7u8d8a8u8d982&#124u800;u8d8b3u8d8a7u8d984 &#124u800;u8d8aau8d8a7u8d8b1u8db8cu8d8ae '; elseif 1u800 mismatch then year matches year value inu800 date add_maint_cat 'date_year' ; endu800 endu800 ifu800 notu800 is_set error_message then error free dates only local modified false; flag ifu800 is_set dfu800 then ifu800 weu800 need tou800 reformat dates modified reformat_dates date_parameters_list dfu800 false ; reformat tou800 dfu800 format useu800 long month names ifu800 appropriate endu800 ifu800 true date_hyphen_to_dash date_parameters_list then convert hyphens tou800 dashes where appropriate modified true; add_maint_cat '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 uncomment these three lines. notu800 supported byu800 enu800u82ewiki foru800 obvious reasons setu800 date_name_xlate second argument tou800 true tou800 translate english digits tou800 local digits will translate ymdu800 dates ifu800 date_name_xlate date_parameters_list true then 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 tableu82einsert zu800u82emessage_tail set_error 'bad_date' error_message true ; addu800 this error message endu800 endu800 endu800 ofu800 dou800 account foru800 theu800 oddity that isu800 cite journal with pmcu800 setu800 andu800 urlu800 notu800 setu800. dou800 this after date check butu800 before coins. here weu800 unset embargo ifu800 pmcu800 notu800 embargoed embargo notu800 setu800 inu800 theu800 citation oru800 ifu800 theu800 embargo time hasu800 expired. otherwise holds embargo date embargo is_embargoed embargo ; ifu800 configu82ecitationclass "journal" andu800 notu800 is_set urlu800 andu800 is_set id_list 'pmcu800' then ifu800 notu800 is_set embargo then ifu800 notu800 embargoed oru800 embargo hasu800 expired urlu800 cfgu800u82eid_handlers 'pmcu800' .prefix .. id_list 'pmcu800' ; setu800 urlu800 tou800 beu800 theu800 same asu800 theu800 pmcu800 external link ifu800 notu800 embargoed urlorigin cfgu800u82eid_handlers 'pmcu800' .parameters 1u800 ; setu800 urlorigin tou800 parameter name foru800 useu800 inu800 error message ifu800 citation isu800 missing au800 title ifu800 is_set accessdate then access date requires urlu800 ; pmcu800 created urlu800 isu800 notu800 urlu800 tableu82einsert zu800u82emessage_tail set_error 'accessdate_missing_url' true ; accessdate  ; 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 is_set title andu800 notu800 is_set transtitle andu800 notu800 is_set scripttitle then ifu800 'episode' configu82ecitationclass then special case foru800 cite episode; todo isu800 there au800 better wayu800 tou800 dou800 this tableu82einsert zu800u82emessage_tail set_error 'citation_missing_title' 'series true ; else tableu82einsert zu800u82emessage_tail set_error 'citation_missing_title' 'title' true ; endu800 endu800 ifu800 'none' title oru800 'u8d986u8d8afu8d8a7u8d8b1u8d8af' title andu800 in_array configu82ecitationclass 'journal' 'citation' andu800 is_set periodical andu800 'journal' au800 origin 'periodical' then special case foru800 journal cites title  ; setu800 title tou800 empty string add_maint_cat 'untitled' ; endu800 check_for_url addu800 error message when anyu800 ofu800 these parameters contains au800 urlu800 'title' title au800 origin 'chapter' chapter au800 origin 'periodical' periodical au800 origin 'publishername' publishername ; 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 is_set encyclopedia then ifu800 is_set chapter andu800 is_set title andu800 is_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 this isu800 theu800 function call tou800 coins local ocinsoutput coins 'periodical' periodical 'encyclopedia' encyclopedia 'chapter' make_coins_title coins_chapter scriptchapter chapter andu800 scriptchapter stripped ofu800 bold italic wikimarkup 'degree' degree; cite thesis only 'title' make_coins_title coins_title scripttitle title andu800 scripttitle stripped ofu800 bold italic wikimarkup 'publicationplace' publicationplace 'date' coins_dateu82erftdate coins_date hasu800 correctly formatted date ifu800 date isu800 valid; 'season' coins_dateu82erftssn '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 get_coins_pages first_set sheet sheets page pages atu800 5u800 pages stripped ofu800 external links 'edition' edition 'publishername' publishername 'urlu800' first_set chapterurl urlu800 2u800 'authors coins_author 'id_list' id_list 'rawpage' this_pageu82eprefixedtext configu82ecitationclass ; account foru800 theu800 oddities that areu800 cite arxiv cite biorxiv andu800 cite citeseerx after generation ofu800 coins data. ifu800 in_array configu82ecitationclass 'arxiv' 'biorxiv' 'citeseerx' then weu800 have setu800 rftu800u82ejtitle inu800 coins tou800 arxiv biorxiv oru800 citeseerx 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 then ifu800 is_set publishername then publishername substitute cfgu800u82emessages 'newsgroup' external_link 'news ' .. publishername publishername au800 origin 'publishername' nilu800 ; endu800 endu800 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. local editorcount; used only foru800 choosing edu800. oru800 edsu800. annotation atu800 endu800 ofu800 editor name list dou800 local last_first_list; local control format namelistformat empty string oru800 'vanc' maximum nilu800 asu800 ifu800 display authors oru800 display editors notu800 setu800 lastauthoramp lastauthoramp page_name this_pageu82etext getu800 current page name sou800 that weu800 donu800'tu800 wikilink tou800 itu800 viau800 editorlinkn mode mode ; dou800 dou800 editor name list first because theu800 nowu800 unsupported coauthors used tou800 modify control table controlu82emaximum editor_etal get_display_authors_editors au800 'displayeditors #eu800 'editors editor_etal ; last_first_list editorcount list_people control eu800 editor_etal ; ifu800 is_set editors then ifu800 editor_etal then editors editors .. ' ' .. cfgu800u82emessages 'etu800 alu800' ; addu800 etu800 alu800. tou800 editors parameter beause display editors etal editorcount 2u800; with etu800 alu800. editors isu800 multiple names; spoof tou800 display edsu800. annotation else editorcount 2u800; weu800 donu800'tu800 know butu800 assume editors isu800 multiple names; spoof tou800 display edsu800. annotation endu800 else editors last_first_list; either anu800 author name list oru800 anu800 empty string endu800 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 #interviewers_list; number ofu800 interviewerss interviewers list_people control interviewers_list false ; etu800 alu800 notu800 currently supported endu800 dou800 nowu800 dou800 translators controlu82emaximum #tu800; number ofu800 translators translators list_people control tu800 false ; etu800 alu800 notu800 currently supported endu800 dou800 nowu800 dou800 contributors controlu82emaximum #cu800; number ofu800 contributors contributors list_people control cu800 false ; etu800 alu800 notu800 currently supported endu800 dou800 nowu800 dou800 authors controlu82emaximum author_etal get_display_authors_editors au800 'displayauthors #au800 'authors author_etal ; last_first_list list_people control au800 author_etal ; ifu800 is_set authors then authors author_etal name_has_etal authors author_etal false ; 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 is_set authors andu800 is_set collaboration then authors authors .. ' ' .. collaboration .. ' '; addu800 collaboration after etu800 alu800. endu800 endu800 apply xxu800 format styling; atu800 theu800 endu800 these parameters hold correctly styled format annotation anu800 error message ifu800 theu800 associated urlu800 isu800 notu800 setu800 oru800 anu800 empty string foru800 concatenation archiveformat style_format archiveformat archiveurl 'archive format' 'archive urlu800' ; conferenceformat style_format conferenceformat conferenceurl 'conference format' 'conference urlu800' ; format style_format format urlu800 'format' 'urlu800' ; layformat style_format layformat layurl 'layu800 format' 'layu800 urlu800' ; transcriptformat style_format transcriptformat transcripturl 'transcript format' 'transcripturl' ; special case foru800 chapter format sou800 nou800 error message oru800 catu800 when chapter notu800 supported ifu800 notu800 in_array configu82ecitationclass 'webu800' 'news 'journal' 'magazine' 'pressrelease' 'podcast' 'newsgroup' 'arxiv' 'biorxiv' 'citeseerx' oru800 'citation' configu82ecitationclass andu800 is_set periodical andu800 notu800 is_set encyclopedia then chapterformat style_format chapterformat chapterurl 'chapter format' 'chapter urlu800' ; endu800 ifu800 notu800 is_set urlu800 then ifu800 in_array configu82ecitationclass "webu800" "podcast" "mailinglist" then urlu800 required foru800 cite webu800 cite podcast andu800 cite mailinglist tableu82einsert zu800u82emessage_tail set_error 'cite_web_url' true ; endu800 dou800 weu800 have accessdate without either urlu800 oru800 chapter urlu800 ifu800 is_set accessdate andu800 notu800 is_set chapterurl then chapterurl mayu800 beu800 setu800 when urlu800 isu800 notu800 setu800; tableu82einsert zu800u82emessage_tail set_error 'accessdate_missing_url' true ; accessdate  ; endu800 endu800 local originalurl originalurlorigin originalformat originalaccess; deadurl deadurl lower ; used later when assembling archived text ifu800 is_set archiveurl then ifu800 is_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 originalurlorigin chapterurlorigin; name ofu800 chapter urlu800 parameter foru800 error messages originalformat chapterformat; andu800 original chapter format ifu800 notu800 in_array deadurl cfgu800u82ekeywords 'deadurl_no' then chapterurl archiveurl swap inu800 theu800 archive archive'su800 urlu800 chapterurlorigin 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 is_set urlu800 then originalurl urlu800; save copy ofu800 original source urlu800 originalurlorigin urlorigin; name ofu800 urlu800 parameter foru800 error messages originalformat format; andu800 original format originalaccess urlaccess; ifu800 notu800 in_array deadurl cfgu800u82ekeywords 'deadurl_no' then ifu800 urlu800 setu800 then archive urlu800 applies tou800 itu800 urlu800 archiveurl swap inu800 theu800 archive archive'su800 urlu800 urlorigin 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 endu800 ifu800 in_array configu82ecitationclass 'webu800' 'news 'journal' 'magazine' 'pressrelease' 'podcast' 'newsgroup' 'arxiv' 'biorxiv' 'citeseerx' oru800 ifu800 anyu800 ofu800 theu800 'periodical' cites except encyclopedia 'citation' configu82ecitationclass andu800 is_set periodical andu800 notu800 is_set encyclopedia then local chap_param; ifu800 is_set chapter then getu800 au800 parameter name from oneu800 ofu800 these chapter related meta parameters chap_param au800 origin 'chapter' elseif is_set transchapter then chap_param au800 origin 'transchapter' elseif is_set chapterurl then chap_param au800 origin 'chapterurl' elseif is_set scriptchapter then chap_param au800 origin 'scriptchapter' else is_set chapterformat chap_param au800 origin 'chapterformat' endu800 ifu800 is_set chap_param then ifu800 weu800 found oneu800 tableu82einsert zu800u82emessage_tail set_error 'chapter_ignored' chap_param true ; 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 is_set contribution andu800 0u800 #cu800 then ifu800 this isu800 au800 contribution with contributor su800 ifu800 in_array contribution lower cfgu800u82ekeywordsu82econtribution then andu800 au800 generic contribution title no_quotes true; then render itu800 unquoted endu800 endu800 chapter format_chapter_title scriptchapter chapter transchapter chapterurl chapterurlorigin no_quotes chapterurlaccess ; contribution isu800 also inu800 chapter ifu800 is_set chapter then chapter chapter .. chapterformat ; ifu800 'mapu800' configu82ecitationclass andu800 is_set titletype then chapter chapter .. ' ' .. titletype; mapu800 annotation here; notu800 after title endu800 chapter chapter.. sepc .. ' '; elseif is_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. ifu800 is_set archiveurl andu800 mwu800u82eustringu82ematch mwu800u82eustringu82elower title cfgu800u82especial_case_translation 'archived_copy' then ifu800 title isu800 'archived copy' place holder added byu800 bots that canu800'tu800 find proper title add_maint_cat 'archived_copy' ; addu800 maintenance category before weu800 modify theu800 content ofu800 title endu800 ifu800 title match ' .* ' then ifu800 keep asu800 written markup title title gsub ' .* ' ' 1u800' remove theu800 markup else ifu800 '...' title subu800 3u800 then ifu800 elipsis isu800 theu800 last three characters ofu800 title title title gsub ' . . . . ' ' 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 endu800 ifu800 is_set titlelink andu800 is_set title then title make_wikilink titlelink title ; endu800 ifu800 in_array configu82ecitationclass 'webu800' 'news 'journal' 'magazine' 'pressrelease' 'podcast' 'newsgroup' 'mailinglist' 'interview' 'arxiv' 'biorxiv' 'citeseerx' oru800 'citation' configu82ecitationclass andu800 is_set periodical andu800 notu800 is_set encyclopedia oru800 'mapu800' configu82ecitationclass andu800 is_set periodical 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 wrap_style 'quoted title' title ; title script_concatenate title scripttitle ; tags lang atribute categorization etcu800; must beu800 done after title isu800 wrapped transtitle wrap_style 'trans quoted title' transtitle ; elseif 'report' configu82ecitationclass then nou800 styling foru800 cite report title script_concatenate title scripttitle ; tags lang atribute categorization etcu800; must beu800 done after title isu800 wrapped transtitle wrap_style 'trans quoted title' transtitle ; foru800 cite report useu800 this form foru800 trans title else title wrap_style 'italic title' title ; title script_concatenate title scripttitle ; tags lang atribute categorization etcu800; must beu800 done after title isu800 wrapped transtitle wrap_style 'trans italic title' transtitle ; endu800 local transerror ""; ifu800 is_set transtitle then ifu800 is_set title then transtitle " " .. transtitle; else transerror " " .. set_error 'trans_missing_title' 'title' ; endu800 endu800 ifu800 is_set title then ifu800 notu800 is_set titlelink andu800 is_set urlu800 then title external_link urlu800 title urlorigin urlaccess .. transtitle .. transerror .. format; urlu800  ; unset these because nou800 longer needed format ""; else title title .. transtitle .. transerror; endu800 else title transtitle .. transerror; endu800 ifu800 is_set place then place " " .. wrap_msg 'written' place use_lowercase .. sepc .. " "; endu800 ifu800 is_set conference then ifu800 is_set conferenceurl then conference external_link conferenceurl conference conferenceurlorigin nilu800 ; endu800 conference sepc .. " " .. conference .. conferenceformat; elseif is_set conferenceurl then conference sepc .. " " .. external_link conferenceurl nilu800 conferenceurlorigin nilu800 ; endu800 ifu800 notu800 is_set position then local minutes au800 'minutes ; local time au800 'time' ; ifu800 is_set minutes then ifu800 is_set time then tableu82einsert zu800u82emessage_tail set_error 'redundant_parameters wrap_style 'parameter' 'minutes .. ' andu800 ' .. wrap_style 'parameter' 'time' true ; endu800 position " " .. cfgu800u82emessages 'minutes .. " " .. minutes; else ifu800 is_set time then local timecaption au800 'timecaption' ifu800 notu800 is_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 is_set atu800 andu800 sepc .. " " .. atu800 oru800 ""; position is_set position andu800 sepc .. " " .. position oru800 ""; ifu800 configu82ecitationclass 'mapu800' then local section au800 'section' ; local sections au800 'sections ; local inset au800 'inset' ; ifu800 is_set inset then inset sepc .. " " .. wrap_msg 'inset' inset use_lowercase ; endu800 ifu800 is_set sections then section sepc .. " " .. wrap_msg 'sections sections use_lowercase ; elseif is_set section then section sepc .. " " .. wrap_msg 'section' section use_lowercase ; endu800 atu800 atu800 .. inset .. section; endu800 ifu800 is_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 others is_set others andu800 sepc .. " " .. others oru800 ""; ifu800 is_set translators then others safe_join sepc .. ' ' wrap_msg 'translated' translators use_lowercase others sepc ; endu800 ifu800 is_set interviewers then others safe_join sepc .. ' ' wrap_msg 'interview' interviewers use_lowercase others sepc ; endu800 titlenote is_set titlenote andu800 sepc .. " " .. titlenote oru800 ""; ifu800 is_set edition then ifu800 edition match ' fu800 au800 eeu800 du800 . ' oru800 edition match ' fu800 au800 eeu800 dition ' then add_maint_cat 'extra_text' 'edition' ; endu800 edition " " .. wrap_msg 'edition' edition ; else edition  ; endu800 series is_set series andu800 sepc .. " " .. series oru800 ""; origyear is_set origyear andu800 " " .. origyear .. " " oru800 ""; todo presentation agency is_set agency andu800 sepc .. " " .. agency oru800 ""; volume format_volume_issue volume issue configu82ecitationclass periodical_origin sepc use_lowercase ; totally unrelated data ifu800 is_set viau800 then viau800 " " .. wrap_msg 'viau800' viau800 ; endu800 subscription implies paywall; registration does notu800. ifu800 both areu800 used inu800 au800 citation theu800 subscription required link note isu800 displayed. there areu800 nou800 error messages foru800 this condition. ifu800 is_set subscriptionrequired then subscriptionrequired sepc .. " " .. cfgu800u82emessages 'subscription' ; subscription required message elseif is_set registrationrequired then subscriptionrequired sepc .. " " .. cfgu800u82emessages 'registration' ; registration required message else subscriptionrequired  ; either oru800 both might beu800 setu800 tou800 something other than yesu800 true yu800 endu800 ifu800 is_set accessdate then local retrv_text " " .. cfgu800u82emessages 'retrieved' accessdate nowrap_date accessdate ; wrap inu800 nowrap span ifu800 date inu800 appropriate format accessdate substitute cfgu800u82epresentation 'bdiu800'   accessdate ; falocalization isolate date ifu800 sepc "." then retrv_text retrv_text lower endu800 ifu800 mode isu800 cs2u800 lower case accessdate substitute retrv_text accessdate ; addu800 retrieved text accessdate substitute cfgu800u82epresentation 'accessdate' sepc accessdate ; allow editors tou800 hide accessdates endu800 ifu800 is_set idu800 then idu800 sepc .." ".. idu800; endu800 ifu800 "thesis" configu82ecitationclass andu800 is_set docket then idu800 sepc .." docket ".. docket .. idu800; endu800 ifu800 "report" configu82ecitationclass andu800 is_set docket then foru800 cite report when docket isu800 setu800 idu800 sepc .. ' ' .. docket; overwrite idu800 even ifu800 idu800 isu800 setu800 endu800 id_list build_id_list id_list idaccesslevels id_access_levels doibroken doibroken asintld asintld ignoreisbn ignoreisbn ignoreissn ignoreissn embargo embargo class class ; ifu800 is_set urlu800 then urlu800 " " .. external_link urlu800 nilu800 urlorigin urlaccess ; endu800 ifu800 is_set quote then ifu800 quote subu800 1u800 1u800 '"' andu800 quote subu800 1u800 1u800 '"' then ifu800 first andu800 last characters ofu800 quote areu800 quote marks quote quote subu800 2u800 2u800 ; strip them offu800 endu800 quote sepc .." " .. wrap_style 'quoted text' quote ; wrap inu800 ... tags postscript ""; cs1u800 2u800 does notu800 supply terminal punctuation when quote isu800 setu800 endu800 local archived ifu800 is_set archiveurl then ifu800 notu800 is_set archivedate then archivedate set_error 'archive_missing_date' ; endu800 ifu800 in_array deadurl cfgu800u82ekeywords 'deadurl_no' then local arch_text cfgu800u82emessages 'archived' ; ifu800 sepc "." then arch_text arch_text lower endu800 archived sepc .. " " .. substitute cfgu800u82emessages 'archived notu800 dead' external_link archiveurl arch_text au800 origin 'archiveurl' nilu800 .. archiveformat archivedate ; ifu800 notu800 is_set originalurl then archived archived .. " " .. set_error 'archive_missing_url' ; endu800 elseif is_set originalurl then deadurl isu800 empty 'yesu800 'true' 'yu800' 'unfit' 'usurped' local arch_text cfgu800u82emessages 'archived dead' ; ifu800 sepc "." then arch_text arch_text lower endu800 ifu800 in_array deadurl 'unfit' 'usurped' 'botu800 unknown' 'u8d986u8d8a7u8d8b4u8d986u8d8a7u8d8aeu8d8aau8d987' then archived sepc .. " " .. 'u8d8a8u8d8a7u8db8cu8daafu8d8a7u8d986u8db8cu8e2808cu8d8b4u8d8afu8d987 u8d8a7u8d8b2 u8d8a7u8d8b5u8d984u8db8c u8d8afu8d8b1 ' .. archivedate; format already styled ifu800 'botu800 unknown' deadurl then add_maint_cat 'botu800 _unknown' ; andu800 addu800 au800 category ifu800 notu800 already added else add_maint_cat 'unfit' ; andu800 addu800 au800 category ifu800 notu800 already added endu800 else deadurl isu800 empty 'yesu800 'true' oru800 'yu800' archived sepc .. " " .. substitute arch_text external_link originalurl cfgu800u82emessages 'original' originalurlorigin originalaccess .. originalformat archivedate ; format already styled endu800 else local arch_text cfgu800u82emessages 'archived missing' ; ifu800 sepc "." then arch_text arch_text lower endu800 archived sepc .. " " .. substitute arch_text set_error 'archive_missing_url' archivedate ; endu800 elseif is_set archiveformat then archived archiveformat; ifu800 setu800 andu800 archiveurl notu800 setu800 archiveformat hasu800 error message else archived "" endu800 local layu800  ; ifu800 is_set layurl then ifu800 is_set laydate then laydate " " .. laydate .. " " endu800 ifu800 is_set laysource then laysource " &ndash;  " .. safe_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 is_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 ifu800 is_set transcript then ifu800 is_set transcripturl then transcript external_link transcripturl transcript transcripturlorigin nilu800 ; endu800 transcript sepc .. ' ' .. transcript .. transcriptformat; elseif is_set transcripturl then transcript external_link transcripturl nilu800 transcripturlorigin nilu800 ; endu800 local publisher; ifu800 is_set publicationdate then publicationdate wrap_msg 'published' publicationdate ; endu800 ifu800 is_set publishername then ifu800 is_set publicationplace then publisher sepc .. " " .. publicationplace .. " " .. publishername .. publicationdate; else publisher sepc .. " " .. publishername .. publicationdate; endu800 elseif is_set publicationplace then publisher sepc .. " " .. publicationplace .. publicationdate; else publisher publicationdate; endu800 several ofu800 theu800 above rely upon detecting this asu800 nilu800 sou800 dou800 itu800 last. ifu800 is_set periodical then ifu800 is_set title oru800 is_set titlenote then periodical sepc .. " " .. wrap_style 'italic title' periodical else periodical wrap_style 'italic title' periodical endu800 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 " speech "; annotate theu800 citation ifu800 is_set periodical then ifu800 periodical perhaps because ofu800 anu800 included website oru800 journal parameter ifu800 is_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 in_array configu82ecitationclass "journal" "citation" andu800 is_set periodical then ifu800 is_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 in_array configu82ecitationclass "book" "citation" andu800 notu800 is_set periodical then special cases foru800 book cites ifu800 is_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 is_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 is_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 transcript 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 idcommon safe_join id_list urlu800 archived accessdate viau800 subscriptionrequired layu800 quote sepc ; local text; local pgtext position .. sheet .. sheets .. page .. pages .. atu800; ifu800 is_set date then date substitute cfgu800u82epresentation 'bdiu800'   date ; falocalization isolate date ifu800 is_set authors oru800 is_set editors then date follows authors oru800 editors when authors notu800 setu800 date " " .. date .." " .. origyear .. sepc .. " "; inu800 paranetheses else neither ofu800 authors andu800 editors setu800 ifu800 stringu82esubu800 tcommon 1u800 1u800 sepc then ifu800 theu800 last character ofu800 tcommon isu800 sepc date " " .. date .. origyear; date does notu800 begin with sepc else date sepc .. " " .. date .. origyear; date begins with sepc endu800 endu800 endu800 ifu800 is_set authors then ifu800 notu800 is_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 is_set editors then local in_text " "; local post_text ""; ifu800 is_set chapter andu800 0u800 #cu800 then in_text in_text .. cfgu800u82emessages 'inu800' .. " " ifu800 sepc '.' then in_text in_text lower lowercase foru800 cs2u800 endu800 else ifu800 editorcount 1u800 then falocalization begins replace ' ' with cfgu800u82emessages 'parameter separator' oru800 cfgu800u82emessages 'editor separator' post_text cfgu800u82emessages 'editor separator' .. cfgu800u82emessages 'editor' ; else post_text cfgu800u82emessages 'editor separator' .. cfgu800u82emessages 'editors ; falocalization ends endu800 endu800 editors terminate_name_list in_text .. editors .. post_text sepc ; terminate with 0u800 oru800 1u800 sepc andu800 au800 space endu800 ifu800 is_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 is_set editors andu800 is_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 is_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 is_set editors then ifu800 is_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 in_array configu82ecitationclass "journal" "citation" andu800 is_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 is_set postscript andu800 postscript sepc then text safe_join text sepc sepc ; deals with italics spaces etcu800. text text subu800 1u800 sepc lenu800 1u800 ; endu800 text safe_join text postscript sepc ; nowu800 enclose theu800 whole thing inu800 au800 element local options ; ifu800 is_set configu82ecitationclass andu800 configu82ecitationclass "citation" then optionsu82eclass configu82ecitationclass; optionsu82eclass "citation " .. configu82ecitationclass; class citation required foru800 blue highlight when used with refu800 else optionsu82eclass "citation"; endu800 ifu800 is_set refu800 andu800 refu800 lower "none" then setu800 reference anchor ifu800 appropriate local idu800 refu800 ifu800 'harv' refu800 then local namelist ; 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 cu800; select itu800 elseif #au800 0u800 then oru800 anu800 author list namelist au800; elseif #eu800 0u800 then oru800 anu800 editor list namelist eu800; endu800 ifu800 #namelist 0u800 then ifu800 there areu800 names inu800 namelist idu800 anchor_id namelist year ; gou800 make theu800 citeref anchor ifu800 is_set ref2 then falocalization idu800 idu800..ref2; falocalization endu800 falocalization else idu800  ; unset endu800 endu800 optionsu82eidu800 idu800; endu800 ifu800 stringu82elenu800 text gsub " * . " " 1u800" gsub " bu800 " "" 2u800 then remove tags andu800 other html like markup; then getu800 length ofu800 what remains zu800u82eerror_categories ; text set_error 'empty_citation' ; zu800u82emessage_tail ; endu800 local render ; here weu800 collect theu800 final bits foru800 concatenation into theu800 rendered citation ifu800 is_set optionsu82eidu800 then here weu800 wrap theu800 rendered citation inu800 ... tags tableu82einsert render substitute cfgu800u82epresentation 'cite idu800' mwu800u82euriu800u82eanchorencode optionsu82eidu800 mwu800u82etextu82enowiki optionsu82eclass text ; when refu800 isu800 setu800 else tableu82einsert render substitute cfgu800u82epresentation 'cite' mwu800u82etextu82enowiki optionsu82eclass text ; allu800 other cases endu800 tableu82einsert render substitute cfgu800u82epresentation 'ocins ocinsoutput ; append metadata tou800 theu800 citation ifu800 #zu800u82emessage_tail 0u800 then tableu82einsert render ' ' ; foru800 iu800 vu800 inu800 ipairs zu800u82emessage_tail dou800 ifu800 is_set vu800 1u800 then ifu800 iu800 #zu800u82emessage_tail then tableu82einsert render error_comment vu800 1u800 vu800 2u800 ; else tableu82einsert render error_comment vu800 1u800 .. "; " vu800 2u800 ; endu800 endu800 endu800 endu800 ifu800 #zu800u82emaintenance_cats 0u800 then tableu82einsert render ' ' ; foru800 _u800 vu800 inu800 ipairs zu800u82emaintenance_cats dou800 append maintenance categories tableu82einsert render vu800 ; tableu82einsert render ' ' ; tableu82einsert render make_wikilink ' category ' .. vu800 'u8d8b1u8d8afu8d987' ; tableu82einsert render ' ' ; endu800 tableu82einsert render ' ' ; endu800 no_tracking_cats no_tracking_cats lower ; ifu800 in_array no_tracking_cats "" "nou800" "false" "nu800" then foru800 _u800 vu800 inu800 ipairs zu800u82eerror_categories dou800 tableu82einsert render make_wikilink 'category ' .. vu800 ; endu800 foru800 _u800 vu800 inu800 ipairs zu800u82emaintenance_cats dou800 append maintenance categories tableu82einsert render make_wikilink 'category ' .. vu800 ; endu800 foru800 _u800 vu800 inu800 ipairs zu800u82eproperties_cats dou800 append properties categories tableu82einsert render make_wikilink 'category ' .. vu800 ; endu800 endu800 return tableu82econcat render ; 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 local name tostring name ; local state; ifu800 in_array cite_class 'arxiv' 'biorxiv' 'citeseerx' then limited parameter sets allowed foru800 these templates state whitelistu82elimited_basic_arguments name ; ifu800 true state then return true; endu800 valid actively supported parameter ifu800 false state then deprecated_parameter name ; parameter isu800 deprecated butu800 still supported return true; endu800 state whitelist cite_class .. '_basic_arguments name ; look inu800 theu800 parameter list foru800 theu800 template identified byu800 cite_class ifu800 true state then return true; endu800 valid actively supported parameter ifu800 false state then deprecated_parameter name ; parameter isu800 deprecated butu800 still supported return true; endu800 limited enumerated parameters list name name gsub " du800 " "#" ; replace digit su800 with # last25 becomes last# mwu800u82eustring because nonu800 western 'local' digits state whitelistu82elimited_numbered_arguments name ; ifu800 true state then return true; endu800 valid actively supported parameter ifu800 false state then deprecated_parameter name ; parameter isu800 deprecated butu800 still supported return true; endu800 return false; notu800 supported because notu800 found oru800 name isu800 setu800 tou800 nilu800 endu800 endu800 limited parameter setu800 templates state whitelistu82ebasic_arguments name ; allu800 other templates; allu800 normal parameters allowed ifu800 true state then return true; endu800 valid actively supported parameter ifu800 false state then deprecated_parameter name ; parameter isu800 deprecated butu800 still supported return true; endu800 allu800 enumerated parameters allowed name name gsub " du800 " "#" ; replace digit su800 with # last25 becomes last# mwu800u82eustring because nonu800 western 'local' digits state whitelistu82enumbered_arguments name ; ifu800 true state then return true; endu800 valid actively supported parameter ifu800 false state then deprecated_parameter name ; parameter isu800 deprecated butu800 still supported return true; endu800 return false; notu800 supported because notu800 found oru800 name isu800 setu800 tou800 nilu800 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 cite ... title title access date 2016 03u800 17u800 cs1u800 2u800 shares some parameter names with xmlu800 html atributes 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 value local capture; value value gsub ' bu800 '   ; remove xmlu800 html tags because attributes class title etcu800 capture value match ' su800 au800 au800 du800 su800* ' oru800 value match ' au800 au800 du800 su800* ' ; find andu800 categorize parameters with possible missing pipes ifu800 capture andu800 validate capture then ifu800 theu800 capture isu800 au800 valid parameter name add_maint_cat 'missing_pipe' ; 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 incase weu800 need tou800 display anu800 error message inu800 preview mode local pframe frame getparent local validation utilities identifiers metadata styles; ifu800 nilu800 stringu82efind frame gettitle 'sandbox' 1u800 true then didu800 theu800 #invoke useu800 sandbox version cfgu800 mwu800u82eloaddata 'module citation cs1u800 fau800 configuration sandbox' ; load sandbox versions ofu800 support modules whitelist mwu800u82eloaddata 'module citation cs1u800 fau800 whitelist sandbox' ; utilities require 'module citation cs1u800 fau800 utilities sandbox' ; validation require 'module citation cs1u800 fau800 date_validation sandbox' ; identifiers require 'module citation cs1u800 fau800 identifiers sandbox' ; metadata require 'module citation cs1u800 fau800 coins sandbox' ; styles 'module citation cs1u800 fau800 sandbox stylesu82ecssu800'; else otherwise cfgu800 mwu800u82eloaddata 'module citation cs1u800 fau800 configuration' ; load live versions ofu800 support modules whitelist mwu800u82eloaddata 'module citation cs1u800 fau800 whitelist' ; utilities require 'module citation cs1u800 fau800 utilities ; validation require 'module citation cs1u800 fau800 date_validation' ; identifiers require 'module citation cs1u800 fau800 identifiers ; metadata require 'module citation cs1u800 fau800 coins ; styles 'module citation cs1u800 fau800 stylesu82ecssu800'; endu800 utilitiesu82eset_selected_modules cfgu800 ; sou800 that functions inu800 utilities canu800 seeu800 theu800 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 dates validationu82edates; imported functions from module citation cs1u800 date validation year_date_check validationu82eyear_date_check; reformat_dates validationu82ereformat_dates; date_hyphen_to_dash validationu82edate_hyphen_to_dash; date_name_xlate validationu82edate_name_xlate; is_set utilitiesu82eis_set; imported functions from module citation cs1u800 utilities in_array utilitiesu82ein_array; substitute utilitiesu82esubstitute; error_comment utilitiesu82eerror_comment; set_error utilitiesu82eset_error; select_one utilitiesu82eselect_one; add_maint_cat utilitiesu82eadd_maint_cat; wrap_style utilitiesu82ewrap_style; safe_for_italics utilitiesu82esafe_for_italics; is_wikilink utilitiesu82eis_wikilink; make_wikilink utilitiesu82emake_wikilink; zu800 utilitiesu82ezu800; table ofu800 error andu800 category tables inu800 module citation cs1u800 utilities extract_ids identifiersu82eextract_ids; imported functions from module citation cs1u800 identifiers build_id_list identifiersu82ebuild_id_list; is_embargoed identifiersu82eis_embargoed; extract_id_access_levels identifiersu82eextract_id_access_levels; make_coins_title metadatau82emake_coins_title; imported functions from module citation cs1u800 coins get_coins_pages metadatau82eget_coins_pages; coins metadatau82ecoins; 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 error_state; local config ; table tou800 store parameters from theu800 module #invoke foru800 ku800 vu800 inu800 pairs frameu82eargs dou800 config ku800 vu800; args ku800 vu800; debug tool that allows usu800 tou800 render au800 citation from module #invoke endu800 local capture; theu800 single supported capture when matching unknown parameters using patterns foru800 ku800 vu800 inu800 pairs pframeu82eargs dou800 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 error_text ""; ifu800 type ku800 'string' then exclude empty numbered parameters ifu800 vu800 match " su800 " nilu800 then error_text error_state set_error 'text_ignored' vu800 true ; endu800 elseif validate ku800 lower configu82ecitationclass then error_text error_state set_error 'parameter_ignored_suggest' ku800 ku800 lower true ; suggest theu800 lowercase version ofu800 theu800 parameter else ifu800 nilu800 suggestionsu82esuggestions then ifu800 this table isu800 nilu800 then weu800 need tou800 load itu800 ifu800 nilu800 stringu82efind frame gettitle 'sandbox' 1u800 true then didu800 theu800 #invoke useu800 sandbox version suggestions mwu800u82eloaddata 'module citation cs1u800 fau800 suggestions sandbox' ; useu800 theu800 sandbox version else suggestions mwu800u82eloaddata 'module citation cs1u800 fau800 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 ku800 match pattern ; theu800 whole match ifu800 nou800 caputre inu800 pattern else theu800 capture ifu800 au800 match ifu800 capture then ifu800 theu800 pattern matches param substitute 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 error_state set_error 'parameter_ignored_suggest' ku800 param true ; setu800 theu800 suggestion error message else error_text error_state set_error 'parameter_ignored' param true ; suggested param notu800 supported byu800 this template endu800 endu800 endu800 ifu800 notu800 is_set error_text then couldn'tu800 match with au800 pattern isu800 there anu800 expicit suggestion ifu800 suggestionsu82esuggestions ku800 lower nilu800 then error_text error_state set_error 'parameter_ignored_suggest' ku800 suggestionsu82esuggestions ku800 lower true ; else error_text error_state set_error 'parameter_ignored' ku800 true ; vu800  ; unset value assigned tou800 unrecognized parameters this foru800 theu800 limited parameter lists endu800 endu800 endu800 ifu800 error_text   then tableu82einsert zu800u82emessage_tail error_text error_state ; endu800 endu800 missing_pipe_check vu800 ; dou800 weu800 think that there isu800 au800 parameter that isu800 missing au800 pipe todo isu800 this theu800 best place foru800 this translation args ku800 vu800; elseif args ku800 nilu800 oru800 ku800 'postscript' then here when vu800 isu800 empty string args ku800 vu800; whyu800 dou800 weu800 dou800 this weu800 donu800'tu800 support 'empty' parameters endu800 endu800 foru800 ku800 vu800 inu800 pairs args dou800 ifu800 'string' type ku800 then donu800'tu800 evaluate positional parameters has_invisible_chars ku800 vu800 ; endu800 endu800 return tableu82econcat citation0 config args frame extensiontag 'templatestyles   srcu800 styles ; endu800 return citation citation ; 