We've Moved! Just as Gamepedia has joined forces with Fandom, this wiki had joined forces with our Fandom equivalent. The wiki has been archived and we ask that readers and editors move to the now combined wiki on Fandom. Click to go to the new wiki.


From The Vault - Fallout Wiki
Revision as of 11:01, 18 September 2018 by RheingoldRiver (talk | contribs) (Protected "Module:Util": Syncing content across wikis ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

To edit the documentation or categories for this module, click here.

-- util
local p = {}

function p.nowrap(text)
	return '<span style="white-space:nowrap;">' .. text .. '</span>'

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

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

-- 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('[[File:%s|link=%s|%s]]',
			links and links[k] or '',
			sizes and sizes[k] or ''
	return tbl

return p