Diferenzas entre revisións de «Módulo:Footnotes»

actualizo código dende en:Module:Footnotes
(copiado de en.wiki)
 
(actualizo código dende en:Module:Footnotes)
f = {
args_default = {
bracket_left = "",
bracket_right = "",
bracket_year_left = "",
bracket_year_right = "",
postscript = "",
page = "",
pages = "",
location = "",
page_sep = ", p. ",
pages_sep = ", pp. ",
ref = "",
P1 = "",
P2 = "",
P3 = "",
P4 = "",
P5 = ""
}
}
};
 
function trim( str )
if str == nil then
return nil;
end
return str:match( "^%s*(.-)%s*$");
end
 
function core( args )
local result;
 
if args.P5 ~= "" then
result = args.P1 .. ' et al. ' .. args.bracket_year_left .. args.P5 ..
args.bracket_year_right;
elseif args.P4 ~= "" then
result = args.P1 .. ', ' .. args.P2 .. ' & ' .. args.P3 .. ' ' ..
args.bracket_year_left .. args.P4 .. args.bracket_year_right;
elseif args.P3 ~= "" then
result = args.P1 .. ' & ' .. args.P2 .. ' ' .. args.bracket_year_left ..
args.P3 .. args.bracket_year_right;
else
result = trim( args.P1 .. ' ' .. args.bracket_year_left .. args.P2 ..
args.bracket_year_right )
end
 
if args.ref ~= 'none' then
if args.ref ~= "" then
result = "[[#" .. mw.uri.anchorEncode(args.ref) .. "|" .. result .. "]]";
else
result = "[[#CITEREF" .. mw.uri.anchorEncode(args.P1 .. args.P2 .. args.P3 .. args.P4 .. args.P5) .. "|" .. result .. "]]";
end
end
 
if args.page ~= "" then
result = result .. args.page_sep .. args.page;
elseif args.pages ~= "" then
result = result .. args.pages_sep .. args.pages;
end
 
if args.location ~= "" then
result = result .. ", " .. args.location;
end
 
result = args.bracket_left .. result .. args.bracket_right .. args.postscript;
return result;
end
 
function f.harvard_core( frame )
local args = {};
local pframe = frame:getParent();
 
args.bracket_left = pframe.args.BracketLeft or "";
args.bracket_right = pframe.args.BracketRight or "";
args.bracket_year_left = pframe.args.BracketYearLeft or "";
args.bracket_year_right = pframe.args.BracketYearRight or "";
args.postscript = pframe.args.Postscript or "";
if args.page'none' == pframe.args.Page orpostscript "";then
args.postscript = '';
args.pages = pframe.args.Pages or "";
end
args.location = pframe.args.Location or "";
 
args.page_sep = pframe.args.PageSep or "";
args.pages_seppage = pframe.args.PagesSepPage or "";
args.refpages = pframe.args.REFPages or "{{{REF}}}";
args.P1location = trim( pframe.args.P1 )Location or "";
args.P2page_sep = trim( pframe.args.P2 )PageSep or "";
args.P3pages_sep = trim( pframe.args.P3 )PagesSep or "";
args.P4ref = trim( pframe.args.P4 )REF or "{{{REF}}}";
args.P5P1 = trim( pframe.args.P5P1 ) or "";
args.locationP2 = trim( pframe.args.LocationP2 ) or "";
args.P3 = return coretrim( pframe.args.P3 ) or "";
args.page_sepP4 = trim( pframe.args.PageSepP4 ) or "";
args.P1P5 = trim( pframe.args[1].P5 ) or "";
 
local result = return core( args );
end
 
function f.harvard_citation( frame )
local args = f.args_default;
pframe = frame:getParent();
 
args.bracket_left = "(";
args.bracket_right = ")";
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 "";
 
return core( args );
end
 
function f.harvard_citation_no_bracket( frame )
local args = f.args_default;
pframe = frame:getParent();
 
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 "";
 
return core( args );
end
 
function f.sfn( frame )
local args = f.args_default;
for k, v in pairs( frame.args ) do -- for {{sfnp}}, override default with values provided in the #invoke:
pframe = frame:getParent();
args[k] = v;
end
args.postscript = pframe.args.postscript or pframe.args.ps or ".";
args.page = pframe.args.p or pframe.args.page or "";
pframe = frame:getParent();
args.pages = pframe.args.pp or pframe.args.pages or "";
 
args.location = pframe.args.loc or "";
args.refpostscript = pframe.args.refpostscript or pframe.args.Refps or ".";
if 'none' == args.postscript then
args.P1 = trim( pframe.args[1] ) or "";
args.postscript = '';
args.P2 = trim( pframe.args[2] ) or "";
end
args.P3 = trim( pframe.args[3] ) or "";
args.P4page = trim( pframe.args[4].p )or pframe.args.page or "";
args.P5pages = trim( pframe.args[5].pp )or pframe.args.pages or "";
args.pageslocation = pframe.args.Pagesloc or "";
args.postscriptref = pframe.args.postscriptref or pframe.args.psRef or ".";
local result = core( args );
args.P1 = trim( pframe.args[1] ) or "";
local name = "FOOTNOTE" .. args.P1 .. args.P2 ..
args.P2 = trim( pframe.args[2] ) or "";
args.P3 .. args.P4 .. args.P5 .. args.page .. args.pages .. args.location;
args.P3 = trim( pframe.args[3] ) or "";
args.locationP4 = trim( pframe.args.loc[4] ) or "";
result = frame:extensionTag{ name = "ref", args = {name=name}, content=result };
args.pageP5 = trim( pframe.args.p[5] or pframe.args.page) or "";
 
return result;
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