更多操作
此模块的文档可以在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 header_styles = string.format(
'background-color: %s; border-left: %s solid %s; padding-left: %s; margin-bottom: 10px; color: %s; border-bottom: %s;',
bgcolor, border_left, color, padding_left, color, border_bottom ~= '0' and border_bottom .. ' solid ' .. color or 'none'
)
return string.format(
'<%s style="%s">%s</%s>',
header, header_styles, text, header
)
end
return p