Module:Util

-- util local p = {}

function p.nowrap(text) return ' ' .. text .. ' ' end

function p.escape(link) link = link or '' -- because of gsub not letting you have - unescaped link = string.gsub(link,'%-','%%%-') link = string.gsub(link,'%(','%%%(') link = string.gsub(link,'%)','%%%)') link = string.gsub(link,'%+','%%%+') return link end

function p.serializeNumber(N) local chr = tostring(N):sub(-1) local lookup = { ['1'] = 'st', ['2'] = 'nd', ['3'] = 'rd' } return N .. (lookup[chr] or 'th') end

-- given a table of images, links, and sizes, return a table of formatted images function p.linkedImages(images, links, sizes) local tbl = {} for k, v in ipairs(images) do		tbl[k] = string.format(,			v,			links and links[k] or ,			sizes and sizes[k] or ''		) end return tbl end

return p