Module:Logoform: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
m test |
m test |
||
Line 6: | Line 6: | ||
local file = 'F' -- assume file |
local file = 'F' -- assume file |
||
local size = gpar[2] or '0' |
local size = gpar[2] or '0' |
||
local styl = ';'..gpar[3] or '-' |
|||
local stab = {} |
local stab = {} |
||
if mw.ustring.sub(size, -2) == 'px' then |
if mw.ustring.sub(size, -2) == 'px' then |
||
Line 20: | Line 21: | ||
gpar[1] = mw.ustring.sub( gpar[1], 4 ) |
gpar[1] = mw.ustring.sub( gpar[1], 4 ) |
||
end |
end |
||
if styl == ';-' then styl = ';' end |
|||
if size ~= '0' then |
if size ~= '0' then |
||
stab = mw.text.split( size, 'x' ) |
stab = mw.text.split( size, 'x' ) |
||
Line 37: | Line 39: | ||
return '[[File:'..gpar[1]..'|'..size..'px]]' |
return '[[File:'..gpar[1]..'|'..size..'px]]' |
||
else |
else |
||
return '<span style="font-size:'..size..'px;vertical-align:middle">'..gpar[1]..'</span>' |
return '<span style="font-size:'..size..'px;vertical-align:middle'..styl..'">'..gpar[1]..'</span>' |
||
end |
end |
||
-- return file..':<nowiki>'..gpar[1]..'</nowiki> '..size |
-- return file..':<nowiki>'..gpar[1]..'</nowiki> '..size |
Revision as of 08:19, 1 February 2021
Lua
CodeDiscussionEditHistoryLinksLink count Subpages:DocumentationTestsResultsSandboxLive code All modules
- global function "format"
is invoked from e.g. Created with/layout when
- either the name of the
logo
starts with U+ or &# - and/or an
iconsize
is specified.
- analize
logo
: when it contains a dot, it cannot be a codepoint
no further checks are performed whether is is a valid file name, e.g. "U+2861.svg";
without a dot it is assumed to be a codepoint, as e.g. ⡡
no further checks are performed whether is is a valid codepoint,
but the notation U+ is converted to &#x... and the display becomes tooltipped - analize
iconsize
: when it is missing, useful defaults are set: 33px for Unicode, 36x22px for files
when it is specified, the absence/presence of thepx
dimension is verified - either the file, or the codepoint is displayed
With other file names and no iconsize, no invocation occurs
Code
local p = {} -- test
function p.fpoint (frame)
local gpar = frame.args -- global
local file = 'F' -- assume file
local size = gpar[2] or '0'
local styl = ';'..gpar[3] or '-'
local stab = {}
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
gpar[1] = mw.ustring.gsub( gpar[1]..';', 'U%+', '&#x' ),_
end
if mw.ustring.sub( gpar[1], 1, 3 ) == '&#;' then
gpar[1] = mw.ustring.sub( gpar[1], 4 )
end
if styl == ';-' then styl = ';' end
if size ~= '0' then
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]]'
else
return '<span style="font-size:'..size..'px;vertical-align:middle'..styl..'">'..gpar[1]..'</span>'
end
-- return file..':<nowiki>'..gpar[1]..'</nowiki> '..size
end -- function fpoint
return p