Module:CorrespondingPageBox

local util = require('Module:Util')

local p = {}

function p.makeBox(data) local title = mw.title.getCurrentTitle.prefixedText local links = {} for k, v in ipairs(data.replace) do		link = data.targetpage and data.targetpage[k] or string.gsub(title,			util.escape(data.find[k] or data.find[1]),			util.escape(data.replace[k])) display = data.display and data.display[k] or string.format('View the corresponding %s page',(data.tournament and data.tournament[k] or '')) links[k] = string.format('%s', link, display) end local tbl = mw.html.create('div'):addClass('correspondingpagebox') tbl:wikitext(table.concat(links,' | ')) return tostring(tbl) end

function p.main(frame) if frame == mw.getCurrentFrame then args = require('Module:ProcessArgs').merge(true) else frame = mw.getCurrentFrame end local sep = args.sep or ',' for k, v in pairs(args) do		args[k] = mw.text.split(args[k],sep) for k2, v2 in ipairs(args[k]) do			args[k][k2] = mw.text.trim(v2) end end return p.makeBox(args) end return p