Module:Book

-- -- Module:Book -- A module for automatically putting the pages of a book into a Tabber. -- Noreplyz

local Book = {} local getArgs = require('Dev:Arguments').getArgs

-- Get the code for a single (left and right) page function Book.createPage(left, right) return ' ' .. ' ' ..          left .. ' ' ..          ' ' ..           right .. ' ' end

-- Get the code for the whole book function Book.createBook(args) local ret = {} local left = '' local right = '' local i = 1 while args[i] ~= nil do       if i % 2 == 1 then left = args[i] if args[i + 1] == nil then ret[#ret + 1] = '|-|' .. (i+1)/2 .. '='               ret[#ret + 1] = Book.createPage(left, '') ret[#ret + 1] = '\n' end else right = args[i] ret[#ret + 1] = '|-|' .. i/2 .. '='           ret[#ret + 1] = Book.createPage(left, right) ret[#ret + 1] = '\n' left = '' end i = i + 1 end return table.concat(ret) end

-- entry to create a book function Book.create(frame) local args = getArgs(frame) return Book.createBook(args) end

return Book --