Módulo:Formato texto

De borradopedia
Ir a la navegación Ir a la búsqueda

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

Error de secuencia de órdenes: Error de Lua: Error interno: El intérprete ha finalizado con la señal "-129".

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

-- Adaptado de [[:en:Module:String2]], función sentence
function z.enMayusculas(texto)
	if not texto or texto == '' then
		return texto
	end
	
	-- [[hipótesis (método científico)|hipótesis]]
	
	if texto:find("^%[%[[^|]+|[^%]]+%]%]") then
		local b, c = texto:find("|%A*%a") 
		return string.sub(texto, 1, c-1) .. string.upper(string.sub(texto, c, c)) .. string.sub(texto, c+1)
	end
	
	local letterpos = texto:find('%a')
	if letterpos then
		local first = texto:sub(1, letterpos - 1)
		local letter = texto:sub(letterpos, letterpos)
		local rest = texto:sub(letterpos + 1)
		return first .. string.upper(letter) .. rest
	else
		return texto
	end
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 resultado
	local copia={}
	require('Módulo:Tablas').insertarElementosConValor(lista, copia)
	
	-- Solo devolver algo si hay al menos un elemento
	if copia[1] then
		return table.concat(copia, '<br/>')
	end
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