Module:ILLArchiveList

--Outputs a list of ILL request archive pages, for use in Template:PILL header/archives --Lua by Bryght --DPL by Sophie with help from SuperDragon local p = {}

function p.main(frame) local numberOfRows = 2 local dpl = mw.getCurrentFrame:preprocess([=[]=]) local pages = mw.text.split(mw.text.trim(dpl), '\n') local total = #pages -- In case the number of archives isn't exactly divisible by the number of rows, -- add one extra archive for `archives % rows` initial rows local baseItemsPerRow = math.floor(total / numberOfRows) local rowsWithExtraItems = total % numberOfRows local lastEndIndex = 0 local row_data = {} for i = 1, numberOfRows do   	local startIndex = lastEndIndex + 1 local endIndex = startIndex + baseItemsPerRow if i > rowsWithExtraItems then endIndex = endIndex - 1 end row_data[i] = table.concat(pages, ', ', startIndex, endIndex) lastEndIndex = endIndex end return table.concat(row_data, ', ') end

return p