更多操作
无编辑摘要 |
无编辑摘要 |
||
(未显示同一用户的1个中间版本) | |||
第4行: | 第4行: | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
local bgcolor = args['bgcolor'] or 'transparent' | local bgcolor = args['bgcolor'] or 'transparent' | ||
local | local border_left = args['border-left'] or '0' | ||
local color = args['color'] or 'black' | local color = args['color'] or 'black' | ||
local header = args['header'] or 'h1' | local header = args['header'] or 'h1' | ||
local text = args['text'] or '' | local text = args['text'] or '' | ||
local | local border_bottom = args['border-bottom'] or '0' | ||
local padding_left = | local padding_left = border_left ~= '0' and '10px' or '0px' | ||
local header_styles = string.format( | local header_styles = string.format( | ||
'margin: | 'background-color: %s; border-left: %s solid %s; padding-left: %s; margin-bottom: 10px; color: %s; border-bottom: %s;', | ||
color, | bgcolor, border_left, color, padding_left, color, border_bottom ~= '0' and border_bottom .. ' solid ' .. color or 'none' | ||
) | ) | ||
return string.format( | return string.format( | ||
' | '<%s style="%s">%s</%s>', | ||
header, header_styles, text, header | |||
) | ) | ||
end | end | ||
return p | return p |
2024年7月24日 (三) 15:59的最新版本
此模块的文档可以在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