Module:Citation/CS1: Difference between revisions

no edit summary
m>Trappist the monk
(bug fix in language_parameter();)
m>Trappist the monk
No edit summary
Line 1: Line 1:


local cs1 ={};
local cs1 ={};
Line 109: Line 108:
There are several tests:
There are several tests:
the first character of the whole domain name including subdomains must be a letter or a digit
the first character of the whole domain name including subdomains must be a letter or a digit
internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
single-letter/digit second-level domains in the .org TLD
single-letter/digit second-level domains in the .org TLD
q, x, and z SL domains in the .com TLD
q, x, and z SL domains in the .com TLD
Line 132: Line 132:
end
end
-- Do most common case first
-- Do most common case first
if domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then     -- three or more character hostname.hostname or hostname.tld
if domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then -- three or more character hostname.hostname or hostname.tld
return true;
elseif domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.xn%-%-[%a%d]+$') then -- internationalized domain name with ACE prefix
return true;
return true;
elseif domain:match ('%f[%a%d][%a%d]%.org$') then -- one character .org hostname
elseif domain:match ('%f[%a%d][%a%d]%.org$') then -- one character .org hostname
Line 243: Line 245:
local orig;
local orig;


if is_set (link) then -- don't bother if link doesn't have a value
if is_set (link) then -- don't bother if <param>-link doesn't have a value
if not link_param_ok (link) then -- check |<param>-link= markup
if not link_param_ok (link) then -- check |<param>-link= markup
orig = lorig; -- identify the failing link parameter
orig = lorig; -- identify the failing link parameter
elseif title:find ('%[%[') then -- check |title= for wikilink markup
elseif title:find ('%[%[') then -- check |title= for wikilink markup
orig = torig; -- identify the failing link parameter
orig = torig; -- identify the failing |title= parameter
end
end
end
end
Line 366: Line 368:
local function external_link( URL, label, source )
local function external_link( URL, label, source )
local error_str = "";
local error_str = "";
local domain;
local path;
if not is_set( label ) then
if not is_set( label ) then
label = URL;
label = URL;
Line 377: Line 382:
error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, " " ) .. error_str;
error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, " " ) .. error_str;
end
end
domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$'); -- split the url into scheme plus domain and path
if path then -- if there is a path portion
path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'}); -- replace '[' and ']' with their percent encoded values
URL=domain..path; -- and reassemble
end
return table.concat({ "[", URL, " ", safe_for_url( label ), "]", error_str });
return table.concat({ "[", URL, " ", safe_for_url( label ), "]", error_str });
end
end


--[[--------------------------< D E P R E C A T E D _ P A R A M E T E R >--------------------------------------
--[[--------------------------< D E P R E C A T E D _ P A R A M E T E R >--------------------------------------
Line 590: Line 603:
if position then
if position then
-- if 'nowiki' == capture or 'math' == capture or ('ref' == capture and 'quote' == param) then -- nowiki, math, or quote param and ref stripmarker (not an error condition)
if 'nowiki' == capture or 'math' == capture then -- nowiki, math stripmarker (not an error condition)
if 'nowiki' == capture or 'math' == capture then -- nowiki, math stripmarker (not an error condition)
stripmarker = true; -- set a flag
stripmarker = true; -- set a flag
elseif true == stripmarker and 'delete' == char then -- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
elseif true == stripmarker and 'delete' == char then -- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
position = nil; -- unset
elseif 'apostrophe' == char then -- apostrophe template uses &zwj;, hair space and zero-width space
apostrophe = true;
elseif true == apostrophe and in_array (char, {'zero width joiner', 'zero width space', 'hair space'}) then
position = nil; -- unset
position = nil; -- unset
else
else
Line 894: Line 902:
]]
]]


local function list_people(control, people, etal, list_name) -- TODO: why is list_name here?  not used in this function
local function list_people(control, people, etal)
local sep;
local sep;
local namesep;
local namesep;
Line 1,020: Line 1,028:
end
end
return name, etal; --  
return name, etal; --  
end
--[[--------------------------< N A M E _ H A S _ M U L T _ N A M E S >----------------------------------------
Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.
]]
local function name_has_mult_names (name, list_name)
local count, _;
if is_set (name) then
if name:match ('^%(%(.*%)%)$') then -- if wrapped in doubled parentheses, ignore
name = name:match ('^%(%((.*)%)%)$'); -- strip parens
else
_, count = name:gsub ('[;,]', ''); -- count the number of separator-like characters
if 1 < count then -- param could be |author= or |editor= so one separactor character is acceptable
add_maint_cat ('mult_names', list_name:lower()); -- more than one separator indicates multiple names so add a maint cat for this template
end
end
end
return name; -- and done
end
end


