Module:Odl
Builds an ordered definition list. Something like <ol><li><dl><dt>Header</dt><dd>Text</dd></dl></li></ol>, which turns out to be
- Header
- Text
local get_gna_fn = function ( tbl )
local ix = 1
return function ()
local arg = tbl[ix]
if arg ~= nil then
ix = ix + 1
end
return arg
end
end
local ordered_definition_list = function ( things )
local get_next_thing = get_gna_fn( things )
local strval = '<ol>'
local key, val
local get_next_pair = function ()
local thing = get_next_thing()
if thing ~= nil then
key = thing[1]
val = thing[2]
else
key = nil
val = nil
end
end
get_next_pair()
while key ~= nil and val ~= nil do
strval = strval .. '<li><dl><dt>' .. key .. '</dt><dd>' .. val .. '</dd></dl></li>'
get_next_pair()
end
return strval .. '</ol>'
end
return {
_ordered_definition_list = ordered_definition_list,
build = function ( frame )
local get_next_arg = get_gna_fn( frame.args )
local curarg = get_next_arg()
local list = {}
local curitem
while curarg ~= nil do
table.insert( list, { curarg, get_next_arg() } )
curarg = get_next_arg()
end
return ordered_definition_list( list )
end
}