Módulo:Título
Apariencia
[editar] []
Módulo para implementar {{Título}}, la plantilla para simplificar portadas tradicionales de libros
El formato es el que sigue
{{título|ancho=16em|
{+++}NUEVA PLANTILLA
{+} PARA EL USO EN PORTADAS
{-}Y PÁGINAS DE LIBROS SEMEJANTES
{>} Texto a la derecha
{<} Texto a la izquierda
{sc, -}Traída a ustedes para facilidad de la transcripción de portadas sumamente complejas y llenas de texto de diferentes formatos y variedades por el estilo como sangría colgante
{_2}
{asc}Imprenta Tal para cual
{may, sp0.5em}Tahuantinsuyo
{+}2024
{~2}
}}
NUEVA PLANTILLA
PARA EL USO EN PORTADAS
Y PÁGINAS DE LIBROS SEMEJANTES
Texto a la derecha
Texto a la izquierda
Traída a ustedes para facilidad de la transcripción de portadas sumamente complejas y llenas de texto de diferentes formatos y variedades por el estilo como sangría colgante
Imprenta Tal para cual
Tahuantinsuyo
2024
Uso
Esta documentación está transcluida desde Módulo:Título/doc.
Los editores pueden experimentar en la zona de pruebas
Por favor, añade las categorías a la subpágina de documentación.
(subpáginas - enlaces)
Los editores pueden experimentar en la zona de pruebas
Por favor, añade las categorías a la subpágina de documentación.
(subpáginas - enlaces)
-- Modulo para portadas de título y páginas con diseño complejo como esas
require('strict')
local FACTOR = 1.2
local p = {}
local getArgs = require('Módulo:Arguments').getArgs
local function formatdiv(frame, div, style)
local styles = mw.text.split(style, ',')
for _, st in ipairs(styles) do -- loop entre estilos
st = mw.text.trim(st)
local GRANDE = mw.ustring.match(st, '^%++$')
if GRANDE then div:css('font-size',tostring(FACTOR^tonumber(#GRANDE)*100)..'%') end
local CHICO = mw.ustring.match(st, '^%-+$')
if CHICO then div:css('font-size',tostring(FACTOR^tonumber(-#CHICO)*100)..'%') end
local IZQ = mw.ustring.match(st, '^%<$')
if IZQ then div:css('text-align','left') end
local DER = mw.ustring.match(st, '^%>$')
if DER then div:css('text-align','right') end
local LIN = mw.ustring.match(st, '^%_(%d*)$')
if LIN then
if LIN ~= '' then LIN = LIN..'em' end
div:wikitext(frame:expandTemplate{ title = 'línea', args = { LIN } })
end
local WAVE = mw.ustring.match(st, '^%~(%d+)$')
if WAVE then div:wikitext(string.rep("[[Archivo:Rule_Segment_-_Wave_-_40px.svg]]", tonumber(WAVE))) end
local MAY = mw.ustring.match(st, '^may$')
if MAY then div:css('font-variant', 'small-caps') end
local ASC = mw.ustring.match(st, '^asc$')
if ASC then div:css('font-variant', 'all-small-caps') end
local SC = mw.ustring.match(st, '^sc$')
if SC then div:css({['margin-left'] = '1em', ['text-indent'] = '-1em', ['text-align'] = 'justify'}) end
local BD = mw.ustring.match(st, '^bd$')
if BD then div:css({['float'] = 'right', ['text-align'] = 'justify', ['width'] = '50%', ['clear']='both'}) end
local UL = mw.ustring.match(st, '^ul$')
if UL then div:css('text-decoration', 'underline') end
local SP = mw.ustring.match(st, '^sp(.+)$')
if SP then div:css('letter-spacing', SP) end
local ESTILO = mw.ustring.match(st, '^estilo (.+)$')
if ESTILO then div:cssText(ESTILO) end
end
return div
end
local function processdiv(frame, text)
-- PROCESAMIENTO DE LÍNEAS INDIVIDUALES
-- Acá se definirán los estilos a aplicarse a cada línea, separados por ,
-- El formato general será {estilo1, estilo2, estilo3} y podríamos copiar el estándar q se usa en el Módulo:Centrar
--[[ TODO:
4) máquina q convierta palabra (menor, underline) en función
5) exportar esa máquina de vuelta al Módulo:Centrar
]]--
local div = mw.html.create('div')
local components = mw.text.split(text,'[{}]')
if #components == 1 then --caso base, sin formato
if #text == 0 then text = ' ' end --línea en blanco: agregar espacio para q no colapse.
return div:wikitext(text)
elseif #components == 3 then --caso bien formatetado
div = formatdiv(frame, div,components[2])
return div:wikitext(components[3])
else --cualquier otra cosa
return div:wikitext('LÍNEA MAL FORMATEADA'):cssText('color:red;font-weight:bold')
end
end
function p.portada( frame )
local argus = getArgs(frame) -- crea una tabla con los parámetros incluídos en la plantilla, y elimina parámetros vacíos
local html = mw.html.create() -- cuerpo principal de la plantilla
local BIG=html:tag('div'):addClass('ws-titleblock'):cssText('margin:auto;text-align:center;page-break-after:always')
local ancho = argus['ancho'] or 'fit-content' --MEJORAR
local anchomax = argus['anchomax'] or '32em' --MEJORAR
local lineheight = argus['lh'] or '1.6'
if argus['factor'] then FACTOR = tonumber(argus['factor']) end
BIG:css('width',ancho)
BIG:css('max-width', anchomax)
BIG:css('line-height',lineheight)
local texto = argus[1] or ''
local lineas = mw.text.split(texto, '\n')
for i, v in ipairs(lineas) do
local div = processdiv(frame, v)
div:addClass('ws-titleblock-line'..i):css('clear', 'both')
BIG:node(div)
end
return tostring(html)
end
return p