Line 1,056: Line 1,088:
mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );


last, etal = name_has_etal (last, etal, false); -- find and remove variations on et al.
last, etal = name_has_etal (last, etal, false); -- find and remove variations on et al.
first, etal = name_has_etal (first, etal, false); -- find and remove variations on et al.
first, etal = name_has_etal (first, etal, false); -- find and remove variations on et al.
 
last = name_has_mult_names (last, err_msg_list_name); -- check for multiple names in last and its aliases
if first and not last then -- if there is a firstn without a matching lastn
if first and not last then -- if there is a firstn without a matching lastn
table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } ); -- add this error message
table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } ); -- add this error message
Line 1,084: Line 1,117:
--[[--------------------------< G E T _ I S O 6 3 9 _ C O D E >------------------------------------------------
--[[--------------------------< G E T _ I S O 6 3 9 _ C O D E >------------------------------------------------


Validates language names provided in |language= parameter if not an ISO639-1 code.
Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.


Returns the language name and associated ISO639-1 code.  Because case of the source may be incorrect or different from the case that Wikimedia
Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
with the code.  When there is no match, we return the original language name string.
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.


mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
mw.language.fetchLanguageNames(<local wiki language>, 'all') return a list of languages that in some cases may include
in the list will be found if that name is provided in the |language= parameter.  For example, if |language=Samaritan Aramaic, that name will be
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
found with the associated code 'sam', not an ISO639-1 code.  When names are found and the associated code is not two characters, this function
code 'cbk' or name 'Chavacano'.
returns only the Wikimedia language name.
 
Names but that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the Wikimedia language name.


Adapted from code taken from Module:Check ISO 639-1.
Adapted from code taken from Module:Check ISO 639-1.
Line 1,106: Line 1,143:
for code, name in pairs(languages) do -- scan the list to see if we can find our language
for code, name in pairs(languages) do -- scan the list to see if we can find our language
if langlc == mw.ustring.lower(name) then
if langlc == mw.ustring.lower(name) then
if 2 ~= code:len() then -- ISO639-1 codes only
if 2 ~= code:len() and 3 ~= code:len() then -- two- or three-character codes only; extensions not supported
return name; -- so return the name but not the code
return name; -- so return the name but not the code
end
end
return name, code; -- found it, return name to ensure proper capitalization and the ISO639-1 code
return name, code; -- found it, return name to ensure proper capitalization and the the code
end
end
end
end
return lang; -- not valid language; return language in original case and nil for ISO639-1 code
return lang; -- not valid language; return language in original case and nil for the code
end
end


--[[--------------------------< L A N G U A G E _ P A R A M E T E R >------------------------------------------
--[[--------------------------< L A N G U A G E _ P A R A M E T E R >------------------------------------------


Get language name from ISO639-1 code value provided.  If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.
Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.


When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
When |language= contains a recognized language (either code or name), the page is assigned to the category for
the page is a mainspace page and the ISO639-1 code is not the local wiki's language code.  Similarly, if the  parameter is |language=Norwegian,
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
it will be categorized in the same way.
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.


This function supports multiple languages in the form |language=nb, French, th where the language names or codes are separated from each other by commas.
Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized bit code 'ara' is not.
 
This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas.


]]
]]


local function language_parameter (lang)
local function language_parameter (lang)
local code; -- the ISO639-1 two character code
local code; -- the two- or three-character language code
local name; -- the language name
local name; -- the language name
local language_list = {}; -- table of language names to be rendered
local language_list = {}; -- table of language names to be rendered
Line 1,141: Line 1,183:
for _, lang in ipairs (names_table) do -- reuse lang
for _, lang in ipairs (names_table) do -- reuse lang


if lang:match ('^%a%a%-') then -- strip ietf language tags from code
if lang:match ('^%a%a%-') then -- strip ietf language tags from code; TODO: is there a need to support 3-char with tag?
lang = lang:match ('(%a%a)%-') -- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
lang = lang:match ('(%a%a)%-') -- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
end
end
if 2 == lang:len() then -- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
if 2 == lang:len() or 3 == lang:len() then -- if two-or three-character code
name = mw.language.fetchLanguageName( lang:lower(), this_wiki_code); -- get ISO 639-1 language name if Language is a proper code
name = mw.language.fetchLanguageName( lang:lower(), this_wiki_code); -- get language name if |language= is a proper code
end
end
if is_set (name) then -- if Language specified a valid ISO639-1 code
if is_set (name) then -- if |language= specified a valid code
code = lang:lower(); -- save it
code = lang:lower(); -- save it
else
else
Line 1,154: Line 1,196:
end
end
if is_set (code) then
if is_set (code) then -- only 2- or 3-character codes
if this_wiki_code ~= code then -- when the language is not the same as this wiki's language
if this_wiki_code ~= code then -- when the language is not the same as this wiki's language
add_prop_cat ('foreign_lang_source', {name, code}) -- categorize it
if 2 == code:len() then -- and is a two-character code
add_prop_cat ('foreign_lang_source', {name, code}) -- categorize it
else -- or is a recognized language (but has a three-character code)
add_prop_cat ('foreign_lang_source_2', {code}) -- categorize it differently TODO: support mutliple three-character code categories per cs1|2 template
end
end
end
else
else
Line 1,607: Line 1,653:
end
end


--[[--------------------------< C I T A T I O N 0 >------------------------------------------------------------


This is the main function doing the majority of the citation formatting.
--[=[-------------------------< A R C H I V E _ U R L _ C H E C K >--------------------------------------------
 
Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the  
save snapshot url.  When the archive url is 'https://web.archive.org/save/' (or http://...) archive.org saves a snapshot
of the target page in the url.  That is something that Wikipedia should not allow unwitting readers to do.


]]
When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a 'search' result.  [[WP:ELNO]] discourages links to search results.


local function citation0( config, args)
This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
--[[
|archive-date= and an error message when:
Load Input Parameters
|archive-url= holds an archive.org save command url
The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the correct place
]]
otherwise returns |archive-url= and |archive-date=
local A = argument_wrapper( args );
local i


-- Pick out the relevant fields from the arguments.  Different citation templates
]=]
 
local function archive_url_check (url, date)
if url:match('//web\.archive\.org/') then -- for archive.org urls:
if url:match('//web\.archive\.org/save/') then -- if a save command url, we don't want to save target page
table.insert( z.message_tail, { set_error( 'archive_url', {'save command'}, true ) } ); -- add error message
return '', ''; -- return empty strings for archiveURL and ArchiveDate
elseif url:match('//web\.archive\.org/web/%d%d%d%d%d%d%d%d%d%d%d%d%d%d/') then -- if there is what looks like a correct timestamp
return url, date; -- return archiveURL and ArchiveDate
else -- malformed url
table.insert( z.message_tail, { set_error( 'archive_url', {'timestamp'}, true ) } ); -- add error message
return '', ''; -- return empty strings for archiveURL and ArchiveDate
end
end
return url, date; -- not an archive.org archive
end
 
 
--[[--------------------------< M I S S I N G _ P I P E _ C H E C K >------------------------------------------
 
Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe:
{{cite ... |title=Title access-date=2016-03-17}}
 
cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.
 
If a missing pipe is detected, this function adds the missing pipe maintenance category.
 
]]
 
local function missing_pipe_check (value)
local capture;
value = value:gsub ('%b<>', ''); -- remove xml/html tags because attributes: class=, title=, etc
 
capture = value:match ('%s+(%a[%a%d]+)%s*=') or value:match ('^(%a[%a%d]+)%s*='); -- find and categorize parameters with possible missing pipes
if capture and validate (capture) then -- if the capture is a valid parameter name
add_maint_cat ('missing_pipe');
end
end
 
 
--[[--------------------------< C I T A T I O N 0 >------------------------------------------------------------
 
This is the main function doing the majority of the citation formatting.
 
]]
 
local function citation0( config, args)
--[[
Load Input Parameters
The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
]]
local A = argument_wrapper( args );
local i
 
-- Pick out the relevant fields from the arguments.  Different citation templates
-- define different field names for the same underlying things.
-- define different field names for the same underlying things.
local author_etal;
local author_etal;
Line 1,717: Line 1,822:
local Docket = A['Docket'];
local Docket = A['Docket'];
local ArchiveFormat = A['ArchiveFormat'];
local ArchiveFormat = A['ArchiveFormat'];
local ArchiveURL = A['ArchiveURL'];
 
local ArchiveDate;
local ArchiveURL;
 
ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
-- local ArchiveDate = A['ArchiveDate'];
-- local ArchiveURL = A['ArchiveURL'];
-- if ArchiveURL:match('//web\.archive\.org/save/') then -- if an archive.org save command url, we don't want to save target page ...
-- ArchiveURL = ''; -- every time a reader clicks the link so
-- ArchiveDate = ''; -- unset these
-- table.insert( z.message_tail, { set_error( 'archive_save', {}, true ) } ); -- and add error message
-- end
local DeadURL = A['DeadURL']
if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then -- set in config.defaults to 'yes'
DeadURL = ''; -- anything else, set to empty string
end
 
local URL = A['URL']
local URL = A['URL']
local URLorigin = A:ORIGIN('URL'); -- get name of parameter that holds URL
local URLorigin = A:ORIGIN('URL'); -- get name of parameter that holds URL
Line 1,765: Line 1,887:
local Via = A['Via'];
local Via = A['Via'];
local AccessDate = A['AccessDate'];
local AccessDate = A['AccessDate'];
local ArchiveDate = A['ArchiveDate'];
local Agency = A['Agency'];
local Agency = A['Agency'];
local DeadURL = A['DeadURL']
if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then -- set in config.defaults to 'yes'
DeadURL = ''; -- anything else, set to empty string
end


local Language = A['Language'];
local Language = A['Language'];
Line 2,131: Line 2,248:
Date validation supporting code is in Module:Citation/CS1/Date_validation
Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
]]
do -- create defined block to contain local variables error_message and mismatch
do -- create defined block to contain local variables error_message, date_parameters_list, mismatch
local error_message = '';
local error_message = '';
-- AirDate has been promoted to Date so not necessary to check it
-- AirDate has been promoted to Date so not necessary to check it
anchor_year, error_message = dates({['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
local date_parameters_list = {['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year}, COinS_date);
['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year};
 
anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);


if is_set (Year) and is_set (Date) then -- both |date= and |year= not normally needed;  
if is_set (Year) and is_set (Date) then -- both |date= and |year= not normally needed;  
Line 2,152: Line 2,271:
table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } ); -- add this error message
table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } ); -- add this error message
elseif is_set (DF) then
elseif is_set (DF) then
local date_parameters_list = {['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate};
if reformat_dates (date_parameters_list, DF, false) then -- reformat to DF format, use long month names if appropriate
if reformat_dates (date_parameters_list, DF, false) then -- reformat to DF format, use long month names if appropriate
AccessDate = date_parameters_list['access-date']; -- overwrite date holding parameters with reformatted values
AccessDate = date_parameters_list['access-date']; -- overwrite date holding parameters with reformatted values
ArchiveDate = date_parameters_list['archive-date']; -- TODO: move all dates into this table at the beginning and ...
ArchiveDate = date_parameters_list['archive-date'];
Date = date_parameters_list['date']; -- ... use them from this table? no in-and-out like we're doing here
Date = date_parameters_list['date'];
DoiBroken = date_parameters_list['doi-broken-date'];
DoiBroken = date_parameters_list['doi-broken-date'];
Embargo = date_parameters_list['embargo'];
LayDate = date_parameters_list['lay-date'];
LayDate = date_parameters_list['lay-date'];
PublicationDate = date_parameters_list['publication-date'];
PublicationDate = date_parameters_list['publication-date'];
Line 2,273: Line 2,388:
do -- do editor name list first because coauthors can modify control table
do -- do editor name list first because coauthors can modify control table
control.maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
control.maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
last_first_list, EditorCount = list_people(control, e, editor_etal, 'editor');
last_first_list, EditorCount = list_people(control, e, editor_etal);


if is_set (Editors) then
if is_set (Editors) then
Line 2,292: Line 2,407:
do -- now do translators
do -- now do translators
control.maximum = #t; -- number of translators
control.maximum = #t; -- number of translators
Translators = list_people(control, t, false, 'translator'); -- et al not currently supported
Translators = list_people(control, t, false); -- et al not currently supported
end
end
do -- now do contributors
do -- now do contributors
control.maximum = #c; -- number of contributors
control.maximum = #c; -- number of contributors
Contributors = list_people(control, c, false, 'contributor'); -- et al not currently supported
Contributors = list_people(control, c, false); -- et al not currently supported
end
end
do -- now do authors
do -- now do authors
Line 2,306: Line 2,421:
end
end
last_first_list = list_people(control, a, author_etal, 'author');
last_first_list = list_people(control, a, author_etal);


if is_set (Authors) then
if is_set (Authors) then
Line 2,342: Line 2,457:


if not is_set(URL) then
if not is_set(URL) then
if in_array(config.CitationClass, {"web","podcast", "mailinglist"}) then -- test if cite web or cite podcast |url= is missing or empty
if in_array(config.CitationClass, {"web","podcast", "mailinglist"}) then -- |url= required for cite web, cite podcast, and cite mailinglist
table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
end
end
-- test if accessdate is given without giving a URL
-- do we have |accessdate= without either |url= or |chapter-url=?
if is_set(AccessDate) and not is_set(ChapterURL)then -- ChapterURL may be set when the others are not set; TODO: move this to a separate test?
if is_set(AccessDate) and not is_set(ChapterURL)then -- ChapterURL may be set when URL is not set;
table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
AccessDate = '';
AccessDate = '';
Line 2,356: Line 2,471:
DeadURL = DeadURL:lower(); -- used later when assembling archived text
DeadURL = DeadURL:lower(); -- used later when assembling archived text
if is_set( ArchiveURL ) then
if is_set( ArchiveURL ) then
if is_set (URL) then
if is_set (ChapterURL) then -- swapped -- URL not set so if chapter-url is set apply archive url to it
OriginalURL = ChapterURL; -- save copy of source chapter's url for archive text
OriginalURLorigin = ChapterURLorigin; -- name of chapter-url parameter for error messages
OriginalFormat = ChapterFormat; -- and original |format=
if 'no' ~= DeadURL then
ChapterURL = ArchiveURL -- swap-in the archive's url
ChapterURLorigin = A:ORIGIN('ArchiveURL') -- name of archive-url parameter for error messages
ChapterFormat = ArchiveFormat or ''; -- swap in archive's format
end
elseif is_set (URL) then
OriginalURL = URL; -- save copy of original source URL
OriginalURL = URL; -- save copy of original source URL
OriginalURLorigin = URLorigin; -- name of url parameter for error messages
OriginalURLorigin = URLorigin; -- name of url parameter for error messages
Line 2,365: Line 2,489:
Format = ArchiveFormat or ''; -- swap in archive's format
Format = ArchiveFormat or ''; -- swap in archive's format
end
end
elseif is_set (ChapterURL) then -- URL not set so if chapter-url is set apply archive url to it
end
OriginalURL = ChapterURL; -- save copy of source chapter's url for archive text
OriginalURLorigin = ChapterURLorigin; -- name of chapter-url parameter for error messages
OriginalFormat = ChapterFormat; -- and original |format=
if 'no' ~= DeadURL then
ChapterURL = ArchiveURL -- swap-in the archive's url
ChapterURLorigin = A:ORIGIN('ArchiveURL') -- name of archive-url parameter for error messages
ChapterFormat = ArchiveFormat or ''; -- swap in archive's format
end
end
end
end


Line 2,454: Line 2,569:
if is_set(Title) then
if is_set(Title) then
if not is_set(TitleLink) and is_set(URL) then  
if not is_set(TitleLink) and is_set(URL) then
Title = external_link( URL, Title, URLorigin ) .. TransError .. Format;
Title = external_link( URL, Title, URLorigin ) .. TransError .. Format;
URL = "";
-- this experiment hidden 2016-04-10; see Help_talk:Citation_Style_1#Recycled_urls
-- local temp_title = external_link( URL, Title, URLorigin ) .. TransError .. Format; -- do this so we get error message even if url is usurped no archive
-- if in_array (DeadURL, {'unfit no archive', 'usurped no archive'}) then -- when url links to inappropriate location and there is no archive of original source available
-- local err_msg
-- if temp_title:match ('%[%S+%s+(.+)%](<.+)') then -- if there is an error message
-- Title, err_msg = temp_title:match ('%[%S+%s+(.+)%](<.+)'); -- strip off external link; TODO: find a better to do this
-- Title = Title .. (err_msg or '');
-- end
-- else
-- Title = temp_title;
-- end
 
URL = ''; -- unset these because no longer needed
Format = "";
Format = "";
else
else
Line 3,037: Line 3,164:
end
end
end
end
missing_pipe_check (v); -- do we think that there is a parameter that is missing a pipe?
args[k] = v;
args[k] = v;
elseif args[k] ~= nil or (k == 'postscript') then
elseif args[k] ~= nil or (k == 'postscript') then
Anonymous user