Module:RandomQueue

local p = {}

local function escapePattern(str) return mw.ustring.gsub(str, "([%(%)%.%%%+%-%*%?%[%^%$%]])", "%%%1") end local start = '' local stop = '' local listpatt = escapePattern(start) .. '(.-)' .. escapePattern(stop) local linkpatt = "\"?'?'?%[%[[^%]\n]+%]%]'?'?\"?" local namepatt = "\"?'?'?%[%[([^%]%|\n])+%]%]'?'?\"?"

local function main(list_page) local wikitext = mw.title.new(list_page):getContent local raw_list = mw.ustring.match(wikitext, listpatt) local list = {} for link in mw.ustring.gmatch(raw_list, linkpatt) do       list[#list + 1] = link end math.randomseed(os.time) local num = math.random(1, #list) local name = mw.ustring.gsub(list[num], namepatt, "%%%1") local pagename = list_page .. '/' .. name local pagetext = mw.title.new(pagename):getContent return pagetext end

return p