Moduł:Style

Z Wikibooks, biblioteki wolnych podręczników.
 Dokumentacja modułu [stwórz] [odśwież]
local sopcje = 
{
kap = 'font-variant:small-caps;',
center = 'margin-left:auto;margin-right:auto;',
table = 'display:table;',
c = 'text-align:center;',
lc = 'text-transform:lowercase;',
uc = 'text-transform:uppercase;',
cap = 'text-transform:capitalize;',
sm = 'font-size:smaller;',
roz = 'letter-spacing:0.15em;',
u = 'text-decoration:underline;',
b = 'font-weight: bold;',
i = 'font-style: italic;',
s = 'text-decoration: line-through;',
}

local sparam = 
{
w = 'font-size:%s;',
font = 'font-family:%s;',
kol = 'color:%s;',
h = 'line-height:%s;',
roz = 'letter-spacing:%s;',
width = 'width:%s;',
maxwidth = 'max-width:%s;',
align = 'text-align:%s;',
last = 'text-align-last:%s;-moz-text-align-last:%s;',
przed = 'margin-top:%s;',
po = 'margin-bottom:%s;',
lewy = 'margin-left:%s;',
prawy = 'margin-right:%s;',
wci = 'text-indent:%s;',
wys = 'padding-left:%s;text-indent:-%s;',
style = '%s;',
}

function sformat( frame )
	local args = frame.args
	local wynik = ""
	for k,v in pairs(args) do
		if type( k ) == "number" and k > 1 and sopcje[v] ~= nil then
			wynik = wynik .. sopcje[v]
		elseif type( k ) == "string" and sparam[k] ~= nil and v ~= nil  then
			wynik = wynik .. string.format(sparam[k], v, v, v)
		end
	end
	return wynik
end

local p = {}
function p.styl( frame )
    return  sformat( frame:getParent() )
end
return p