Module:Harvc: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 6:
}
};
 
--[[--------------------------< T R I M >----------------------------------------------------------------------
 
strip leading and trailing white space from positional parameters.
 
]]
 
function trim( str )
if str == nil then
return '';
end
return str:match( "^%s*(.-)%s*$");
end
 
 
--[[--------------------------< I S _ S E T >------------------------------------------------------------------
 
Whether variable is set or not. A varable is set when it is not nil and not empty.
 
]]
Line 29 ⟶ 15:
function is_set( var )
return not (var == nil or var == '');
end
 
 
-- if all items in list are set, return true, else false
function trimare_all_set( str ...)
local list = {...};
for _, var in pairs(list) do
if not is_set( var ) then
return ''false;
end
end
return true;
end
 
Line 37 ⟶ 35:
and text; encloses the whole within a span with id and class attributes.
 
This creates a CITEREF anchor from |last1= through |last4= and |year=. It also creates a CITEREF link from |in1= through
This function mimics the {{sfn}} and {{harv}} templates, but it does not display an author-date list, just an
author|in4= listand |year=. It is presumed that the dates of contributions are the same as the date of the enclosing work.
 
Even though not displayed, a year parameter is still required for the CITEREF anchor
Line 63 ⟶ 61:
end
 
-- if is_set (args.last4) and is_set (args.last3) and is_set (args.last2) and is_set (args.last1) then
if are_all_set ({args.last4, args.last3, args.last2, args.last1}) then
contributors = args.last1 .. args.first .. ' et al.';
elseif is_set (args.last3) and is_set (args.last2) and is_set (args.last1) then