This wiki is in a testing phase! I'm currently rolling out the wiki in an early state to see if the software works statically. If you want to make changes or something has gone wrong, please post an issue on the GitHub repository.

Module:File

From the Aadenboy Wiki
Jump to navigation

Documentation for this module may be created at Module:File/doc

local p = {}

function escape(s)
	return s:gsub("[%[%]%(%)%+%-%*%?%$%^%%]", "%%%0")
end

function p.involvedFormat(frame)
	local involved = frame.args[1] or ""
	involved = involved:gsub("([^%[%]\n:]+):", "[[%1]]:"):gsub("%[%[([^\n|%]]+)(|?[^\n%]]-)%]%]:", "[[%1%2]]:[[Category:Involves %1]]"):gsub("\n", "<br/>")
	return involved
end

function p.fetchInvolvement(frame)
	local involved = frame.args[1] or ""
	local target = escape(frame.args[2] or "")
	return involved:match(target..":([^\n]+)") or involved:match("%[%["..target.."|?[^\n%]]-%]%]:([^\n]+)") or ""
end

return p