Module:Index

local Index = {} --- imported libraries -- Parses invocation and template parameters, trims whitespace, and removes blanks. local getArgs = require('Dev:Arguments').getArgs -- Output build string and helper variables local header = '' local content = '' local output = '' -- Separator used between items in the in-line list local sep = ' &bull; '

-- functions for opening and closing indent blocks local function IndentBlockOpen (str) return ' '..str end local function IndentBlock (str) return IndentBlockOpen(str)..' ' end local function DoubleIndentBlock (str) return IndentBlockOpen(IndentBlockOpen(str)) end -- Referenced only header local refonly = ..'Referenced only'.. -- function Index.IndList(frame) -- interprets parameters local args = getArgs(frame) -- calls the internal function that does most of the work -- sends the result back to the template / article return Index._IndList(args) end

function Index._IndList(args) if args['title'] then -- Create div containing title of Index header = IndentBlock(..args['title']..) end if args['index'] then -- Create div containing body of Index (does not close) content = DoubleIndentBlock(args['index']..' ') end if args['ref'] then -- Create reference material for Index if not args['index'] then content = DoubleIndentBlock('') end -- Add div if it wasn't created previously content = content..' '..refonly..' '..args['ref']..' ' end if args['index'] or args['ref'] then -- Close div containing body of Index, if it was opened content = content..' ' end -- Add header and content to output output = header..content -- Change all semicolons to the separator character string output = string.gsub(output, ';', sep) return output end

return Index