Modul:Citation/CS1/Utilities: razlika između inačica

Izvor: Hrvatska internetska enciklopedija
Prijeđi na navigaciju Prijeđi na pretraživanje
Zamijenjen sadržaj stranice s » -- Modul:Citation/CS1/Utilities -- Minimalna verzija kompatibilna s hrvatskim CS1 modulom local p = {} -- Trim whitespace function p.trim(s) if not s then return nil end return mw.text.trim(s) end -- Provjera je li vrijednost postavljena function p.is_set(v) return v ~= nil and mw.text.trim(v) ~= "" end -- Formatiranje liste s razmacima function p.join(parts, sep) sep = sep or " " local out = {} for _, v in ipairs(parts) do...«
Oznaka: zamijenjeno preko 90 % teksta
Nema sažetka uređivanja
Redak 4: Redak 4:


local p = {}
local p = {}
function p.format_authors(list)
    if #list == 0 then return nil end
    if #list == 1 then return list[1] end
    if #list == 2 then return list[1] .. ' i ' .. list[2] end
    if #list >= 4 then return list[1] .. ' et al.' end
    local last = table.remove(list)
    return table.concat(list, ', ') .. ' i ' .. last
end
function p.citeref_key(authors, year)
    local key = table.concat(authors, '')
    if year then
        key = key .. year
    end
    return key
end


-- Trim whitespace
-- Trim whitespace

Inačica od 12. siječanj 2026. u 10:13

Script error: The function "nonexistent" does not exist.

-- Modul:Citation/CS1/Utilities
-- Minimalna verzija kompatibilna s hrvatskim CS1 modulom

local p = {}

function p.format_authors(list)
    if #list == 0 then return nil end
    if #list == 1 then return list[1] end
    if #list == 2 then return list[1] .. ' i ' .. list[2] end
    if #list >= 4 then return list[1] .. ' et al.' end

    local last = table.remove(list)
    return table.concat(list, ', ') .. ' i ' .. last
end

function p.citeref_key(authors, year)
    local key = table.concat(authors, '')
    if year then
        key = key .. year
    end
    return key
end

-- Trim whitespace
function p.trim(s)
    if not s then return nil end
    return mw.text.trim(s)
end

-- Provjera je li vrijednost postavljena
function p.is_set(v)
    return v ~= nil and mw.text.trim(v) ~= ""
end

-- Formatiranje liste s razmacima
function p.join(parts, sep)
    sep = sep or " "
    local out = {}
    for _, v in ipairs(parts) do
        if p.is_set(v) then
            table.insert(out, v)
        end
    end
    return table.concat(out, sep)
end

-- Jednostavne poruke o greškama
function p.error_message(msg)
    return '<span class="citation-error" style="color:#b00;">' .. msg .. '</span>'
end

return p