پودمان:Citation/CS1/en: تفاوت میان نسخه‌ها

محتوای حذف‌شده محتوای افزوده‌شده
بروزرسانی argument_wrapper
برچسب: برگردانده‌شده
بروزسانی extract_names
برچسب: برگردانده‌شده
خط ۱٬۲۶۹:
 
 
--[[--------------------------< E X T R A C T _ N A M E S >----------------------------------------------------
 
Gets name list from the input arguments
 
Searches through args in sequential order to find |lastn= and |firstn= parameters
(or their aliases), and their matching link and mask parameters. Stops searching
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts:
found |last1=, |last2=, and |last3= but doesn't find |last4= and |last5= then the
find |last4= and |last5= then the search is done.
 
This function emits an error message when there is a |firstn= without a matching
|lastn=. When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not
required to have a matching |firstn=.
 
When an author or editor parameter contains some form of 'et al.', the 'et al.'
is stripped from the parameter and a flag (etal) returned that will cause list_people()
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/en/Configuration. This keeps 'et al.' out of the
'et al.' out of the template's metadata. When this occurs, thean pageerror is added to a maintenance categoryemitted.
 
]]
 
local function extract_names(args, list_name)
local names = {}; -- table of names
local last; -- individual name components
local first;
local link;
local mask;
local i = 1; -- loop counter/indexer
local n = 1; -- output table indexer
local count = 0; -- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
local etal = false; -- return value set to true when we find some form of et al. in an author parameter
 
local last_alias, first_alias, link_alias; -- selected parameter aliases used in error messaging
local err_msg_list_name = list_name:match ("(%w+)List") .. 's list'; -- modify AuthorList or EditorList for use in error messages if necessary
while true do
last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameterserr_redundant_parameters', i ); -- search through args for name components beginning at 1
first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'redundant_parameterserr_redundant_parameters', i );
link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameterserr_redundant_parameters', i );
mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameterserr_redundant_parameters', i );
 
last, etal = name_has_etal (last, etal, false, last_alias); -- find and remove variations on et al.
first, etal = name_has_etal (first, etal, false, first_alias); -- find and remove variations on et al.
last, first = name_checks (last, first, list_name, last_alias, first_alias); -- multiple names, extraneous annotation, etc. checks
 
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.
last, first= name_checks (last, first, list_name); -- multiple names, extraneous annotation, etc checks
if first and not last then -- if there is a firstn without a matching lastn
local alias = first_alias:find ('given', 1, true) and 'given' or 'first'; -- get first or given form of the alias
table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } ); -- add this error message
utilities.set_message ('err_first_missing_last', {
first_alias, -- param name of alias missing its mate
first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}), -- make param name appropriate to the alias form
}); -- add this error message
elseif not first and not last then -- if both firstn and lastn aren't found, are we done?
count = count + 1; -- number of times we haven't found last and first
سطر ۱٬۳۱۵ ⟵ ۱٬۳۲۵:
end
else -- we have last with or without a first
local result;
link_title_ok (link, list_name:match ("(%w+)List"):lower() .. '-link' .. i, last, list_name:match ("(%w+)List"):lower() .. '-last' .. i); -- check for improper wikimarkup
link = link_title_ok (link, link_alias, last, last_alias); -- check for improper wiki-markup
 
if first then
names[n] = {last = last, first = first, link = link, mask = mask, corporate=false}; -- add this name to our names list (corporate for |vauthors= only)
link = link_title_ok (link, link_alias, first, first_alias); -- check for improper wiki-markup
end
 
names[n] = {last = last, first = first, link = link, mask = mask, corporate = false}; -- add this name to our names list (corporate for |vauthors= only)
n = n + 1; -- point to next location in the names table
if 1 == count then -- if the previous name was missing
tableutilities.insert(set_message z.message_tail, { set_error( 'missing_nameerr_missing_name', {err_msg_list_namelist_name:match ("(%w+)List"):lower(), i - 1}, true ) } ); -- add this error message
end
count = 0; -- reset the counter, we're looking for two consecutive missing names
سطر ۱٬۳۲۷ ⟵ ۱٬۳۴۲:
end
return names, etal; -- all done, return our list of names and the etal flag
end
 
 
--[[--------------------------< G E T _ I S O 6 3 9 _ C O D E >------------------------------------------------