More actions
Documentation for this module may be created at Module:StyledHeader/doc
local p = {}
function p.customStyles(frame)
local args = frame:getParent().args
local bgcolor = args['bgcolor'] or 'transparent'
local border_left = args['border-left'] or '0'
local color = args['color'] or 'black'
local header = args['header'] or 'h1'
local text = args['text'] or ''
local border_bottom = args['border-bottom'] or '0'
local padding_left = border_left ~= '0' and '10px' or '0px'
local styles = string.format(
'background-color: %s; border-left: %s solid %s; padding-left: %s; margin-bottom: 10px;',
bgcolor, border_left, color, padding_left
)
local header_styles = string.format(
'margin: 0; color: %s; border-bottom: %s;',
color, border_bottom ~= '0' and border_bottom .. ' solid ' .. color or 'none'
)
return string.format(
'<div style="%s"><%s style="%s">%s</%s></div>',
styles, header, header_styles, text, header
)
end
return p