Module:Harvc
Appearance
![]() | This module depends on the following other modules: |
![]() | This module uses TemplateStyles: |
Implements {{Harvc}}.
f = {
args_default = {
bracket_left = "",
bracket_right = "",
In = '',
c = '',
contribution = '',
author = '',
last = '',
last1='',
P1 = "",
P2 = "",
P3 = "",
P4 = "",
P5 = ""
}
};
function trim( str )
if str == nil then
return nil;
end
return str:match( "^%s*(.-)%s*$");
end
function core( args )
--<span id={{sfnref|Cottontail|2012}} class="citation">Cottontail (2012) "Evading Capture". In [[#CITEREFLapin2012|Lapin 2012]]</span>
local result;
-- form the CITEREF anchor
result = '<span id="CITEREF' .. table.concat ({args.P1, args.P2, args.P3, args.P4, args.P5}) .. '" class="citation">'
-- form the author date list; like sfn and harv, 1 to 4 names and a date; same construct as sfn and harv
if args.P5 ~= "" then
result = result .. args.P1 .. ' et al. ' .. args.bracket_year_left .. args.P5 ..
args.bracket_year_right;
elseif args.P4 ~= "" then
result = result .. args.P1 .. ', ' .. args.P2 .. ' & ' .. args.P3 .. ' ' .. args.bracket_year_left .. args.P4 .. args.bracket_year_right;
elseif args.P3 ~= "" then
result = result .. args.P1 .. ' & ' .. args.P2 .. ' ' .. args.bracket_year_left .. args.P3 .. args.bracket_year_right;
else
result = result .. args.P1 .. ' ' .. args.bracket_year_left .. args.P2 .. args.bracket_year_right;
end
--add the contribution and close the span
result = result .. '"' .. args.contribution .. '" in ' .. args.In ..'</span>';
return result;
end
function f.harvc (frame)
local args = f.args_default;
pframe = frame:getParent();
args.contribution = pframe.args.c or pframe.args.contribution or "";
args.In = pframe.args.In;
args.P1 = pframe.args.author or pframe.args.last or pframe.args.last1 or trim (pframe.args[1]) or "";
args.P2 = trim (pframe.args[2]) or "";
args.P3 = trim (pframe.args[3]) or "";
args.P4 = trim (pframe.args[4]) or "";
args.P5 = trim (pframe.args[5]) or "";
return core( args );
end
--[[
function f.sfn( frame )
local args = f.args_default;
pframe = frame:getParent();
args.postscript = pframe.args.postscript or pframe.args.ps or ".";
args.page = pframe.args.p or pframe.args.page or "";
args.pages = pframe.args.pp or pframe.args.pages or "";
args.location = pframe.args.loc or "";
args.ref = pframe.args.ref or pframe.args.Ref or "";
args.P1 = trim( pframe.args[1] ) or "";
args.P2 = trim( pframe.args[2] ) or "";
args.P3 = trim( pframe.args[3] ) or "";
args.P4 = trim( pframe.args[4] ) or "";
args.P5 = trim( pframe.args[5] ) or "";
local result = core( args );
local name = "FOOTNOTE" .. args.P1 .. args.P2 ..
args.P3 .. args.P4 .. args.P5 .. args.page .. args.pages .. args.location;
result = frame:extensionTag{ name = "ref", args = {name=name}, content=result };
return result;
end
]]
return f;