Module:Sandbox/Bradv/Case

This is an old revision of this page, as edited by Bradv (talk | contribs) at 21:04, 4 December 2020 (.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
local p = {}

local sub = mw.ustring.sub
local find = mw.ustring.find
local gmatch = mw.ustring.gmatch
local trim = mw.text.trim

local function _decision( case )
	local page = 'Wikipedia:Arbitration/Requests/Case/' .. case
	local pagecontent = mw.title.new(page):getContent()
	local fdstart = find(pagecontent, '\n=Final decision')
	local fd = sub(pagecontent, fdstart)
	local result = {}
	local re = '\n==(.-)=='
	for str in gmatch(fd, re) do
		if find(str, '^Enforcement') then
			break
		end
		if find(str, '^=') then
			s = trim(sub(str, 2))
			table.insert(result, '[[' .. page .. '#' .. s .. '|' .. s .. ']]')
		else
			table.insert(result, "'''" .. str .. "'''")
		end
	end
	local output = table.concat(result, '\n')
	mw.log(output)
	return output
end

function p.decision( frame )
	local case = frame.args[1] or frame.args.case
	return _decision( case )
end

return p