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

Contenido eliminado Contenido añadido
hago que algunas de las funciones puedan llamarse desde una plantilla
función para mayúsculas
Línea 9:
end
 
-- Adaptado de [[:en:Module:String2]], función sentence
function z.enMayusculas(texto)
if not texto or texto == '' then
return texto
end
return texto and '<span style="font-variant:small-caps">' .. texto .. '</span>'
-- [[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) .. string.lower(rest)
else
return texto
end
end