Module:Logoform
Jump to navigation
Jump to search
Documentation for this module may be created at Module:Logoform/doc
local p = {} -- Module for: Formatting Logo
function p.format (frame)
local gpar = frame.args -- global
local file = 'F' -- assume file
local size = gpar[2] or '0' -- "0" for "unspecified"
local styl = ';'..gpar[3] or '-' -- "unspecified"
local titl = '">' -- no title
if mw.ustring.sub(size, -2) == 'px' then
size = mw.ustring.sub(size, 1, #size-2 )
end
if not mw.ustring.find( gpar[1], '.', 1, true ) then
if mw.ustring.sub ( gpar[1], 1, 2 ) == 'U+' or
mw.ustring.sub ( gpar[1], 1, 2 ) == '&#' then
file = 'U'
if mw.ustring.sub( gpar[1], 1, 2 ) == 'U+' then -- standardize:
titl = '" title='..gpar[1]..'>'
gpar[1] = mw.ustring.gsub( gpar[1]..';', 'U%+', '&#x' ),_
elseif
mw.ustring.sub( gpar[1], 1, 3 ) == '&#;' then -- textstring:
gpar[1] = mw.ustring.sub( gpar[1], 4 )
end
if styl == ';-' then styl = ';' end -- not specified
if size ~= '0' then
local stab = mw.text.split( size, 'x' )
size = stab[1]
if stab[2] then size = stab[2] end -- height
else
size = '33' -- Unicode default size
end
end
else
if size == '0' then
size = '36x22' -- File default size
end
end
if file == 'F' then
return '[[File:'..gpar[1]..'|'..size..'px]]' -- allow linking
else
return '<span style="font-size:'..size..'px;vertical-align:middle'..styl..titl..gpar[1]..'</span>'
end
end -- function format
return p