Difference between revisions of "Module:List"

142 bytes added ,  17:42, 23 November 2013
simplify the type-property-checking code
meta>Frietjes
(use nil)
meta>Mr. Stradivarius
(simplify the type-property-checking code)
Line 67: Line 67:
root.css('margin-left', indent .. 'em')
root.css('margin-left', indent .. 'em')
end
end
if args['type'] and not args['type']:match('^%s*[1AaIi]%s*$') then
-- Detect if the type attribute specified by args.type is using an invalid value, and if so try passing it as a list-style-type CSS property.
if not args['list_style_type'] and not args['list-style-type'] then
local listStyleType = args.list_style_type or args['list-style-type']
args['list_style_type'] = args['type']
local listType = args['type']
args['type'] = nil
if listType and not listType:match('^%s*[1AaIi]%s*$') then
if not listStyleType then
listStyleType = listType
listType = nil
end
end
end
end
Line 77: Line 80:
list
list
.attr('start', args.start)
.attr('start', args.start)
.attr('type', args.type)
.attr('type', listType)
.css('list-style-type', args.list_style_type or args['list-style-type'])
.css('list-style-type', listStyleType)
.cssText(args.list_style or args.ul_style or args.ol_style) -- ul_style and ol_style are included for backwards compatibility. No distinction is made for ordered or unordered lists.
.cssText(args.list_style or args.ul_style or args.ol_style) -- ul_style and ol_style are included for backwards compatibility. No distinction is made for ordered or unordered lists.
.wikitext(table.concat(listItems))
.wikitext(table.concat(listItems))
Anonymous user