Broken/Footnotes: razlika između inačica

Izvor: Hrvatska internetska enciklopedija
Prijeđi na navigaciju Prijeđi na pretraživanje
Bot: Automatski unos stranica
 
Nema sažetka uređivanja
 
Nije prikazana jedna međuinačica
Redak 1: Redak 1:
<!--'''Modul:Footnotes'''-->f = {
local f = {}
args_default = {
bracket_left = "",
bracket_right = "",
bracket_year_left = "",
bracket_year_right = "",
postscript = "",
page = "",
pages = "",
location = "",
page_sep = ", str.&nbsp;",
pages_sep = ", str.&nbsp;",
ref = "",
P1 = "",
P2 = "",
P3 = "",
P4 = "",
P5 = ""
}
};


function trim( str )
f.args_default = {
if str == nil then
    bracket_left = "",
return nil;
    bracket_right = "",
end
    bracket_year_left = "",
str = str:match( "^%s*(.-)%s*$");
    bracket_year_right = "",
return str:gsub("%.$", "")
    postscript = "",
end   
    page = "",
    pages = "",
    location = "",
    page_sep = ", str.&nbsp;",
    pages_sep = ", str.&nbsp;",
    ref = "",
    P1 = "",
    P2 = "",
    P3 = "",
    P4 = "",
    P5 = ""
}


function core( args )
local function trim(str)
local result;
    if not str then return "" end
    str = mw.text.trim(str)
    return str:gsub("%.$", "")
end
 
local function core(args)
    local result


if args.P5 ~= "" then
    if args.P5 ~= "" then
result = args.P1 .. ' et al. ' .. args.bracket_year_left .. args.P5 ..  
        result = args.P1 .. " et al. " .. args.bracket_year_left .. args.P5 .. args.bracket_year_right
args.bracket_year_right;
    elseif args.P4 ~= "" then
elseif args.P4 ~= "" then
        result = args.P1 .. ", " .. args.P2 .. " i " .. args.P3 .. " " ..
result = args.P1 .. ', ' .. args.P2 .. ' i ' .. args.P3 .. ' ' ..  
            args.bracket_year_left .. args.P4 .. args.bracket_year_right
args.bracket_year_left .. args.P4 .. args.bracket_year_right;
    elseif args.P3 ~= "" then
elseif args.P3 ~= "" then
        result = args.P1 .. " i " .. args.P2 .. " " ..
result = args.P1 .. ' i ' .. args.P2 .. ' ' .. args.bracket_year_left ..  
            args.bracket_year_left .. args.P3 .. args.bracket_year_right
args.P3 .. args.bracket_year_right;
    else
else
        result = trim(args.P1 .. " " .. args.bracket_year_left .. args.P2 .. args.bracket_year_right)
result = trim( args.P1 .. ' ' .. args.bracket_year_left .. args.P2 ..  
    end
args.bracket_year_right )
end


if args.ref ~= 'none' then
    -- REF handling
if args.ref ~= "" then
    if args.ref ~= "none" then
result = "[[#" .. mw.uri.anchorEncode(args.ref) .. "|" .. result .. "]]";
        if args.ref ~= "" then
else
            result = "[[#" .. mw.uri.anchorEncode(args.ref) .. "|" .. result .. "]]"
result = "[[#CITEREF" .. mw.uri.anchorEncode(args.P1 .. args.P2 .. args.P3 .. args.P4 .. args.P5) .. "|" .. result .. "]]";
        else
end
            local anchor = args.P1 .. args.P2 .. args.P3 .. args.P4 .. args.P5
end
            result = "[[#CITEREF" .. mw.uri.anchorEncode(anchor) .. "|" .. result .. "]]"
        end
    end


if args.page ~= "" then
    -- pages
result = result .. args.page_sep .. args.page;
    if args.page ~= "" then
elseif args.pages ~= "" then
        result = result .. args.page_sep .. args.page
result = result .. args.pages_sep .. args.pages;
    elseif args.pages ~= "" then
end    
        result = result .. args.pages_sep .. args.pages
    end


