From Wikipedia, the free encyclopedia
This module is rated as beta . It is considered ready for widespread use, but as it is still relatively new, it should be applied with some caution to ensure results are as expected.
This module depends on the following other modules:
Implements {{ Anchored list }} and {{ Bare anchored list }} . The only function is generate , which accepts the following parameters:
| bare = – Whether to include a prefix to the anchor IDs.
| name = – Unique name for the anchors, to avoid duplicate IDs.
| style = – CSS styling to apply to the list.
An infinite amount of consecutive unnamed parameters, the list's entries.
local yesno = require ( 'Module:Yesno' )
local getArgs = require ( 'Module:Arguments' ). getArgs
local p = {}
-- Argument handling
function p . generate ( frame )
local args = getArgs ( frame )
return p . _generate ( args )
end
-- Actual function
function p . _generate ( args )
local _style = ''
if not ( args . style == '' or args . style == nil ) then
_style = ' style="' .. args . style .. '"'
end
local output = '<ol' .. _style .. '>'
for i , item in ipairs ( args ) do
if item ~= '' and not yesno ( args . bare ) then
output = output .. '<li ' .. _style .. 'id="alist' .. ( args . name or '' ) .. '-' .. i .. '">' .. item .. '</li>'
elseif item ~= '' and yesno ( args . bare ) then
output = output .. '<li ' .. _style .. 'id="' .. i .. '">' .. item .. '</li>'
end
end
return output .. '</ol>'
end
return p