Module:Citation
De Nefald
Autres actions
La documentation pour ce module peut être créée à Module:Citation/doc
local p = {}
function p.main(frame)
local args = frame:getParent().args
-- Récupération des paramètres
local author = args.auteur or args.author or ""
local title = args.titre or args.title or ""
local url = args.url or ""
local site = args.site or args.website or ""
local date = args.date or ""
local accessdate = args["date-accès"] or args.accessdate or ""
local quote = args.citation or args.quote or ""
local publisher = args.editeur or args.publisher or ""
local language = args.langue or args.language or ""
-- Construction de la citation
local citation = {}
-- Auteur
if author ~= "" then
table.insert(citation, author)
end
-- Titre (avec lien si URL fournie)
if title ~= "" then
if url ~= "" then
table.insert(citation, '[' .. url .. ' "' .. title .. '"]')
else
table.insert(citation, '« ' .. title .. ' »')
end
end
-- Site/Éditeur
if site ~= "" then
table.insert(citation, "sur ''" .. site .. "''")
elseif publisher ~= "" then
table.insert(citation, publisher)
end
-- Date
if date ~= "" then
table.insert(citation, date)
end
-- Date d'accès
if accessdate ~= "" then
table.insert(citation, '(consulté le ' .. accessdate .. ')')
end
-- Langue
if language ~= "" and language ~= "fr" then
table.insert(citation, '(' .. language .. ')')
end
-- Citation textuelle
if quote ~= "" then
table.insert(citation, ': « ' .. quote .. ' »')
end
-- Assemblage final
local result = table.concat(citation, ', ')
-- Ajout de la ponctuation finale si absente
if not result:match('[.!?]$') then
result = result .. '.'
end
return '<span class="citation">' .. result .. '</span>'
end
return p