Module:Harvc: Difference between revisions

Content deleted Content added
Synch from sandbox;
Synch from sandbox;
Line 67:
--[[
form the contributors display list:
if |displayname-authorslist-format= is empty or omittedharv, display is similar to {{sfn}} and {{harv}}, 1 to 4 last names;
if |display-authors=all thenis displaysempty allor authoromitted, display is similar to cs1|2: display all names in last, first order (similar to CS1/2 authorlist);
if |display-authors=etal then displays all author names in last, first order and append et al.
if value assigned to |display-authors= is less than the number of author last names, displays the specified number of author names in last, first order followed by et al.
]]
if is_set'harv' ~= (args.display_authors)name_list_format then -- override default harv or sfncs1|2 style contributor displaylist
local i = 1;
local count;
local etal = false; -- when |display-authors= is same as number of authors in contributor list
if 'all' ==is_set (args.display_authors:lower() then -- force all contributor first and last names to be displayed
elseif if 'etal' == args.display_authors:lower():gsub("[ '%.]", '') then -- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
count = #args.last; -- so set count accordingly
count = #args.last; -- display all authors and ...
elseif 'etal' == args.display_authors:lower():gsub("[ '%.]", '') then -- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
count etal = #args.lasttrue; -- display... allappend authors'et and ..al.'
else
etal = true; -- ... append 'at al.'
count = tonumber (args.display_authors) or 0; -- 0 if can't be converted to a number
else
if 0 >= count then
count = tonumber (args.display_authors) or 0; -- 0 if can't be converted to a number
args.err_msg = args.err_msg .. ' invalid |display-authors='; -- if zero, then emit error message
if 0 >= count then
end
args.err_msg = args.err_msg .. ' invalid |display-authors='; -- if zero, then emit error message
end
if count > #args.last then
count = #args.last; -- when |display-authors= is more than the number of authors, use the number of authors
end
if count < #args.last then -- when |display-authors= is less than the number of authors
etal = true; -- ... append 'atet al.'
end
else
count = #args.last; -- so set count accordinglyto display all of the authors
end
if count > #args.last then
count = #args.last; -- when |display-authors= is more than the number of authors, use the number of authors
end
if count < #args.last then -- when |display-authors= is less than the number of authors
etal = true; -- append 'at al.'
end
while i <= count do
if is_set (contributors) then
Line 102 ⟶ 106:
end
if true == etal then
contributors = contributors .. ' et al.'; -- append et al.
elseif 'yes' == args.last_author_amp then
contributors = contributors:gsub('; ([^;]+)$', ' & %1') -- replace last separator with ' & '
end
else -- do default harv- or sfn-style contributor display
Line 208 ⟶ 214:
 
args.display_authors = pframe.args['display-authors']; -- the number of contributor names to display; cs1/2 format includes first names
args.name_list_format = pframe.args['name-list-format']; -- when set to 'harv' display contributor list in sfn or harv style
 
args.last_author_amp = pframe.args['last-author-amp'] or -- yes only; |last-author-amp=no does not work (though it does in CS1|2)
pframe.args['lastauthoramp'] or '';
args.last_author_amp:lower(); -- make it case agnostic
if is_set (pframe.args['last1']) or is_set (pframe.args['last']) then -- must have at least this to continue
args.last[1] = pframe.args.last or pframe.args.last1; -- get first contributor's last name