Module:Sandbox/Qwerfjkl/MultiTPV explained

local p = local escape = require("Module:String")._escapePatternfunction trimspaces(s) return string.gsub(s, "^%s*(.-)%s*$", "%1")end

local function getTitle(title) local success, titleObj = pcall(mw.title.new, title) if success then return titleObj else return nil endend

function p.main(frame) local args = require('Module:Arguments').getArgs(frame,) local template = for index = 1, #args do if string.match(args[index], 'pattern%d') then table.insert(templates, escape(args[index])) end end

local parameter = escape(args[4]) local numberedParameter = (tonumber(parameter) ~= nil) local templateCount = 0 local parameterCount = 0 local pipemarker = '~_~TPVPIPEMARKER~_~' local templateMatch = tonumber(args[3] or 1) local parameterMatch = tonumber(args[5] or 1)*(numberedParameter and parameter or 1) local targettitle = getTitle(args[1]) if targettitle

nil then return "" end local content = string.gsub(targettitle:getContent or "", "[\r\n]", "") -- Escape some pipes content = string.gsub(content, '(%[%[[^%[{}]*)|([^%[%]]*%]%])', '%1' .. pipemarker ..'%2') while templateCount ~= templateMatch do if content

nil then return "" end -- for index = content = string.match(content, '[^|}]*)|') or string.match(content, '([^|}]+)') content = string.gsub(content, pipemarker, '|') content = frame:preprocess content = trimspaces(content) return contentend

return p