Module:DPLUtil

From The Vault - Fallout Wiki
Jump to: navigation, search

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


local m_text = require('Module:Text')
local lang = mw.getLanguage('en')
local p = {}

function p.escape(link)
	link = link or ''
	link = string.gsub(link,'%(','\\%(')
	link = string.gsub(link,'%)','\\%)')
	link = string.gsub(link,'%+','\\%+')
	return link
end

function p.whichPagesExist(links, frame)
	if not frame then frame = mw.getCurrentFrame() end
	for k, link in ipairs(links) do
		links[k] = lang:ucfirst(p.escape(link))
	end
	newlinks = frame:callParserFunction{
		name = '#dpl:',
		args = {
			'',
			titleregexp = table.concat(links,'|'),
			format = ',%PAGE%,;,',
			namespace = '',
			debug = 0,
		}
	}
	newlinks = newlinks .. mw.title.getCurrentTitle().text
	return m_text.split(newlinks,';')
end

return p