La documentation pour ce module peut être créée à Module:Citation/Documentation

local p={}

function p.citation(frame)
 
    local args = frame.args
    local NS = mw.title.getCurrentTitle().namespace -- id de l'espace de nom courrant
    local NS_pg = mw.site.namespaces.Page.id -- id de l'espace de nom « Page »
    
    local align
    if args[2] == nil then
    	align = 'center'
	else
		align = string.lower(args[2])
		if align == 'left' or align == 'gauche' then
			align = 'left'
		elseif align == 'right' or align == 'droite' then
			align = 'right'
		elseif align == 'justify' or align == 'justifié' then
			align = 'justify'
		else align = 'center'
		end
	end
	-- 
 	local larg
 	-- par défaut 0
 	if args[3] == nil then
  		larg = 0
  	-- ou prend la valeur fournit
  	elseif type(args[3]) == 'number' then
  	 	larg = args[3].."em"
   	else 
   		local temp
   		larg,temp = string.gsub(args[3], "em","") -- cas ou le format est fournit en string
   		larg = tonumber(larg)
   		if larg == nill then
   			larg = 0
   		else
   			larg = larg.."em"
   		end
   	end

     -- Produit la boîte div
     -- Dans l'espace principal, on permet la contiuité d'une citation sur deux pages
     local div_ = '<div style="font-size:90%;margin:5%;padding:0 '..larg..'; text-align:'..align..'">'
     local _div = '</div>'
     if NS == NS_pg then
     	return table.concat({div_, args[1], _div})
     else
     	-- si début de citation, on laisse la balise ouverte
     	if args[4] and string.lower(args[4]) == 'd' then
     		return table.concat({div_, args[1]})
     	-- si fin de citation, on ferme la balise
     	elseif args[4] and string.lower(args[4]) == 'f' then
     		return table.concat({args[1], _div})
 		-- dans les autres cas ouvre et ferme la balise
 		else
 			return table.concat({div_, args[1], _div})
 		end
     end
end

return p