Modul:Citation/CS1/Utilities: razlika između inačica
Prijeđi na navigaciju
Prijeđi na pretraživanje
Stvorena nova stranica sa sadržajem: » local z = { error_categories = {}; -- for categorizing citations that contain errors error_ids = {}; message_tail = {}; maintenance_cats = {}; -- for categorizing citations that aren't erroneous per se, but could use a little work properties_cats = {}; -- for categorizing citations based on certain properties, language of source for instance }; --[[--------------------------< F O R W A R D D E C L A...«. |
mNema sažetka uređivanja |
||
| Nisu prikazane 2 međuinačice | |||
| Redak 1: | Redak 1: | ||
-- 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 | local last = table.remove(list) | ||
return table.concat(list, ', ') .. ' i ' .. last | |||
end | end | ||
function p.citeref_key(authors, year) | |||
local key = '' | |||
if type(authors) == 'table' then | |||
key = table.concat(authors, '') | |||
elseif type(authors) == 'string' then | |||
key = authors | |||
end | |||
if year then | |||
key = key .. tostring(year) | |||
end | |||
return key | |||
end | end | ||
-- | -- Trim whitespace | ||
function p.trim(s) | |||
if not s then return nil end | |||
return mw.text.trim(s) | |||
end | end | ||
-- Provjera je li vrijednost postavljena | |||
function p.is_set(v) | |||
return v ~= nil and mw.text.trim(v) ~= "" | |||
end | 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 | end | ||
-- Jednostavne poruke o greškama | |||
function p.error_message(msg) | |||
return '<span class="citation-error" style="color:#b00;">' .. msg .. '</span>' | |||
end | end | ||
return p | |||
Posljednja izmjena od 12. siječanj 2026. u 10:16
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 = ''
if type(authors) == 'table' then
key = table.concat(authors, '')
elseif type(authors) == 'string' then
key = authors
end
if year then
key = key .. tostring(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