Module:List: Difference between revisions

Jump to navigation Jump to search
m>Mr. Stradivarius
Create modified version of Module:Bulleted list. The code is by myself and User:Frietjes.
 
m>Mr. Stradivarius
add support for start and type attributes in ordered lists
Line 83: Line 83:
return ''
return ''
end
end
-- Check if we need a ul tag or an ol tag.
-- Check if we need a ul tag or an ol tag, and get the start and type attributes for ordered lists.
local listTag = 'ul'
local listTag = 'ul'
local startAttr, typeAttr
if listType == 'numbered' then
if listType == 'numbered' then
listTag = 'ol'
listTag = 'ol'
startAttr = args.start
if startAttr then
startAttr = ' start="' .. startAttr .. '"'
end
typeAttr = args.type
if typeAttr then
typeAttr = ' type="' .. typeAttr .. '"'
end
end
end
startAttr = startAttr or ''
typeAttr = typeAttr or ''
-- Get the classes and styles and output the list.
-- Get the classes and styles and output the list.
local class = getClass(listType, args.class) or ''
local class = getClass(listType, args.class) or ''
Line 94: Line 105:
list_style = list_style and (' style="' .. list_style .. '"') or ''
list_style = list_style and (' style="' .. list_style .. '"') or ''
return mw.ustring.format(
return mw.ustring.format(
'<div%s%s><%s%s>%s</%s></div>',
'<div%s%s><%s%s%s%s>%s</%s></div>',
class, style, listTag, list_style, table.concat(listItems), listTag
class, style, listTag, startAttr, typeAttr, list_style, table.concat(listItems), listTag
)
)
end
end