Module:Dotted TOC page listing

-- Warning: This must be considered a draft version for discussion and improvement.           It is certainly currently not suitable for serious use.           Please consider amending this note if/when improvements are made.

p = {}; --[[ dtpl Main entry point for Lua function to emulate existing template. Usage:

- is functionally equivalent to (but less efficient than): An additional parameter (typically |debug=yes) may be used in this version to produce various internal working state displays. It should probably be removed at once (as it has already served its purpose) and reistated at need.. ]] function p.dtpl(frame) local debug = '{| border style="border-collapse:collapse;"\n|+Debugging: Arguments' if frame.args[1] ~= nil then debug=debug..'\n|-\n|frame.args[1]||'..frame.args[1] end if frame.args[2] ~= nil then debug=debug..'\n|-\n|frame.args[2]||'..frame.args[2] end if frame.args[3] ~= nil then debug=debug..'\n|-\n|frame.args[3]||'..frame.args[3] end if frame.args[4] ~= nil then debug=debug..'\n|-\n|frame.args[4]||'..frame.args[4] end if frame.args['chapteralign'] ~= nil then debug=debug..'\n|-\n|frame.args[\'chapteralign\']||'..frame.args['chapteralign'] end if frame.args['chaptertext'] ~= nil then debug=debug..'\n|-\n|frame.args[\'chaptertext\']||'..frame.args['chaptertext'] end if frame.args['chapterwidth'] ~= nil then debug=debug..'\n|-\n|frame.args[\'chapterwidth\']||'..frame.args['chapterwidth'] end if frame.args['col3align'] ~= nil then debug=debug..'\n|-\n|frame.args[\'col3align\']||'..frame.args['col3align'] end if frame.args['col3width'] ~= nil then debug=debug..'\n|-\n|frame.args[\'col3width\']||'..frame.args['col3width'] end if frame.args['col4align'] ~= nil then debug=debug..'\n|-\n|frame.args[\'col4align\']||'..frame.args['col4align'] end if frame.args['col4text'] ~= nil then debug=debug..'\n|-\n|frame.args[\'col4text\']||'..frame.args['col4text'] end if frame.args['col4width'] ~= nil then debug=debug..'\n|-\n|frame.args[\'col4width\']||'..frame.args['col4width'] end if frame.args['debug'] ~= nil then debug=debug..'\n|-\n|frame.args[\'debug\']||'..frame.args['debug'] end if frame.args['dottext'] ~= nil then debug=debug..'\n|-\n|frame.args[\'dottext\']||'..frame.args['dottext'] end if frame.args['entryalign'] ~= nil then debug=debug..'\n|-\n|frame.args[\'entryalign\']||'..frame.args['entryalign'] end if frame.args['entrytext'] ~= nil then debug=debug..'\n|-\n|frame.args[\'entrytext\']||'..frame.args['entrytext'] end if frame.args['entrywidth'] ~= nil then debug=debug..'\n|-\n|frame.args[\'entrywidth\']||'..frame.args['entrywidth'] end if frame.args['hi'] ~= nil then debug=debug..'\n|-\n|frame.args[\'hi\']||'..frame.args['hi'] end if frame.args['leadlen'] ~= nil then debug=debug..'\n|-\n|frame.args[\'leadlen\']||'..frame.args['leadlen'] end if frame.args['pagetext'] ~= nil then debug=debug..'\n|-\n|frame.args[\'pagetext\']||'..frame.args['pagetext'] end if frame.args['spaces'] ~= nil then debug=debug..'\n|-\n|frame.args[\'spaces\']||'..frame.args['spaces'] end if frame.args['symbol'] ~= nil then debug=debug..'\n|-\n|frame.args[\'symbol\']||'..frame.args['symbol'] end debug=debug..'\n|}\n' local chapteralign = frame.args['chapteralign'] or 'right' local chaptertext = frame.args['chaptertext'] or frame.args[1] or '' local chapterwidth = frame.args['chapterwidth'] or '2.5em' local col3align = frame.args['col3align'] or 'right' local col3width = frame.args['col3width'] or '2em' local col4align = frame.args['col4align'] or 'right' local col4text = frame.args['col4text'] or '' local col4width = frame.args['col4width'] or '2em' local dottext = frame.args['dottext'] or '' local entryalign = frame.args['entryalign'] or 'left' local entrytext = frame.args['entrytext'] or frame.args[2] or 'Entry text' local entrywidth = frame.args['entrywidth'] or '80%' local hi = frame.args['hi'] or '1em' local leadlen = frame.args['leadlen'] or 256; local pagetext = frame.args[3] or frame.args['pagetext'] or '' local spaces = frame.args['spaces'] or frame.args[4] or 1 local symbol = frame.args['symbol'] or '.'

debug = debug..'{| border style="border-collapse:collapse;"\n|+Debugging: Defaults' debug = debug..'\n|-\n|chapteralign||'..chapteralign debug = debug..'\n|-\n|chaptertext||'..chaptertext debug = debug..'\n|-\n|chapterwidth||'..chapterwidth debug = debug..'\n|-\n|col3align||'..col3align debug = debug..'\n|-\n|col3width||'..col3width debug = debug..'\n|-\n|col4align||'..col4align debug = debug..'\n|-\n|col4text||'..col4text debug = debug..'\n|-\n|col4width||'..col4width debug = debug..'\n|-\n|dottext||'..dottext debug = debug..'\n|-\n|entryalign||'..entryalign debug = debug..'\n|-\n|entrytext||'..entrytext debug = debug..'\n|-\n|entrywidth||'..entrywidth debug = debug..'\n|-\n|hi||'..hi   debug = debug..'\n|-\n|leadlen||'..leadlen debug = debug..'\n|-\n|pagetext||'..pagetext debug = debug..'\n|-\n|spaces||'..spaces debug = debug..'\n|-\n|symbol||'..symbol debug=debug..'\n|}\n' local block = symbol..string.rep('&#160;',spaces) if dottext ==  then dottext = string.rep( block, leadlen/( 1+mw.ustring.len(..spaces) ) )..symbol end debug = debug..'{| border style="border-collapse:collapse;"\n|+Debugging: Progress' debug = debug..'\n|-\n|block||'..block debug = debug..'\n|-\n|dottext||'..dottext debug=debug..'\n|}\n'

local output = '{| style="border-collapse:collapse; border-spacing:0; empty-cells:hide; width:100%;"\n' if chaptertext ~= '' then output = output.. '| style="width:'..           chapterwidth..            ';max-width:'..            chapterwidth..            ';padding:0.0em 0.5em 0.0em 0.0em;vertical-align:top;text-align:'..            chapteralign..            ';" | '.. chaptertext.. '\n' end output = output.. '| '.. entrytext.. ' '.. ' '..       ''.. ' '..       dottext.. '  \n' output = output.. '| style="text-align:'..       col3align..        ';vertical-align:bottom;padding:0.0em 0.0em 0.0em 0.5em;width:'..        col3width..        ';" | '.. pagetext.. '\n' if col4text ~= '' then output = output.. '|| style="text-align:'..           col4align..            ';vertical-align:bottom;width:'..            col4width..            ';padding:0.0em 0.0em 0.0em 0.5em;" | '.. col4text.. '\n' end output = output.. '|}\n'

if frame.args['debug'] == nil then debug='' end return debug..output end

return p