پودمان:Citation/CS1/en: تفاوت میان نسخهها
محتوای حذفشده محتوای افزودهشده
بروزرسانی argument_wrapper برچسب: برگرداندهشده |
بروزسانی extract_names برچسب: برگرداندهشده |
||
خط ۱٬۲۶۹:
--[[
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 found |last1=, |last2=, and |last3= but doesn't find |last4= and |last5= then the 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() 'et al.' out of the template's metadata. When this occurs,
]]
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
while true do
last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], '
first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], '
link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], '
mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], '
last, etal = name_has_etal (last, etal, false, last_alias);
first, etal = name_has_etal (first, etal, false, first_alias);
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
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 = 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
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 >------------------------------------------------
|