Module:Harvc: Difference between revisions

Content deleted Content added
No edit summary
Add in1-4;
Line 1:
f = {
args_default = {
err_msg = '',
-- contribution = '',
-- separator = '.';
Line 38 ⟶ 39:
local contributors; -- chapter or contribution authors
local source = ''; -- editor/author date list that forms a CITEREF link to a full citation; mimics harvnb output except year in parentheses
-- local err_msg = ''; -- a place to put error message that are output following normal output
local result; -- the assemby of the above output
 
Line 58 ⟶ 59:
contributors = args.last1 .. args.first;
else
args.err_msg = '<spanargs.err_msg style="font-size:100%".. ' class="error">author missing from contributor list</span>.';
end
 
Line 71 ⟶ 72:
source = args.in1;
else
if '' ~= err_msg then args.err_msg = args.err_msg .. ' ';author end --missing spacefrom betweensource error messageslist.'
err_msg = '<span style="font-size:100%" class="error">author missing from source list</span>'
end
 
if '' ~= args.year then
source = source .. ' (' .. args.year .. ')';
else
-- args.yearerr_msg = '<spanargs.err_msg style="font-size:100%".. ' class="error">missing year</span>.'; -- error message if year not provided
end
 
source = "[[#CITEREF" .. mw.uri.anchorEncode(table.concat ({args.in1, args.in2, args.in3, args.in4, args.year})) .. "|" .. source .. "]]";
 
Line 87 ⟶ 91:
contributors = contributors .. args.separator; -- add separator if not same as last character in name list (|first=John S. or et al.)
end
--wrap error messages in span
args.err_msg = '<span style="font-size:100%" class="error">author' missing.. fromargs.err_msg source.. list'</span>';
 
-- and put it all together
result = span_open_tag .. contributors .. ' ' .. args.contribution .. args.separator .. ' In ' .. source .. args.postscript .. '</span>' .. args.err_msg;
 
-- if '' == args.year then
Line 97 ⟶ 104:
-- end
 
-- if '' == args.year then
-- args.year = '<span style="font-size:100%" class="error">missing year</span>'; -- error message if year not provided
-- end
 
return result;
Line 124 ⟶ 128:
args.in4 = pframe.args.in4 or '';
-- args.In = pframe.args['in'] or -- source; 'in' is a Lua reserved keyword
-- '<span style="font-size:100%" class="error">required source is missing</span>'; -- error message if source not provided
 
args.last1 = pframe.args.last or pframe.args.last1 or ''; -- contribution author(s)
args.last2 = pframe.args.last2 or '';
Line 140 ⟶ 141:
args.postscript = '.'; -- use default postscript
end
args.separatorseparaotr = pframe.args.separator or '.'; -- element separator defaults to full stop
args.url = pframe.args.url or ''; -- url for chapter or contribution
args.year = pframe.args.year or '';
 
-- args.P1 = trim (pframe.args[1]); -- the positional parameters mimic {{harv}} template usage
-- args.P2 = trim (pframe.args[2]);
-- args.P3 = trim (pframe.args[3]);
-- args.P4 = trim (pframe.args[4]);
-- args.P5 = trim (pframe.args[5]);
if '' == args.contribution then
args.contributionerr_msg = args.err_msg .. '<span style="font-size:100%" class="error">required contribution is missing</span>.'; -- error message if source not provided
-- args.url=''; -- if no contribution set url to empty string so we don't link the error message
end