if args.location ~= "" then
    -- location
result = result .. ", " .. args.location;
    if args.location ~= "" then
end
        result = result .. ", " .. args.location
    end


result = args.bracket_left .. result .. args.bracket_right .. args.postscript;
    return args.bracket_left .. result .. args.bracket_right .. args.postscript
return result;
end
end


function f.harvard_core( frame )
function f.harvard_core(frame)
local args = {};
    local pframe = frame:getParent()
local pframe = frame:getParent();
    local args = mw.clone(f.args_default)
 
    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 == "none") and "" or (pframe.args.Postscript or "")


args.bracket_left = pframe.args.BracketLeft or "";
    args.page = pframe.args.Page or ""
args.bracket_right = pframe.args.BracketRight or "";
    args.pages = pframe.args.Pages or ""
args.bracket_year_left = pframe.args.BracketYearLeft or "";
    args.location = pframe.args.Location or ""
args.bracket_year_right = pframe.args.BracketYearRight or "";
    args.page_sep = pframe.args.PageSep or args.page_sep
args.postscript = pframe.args.Postscript or "";
    args.pages_sep = pframe.args.PagesSep or args.pages_sep
if 'none' == args.postscript then
    args.ref = pframe.args.REF or ""
args.postscript = '';
end


args.page = pframe.args.Page or "";
    args.P1 = trim(pframe.args.P1)
args.pages = pframe.args.Pages or "";
    args.P2 = trim(pframe.args.P2)
args.location = pframe.args.Location or "";
    args.P3 = trim(pframe.args.P3)
args.page_sep = pframe.args.PageSep or "";
    args.P4 = trim(pframe.args.P4)
args.pages_sep = pframe.args.PagesSep or "";
    args.P5 = trim(pframe.args.P5)
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 );
    return core(args)
end
end


function f.harvard_citation( frame )
function f.harvard_citation(frame)
local args = f.args_default;
    local pframe = frame:getParent()
pframe = frame:getParent();
    local args = mw.clone(f.args_default)
 
    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.bracket_left = "(";
    args.P1 = trim(pframe.args[1])
args.bracket_right = ")";
    args.P2 = trim(pframe.args[2])
args.page = pframe.args.p or pframe.args.page or "";
    args.P3 = trim(pframe.args[3])
args.pages = pframe.args.pp or pframe.args.pages or "";
    args.P4 = trim(pframe.args[4])
args.location = pframe.args.loc or "";
    args.P5 = trim(pframe.args[5])
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 );
    return core(args)
end
end


function f.harvard_citation_no_bracket( frame )
function f.harvard_citation_no_bracket(frame)
local args = f.args_default;
    local pframe = frame:getParent()
pframe = frame:getParent();
    local args = mw.clone(f.args_default)
 
    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.page = pframe.args.p or pframe.args.page or "";
    args.P1 = trim(pframe.args[1])
args.pages = pframe.args.pp or pframe.args.pages or "";
    args.P2 = trim(pframe.args[2])
args.location = pframe.args.loc or "";
    args.P3 = trim(pframe.args[3])
args.ref = pframe.args.ref or pframe.args.Ref or "";
    args.P4 = trim(pframe.args[4])
args.P1 = trim( pframe.args[1] ) or "";
    args.P5 = trim(pframe.args[5])
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 );
    return core(args)
end
end


function f.sfn( frame )
function f.sfn(frame)
local args = f.args_default;
    local pframe = frame:getParent()
for k, v in pairs( frame.args ) do -- for {{sfnp}}, override default with values provided in the #invoke:
    local args = mw.clone(f.args_default)
args[k] = v;  
 
end
    -- override defaults with #invoke args
    for k, v in pairs(frame.args) do
