Diferencia entre revisiones de «Módulo:Formato texto»

De Hispanopedia
función para llamar desde una plantilla
hago que algunas de las funciones puedan llamarse desde una plantilla
Línea 1: Línea 1:
local z = {}
local z = {}


function z.entreComillas(texto, ref)
function z.enCursivas(texto, ref)
if ref and texto then
if ref and texto then
return '«' .. texto .. '»' .. ref
return '<i>' .. texto .. '</i>' .. ref
elseif texto then
elseif texto then
    return '«' .. texto .. '»'
    return '<i>' .. texto .. '</i>'
end
end
end
end


function z.entreParentesis(texto, calificativo)
function z.enMayusculas(texto)
if texto and calificativo then
if not texto or texto == '' then
    return texto .. ' (' .. calificativo .. ')'
else
return texto
return texto
end
end
end
return texto and '<span style="font-variant:small-caps">' .. texto .. '</span>'
 
function z.enCursivas(texto, ref)
if ref and texto then
return '<i>' .. texto .. '</i>' .. ref
elseif texto then
    return '<i>' .. texto .. '</i>'
end
end
end


function z.enVersalitas(texto)
function z.enVersalitas(texto)
return texto and '<span style="font-variant:small-caps">' .. texto .. '</span>'
if not texto or texto == '' then
return texto
end
return '<span style="font-variant:small-caps">' .. texto .. '</span>'
end
end


Línea 34: Línea 28:
return table.concat(copia, '<br/>')
return table.concat(copia, '<br/>')
end
function z.entreComillas(texto, ref)
if not texto or texto == '' then
return texto
elseif ref and ref ~='' then
return '«' .. texto .. '»' .. ref
else
    return '«' .. texto .. '»'
end
end
function z.entreParentesis(texto, calificativo)
if not texto or texto == '' then
return
elseif calificativo and calificativo ~= '' then
    return texto .. ' (' .. calificativo .. ')'
else
return texto
end
end
end



Revisión del 20:14 1 mar 2017

La documentación para este módulo puede ser creada en Módulo:Formato texto/doc

local z = {}

function z.enCursivas(texto, ref)
	if ref and texto then
		return '<i>' .. texto .. '</i>' .. ref
	elseif texto then
	    return '<i>' .. texto .. '</i>'
	end
end

function z.enMayusculas(texto)
	if not texto or texto == '' then
		return texto
	end
	return texto and '<span style="font-variant:small-caps">' .. texto .. '</span>'
end

function z.enVersalitas(texto)
	if not texto or texto == '' then
		return texto
	end	
	return '<span style="font-variant:small-caps">' .. texto .. '</span>'
end

function z.enVariasLineas(lista)
	local copia={}
	require('Módulo:Tablas').insertarElementosConValor(lista, copia)
	
	return table.concat(copia, '<br/>')
end

function z.entreComillas(texto, ref)
	if not texto or texto == '' then
		return texto
	elseif ref and ref ~='' then
		return '«' .. texto .. '»' .. ref
	else 
	    return '«' .. texto .. '»'
	end
end

function z.entreParentesis(texto, calificativo)
	if not texto or texto == '' then
		return
	elseif calificativo and calificativo ~= '' then
	    return texto .. ' (' .. calificativo .. ')'
	else
		return texto
	end
end

function z.separadosPorComa(lista)
	local copia={}
	require('Módulo:Tablas').insertarElementosConValor(lista, copia)
	
	return table.concat(copia, ', ')
end

function z.enlazar(enlace, texto, calificativo)
	local resultado 
	
	if enlace and texto then
		resultado = '[[' .. enlace .. '|' .. texto .. ']]'
	elseif enlace then
		resultado = '[[' .. enlace .. ']]'
	else
		resultado = texto
	end
	
	if resultado and calificativo then
		return resultado .. ' <small>(' .. calificativo .. ')</small>'
	else
		return resultado
	end
end

function z.llamadaDesdeUnaPlantilla(frame)
	local args = frame.args
	
	if args['tipo argumento'] == 'tabla' then
		local tabla = {args[2], args[3], args[4]}
		return z[args[1]](tabla)
	else
		return z[args[1]](args[2], args[3], args[4])
	end
end

return z