Módulo:Footnotes
DescriçãoEste Módulo implementa a predefinição {{HarvRef}} entre outras. Por favor consulte a predefinição para mais instruções. UsoOutra documentação:
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;
--TODO: evaluate to make sure that the following if correctly handles the parameter set when there is no year
local ano
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
elseif args.P2 ~= "" then
local ano = args.P2
-- converte possível hífen para traço
if string.match(ano, "^[1-9]%d%d%d?[%-–][1-9]%d%d%d?%a?$") then
ano = ("%d–%d"):format(string.match(args.P2, "(%d%d%d%d?)%-(%d%d%d%d?)%a?"))
end
local isDate
for _, tmp in ipairs {'%d%d', 'Século', 'século', 'AC', 'A%.C%.', 'AD', 'A%.D%.'
, 'aC', 'a%.C%.', 'dC', 'd%.C%.', 'DC', 'D%.C%.', 'n%.d%.', 'nd', 's%.d%.', 'sd'}
do
if ano:find(tmp) then
isDate = true
break
end
end
if isDate then
result = args.P1 .. ' ' .. args.bracket_year_left .. ano .. args.bracket_year_right
else
result = args.P1 .. ' & ' .. args.P2 -- for the case where the last numbered parameter is a name and not a year and not no-date
end
args.P2 = ano
else
result = trim( args.P1 .. ' ' .. args.bracket_year_left .. args.P2 ..
args.bracket_year_right )
end
if ('.' == result:sub(-1)) and ('' == args.page) and ('' == args.pages) and ('' == args.location) then
args.postscript = '' -- prevent double periods when date is 'n.d.'
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 .. (ano or 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 'none' == args.postscript then
args.postscript = ''
end
args.page = pframe.args.Page or ""
args.pages = pframe.args.Pages or ""
args.location = pframe.args.Location or ""
args.page_sep = pframe.args.PageSep or ""
args.pages_sep = pframe.args.PagesSep or ""
args.ref = pframe.args.REF or "{{{REF}}}"
args.P1 = trim( pframe.args.P1 ) or ""
args.P2 = trim( pframe.args.P2 ) or ""
args.P3 = trim( pframe.args.P3 ) or ""
args.P4 = trim( pframe.args.P4 ) or ""
args.P5 = trim( pframe.args.P5 ) or ""
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:
args[k] = v
end
pframe = frame:getParent()
args.postscript = pframe.args.postscript or pframe.args.ps or "."
if 'none' == args.postscript then
args.postscript = ''
end
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 = trim(pframe.args['name']) or trim(pframe.args['nome']) or
"FOOTNOTE" .. args.P1 .. args.P2 .. args.P3 .. args.P4 .. args.P5 ..
args.page .. args.pages .. args.location
local group = trim(pframe.args['group']) or trim(pframe.args['grupo'])
result = frame:extensionTag{ name = "ref", args = { name = name, group = group}, content=result }
return result
end
return f
|
Index:
pl ar de en es fr it arz nl ja pt ceb sv uk vi war zh ru af ast az bg zh-min-nan bn be ca cs cy da et el eo eu fa gl ko hi hr id he ka la lv lt hu mk ms min no nn ce uz kk ro simple sk sl sr sh fi ta tt th tg azb tr ur zh-yue hy my ace als am an hyw ban bjn map-bms ba be-tarask bcl bpy bar bs br cv nv eml hif fo fy ga gd gu hak ha hsb io ig ilo ia ie os is jv kn ht ku ckb ky mrj lb lij li lmo mai mg ml zh-classical mr xmf mzn cdo mn nap new ne frr oc mhr or as pa pnb ps pms nds crh qu sa sah sco sq scn si sd szl su sw tl shn te bug vec vo wa wuu yi yo diq bat-smg zu lad kbd ang smn ab roa-rup frp arc gn av ay bh bi bo bxr cbk-zam co za dag ary se pdc dv dsb myv ext fur gv gag inh ki glk gan guw xal haw rw kbp pam csb kw km kv koi kg gom ks gcr lo lbe ltg lez nia ln jbo lg mt mi tw mwl mdf mnw nqo fj nah na nds-nl nrm nov om pi pag pap pfl pcd krc kaa ksh rm rue sm sat sc trv stq nso sn cu so srn kab roa-tara tet tpi to chr tum tk tyv udm ug vep fiu-vro vls wo xh zea ty ak bm ch ny ee ff got iu ik kl mad cr pih ami pwn pnt dz rmy rn sg st tn ss ti din chy ts kcg ve
Portal di Ensiklopedia Dunia