pframe = frame:getParent();
        args[k] = v
    end
 
    args.postscript = (pframe.args.postscript == "none") and "" or (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.postscript = pframe.args.postscript or pframe.args.ps or ".";
    args.P1 = trim(pframe.args[1])
if 'none' == args.postscript then
    args.P2 = trim(pframe.args[2])
args.postscript = '';
    args.P3 = trim(pframe.args[3])
end
    args.P4 = trim(pframe.args[4])
args.page = pframe.args.p or pframe.args.page or "";
    args.P5 = trim(pframe.args[5])
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 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 };
    local name = "FOOTNOTE" ..
        args.P1 .. args.P2 .. args.P3 .. args.P4 .. args.P5 ..
        args.page .. args.pages .. args.location


return result;
    return frame:extensionTag{
        name = "ref",
        args = { name = name },
        content = result
    }
end
end


return f;
return f

Posljednja izmjena od 12. siječanj 2026. u 10:07

local f = {}

f.args_default = {

   bracket_left = "",
   bracket_right = "",
   bracket_year_left = "",
   bracket_year_right = "",
   postscript = "",
   page = "",
   pages = "",
   location = "",
   page_sep = ", str. ",
   pages_sep = ", str. ",
   ref = "",
   P1 = "",
   P2 = "",
   P3 = "",
   P4 = "",
   P5 = ""

}

local function trim(str)

   if not str then return "" end
   str = mw.text.trim(str)
   return str:gsub("%.$", "")

end

local 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 .. " i " .. args.P3 .. " " ..
           args.bracket_year_left .. args.P4 .. args.bracket_year_right
   elseif args.P3 ~= "" then
       result = args.P1 .. " i " .. 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
   -- REF handling
   if args.ref ~= "none" then
       if args.ref ~= "" then
           result = "" .. result .. ""
       else
           local anchor = args.P1 .. args.P2 .. args.P3 .. args.P4 .. args.P5
           result = "" .. result .. ""
       end
   end
   -- pages
   if args.page ~= "" then
       result = result .. args.page_sep .. args.page
   elseif args.pages ~= "" then
       result = result .. args.pages_sep .. args.pages
   end
   -- location
   if args.location ~= "" then
       result = result .. ", " .. args.location
   end
   return args.bracket_left .. result .. args.bracket_right .. args.postscript

end

function f.harvard_core(frame)

   local pframe = frame:getParent()
   local args = mw.clone(f.args_default)
   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 == "none") and "" or (pframe.args.Postscript or "")
   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.page_sep
   args.pages_sep = pframe.args.PagesSep or args.pages_sep
   args.ref = pframe.args.REF or ""
   args.P1 = trim(pframe.args.P1)
   args.P2 = trim(pframe.args.P2)
   args.P3 = trim(pframe.args.P3)
   args.P4 = trim(pframe.args.P4)
   args.P5 = trim(pframe.args.P5)
   return core(args)

end

function f.harvard_citation(frame)

   local pframe = frame:getParent()
   local args = mw.clone(f.args_default)
   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])
   args.P2 = trim(pframe.args[2])
   args.P3 = trim(pframe.args[3])
   args.P4 = trim(pframe.args[4])
   args.P5 = trim(pframe.args[5])
   return core(args)

end

function f.harvard_citation_no_bracket(frame)

   local pframe = frame:getParent()
   local args = mw.clone(f.args_default)
   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])
   args.P2 = trim(pframe.args[2])
   args.P3 = trim(pframe.args[3])
   args.P4 = trim(pframe.args[4])
   args.P5 = trim(pframe.args[5])
   return core(args)

end

function f.sfn(frame)

   local pframe = frame:getParent()
   local args = mw.clone(f.args_default)
   -- override defaults with #invoke args
   for k, v in pairs(frame.args) do
       args[k] = v
   end
   args.postscript = (pframe.args.postscript == "none") and "" or (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])
   args.P2 = trim(pframe.args[2])
   args.P3 = trim(pframe.args[3])
   args.P4 = trim(pframe.args[4])
   args.P5 = trim(pframe.args[5])
   local result = core(args)
   local name = "FOOTNOTE" ..
       args.P1 .. args.P2 .. args.P3 .. args.P4 .. args.P5 ..
       args.page .. args.pages .. args.location
   return frame:extensionTag{
       name = "ref",
       args = { name = name },
       content = result
   }

end

return f