Module:Sandbox/pppery/hook page

Module documentation
local p = {}
local function versiontonumber(version)
	if #version == 6 then
		return versiontonumber(version:sub(0,4)) + tonumber(version:sub(6))/1000
	end
	local num = tonumber(version)
	if #version == 3 then
		return 1 + (num-1)/10
	else
		return num
	end
end
function p._main(name)
	local frame = mw.getCurrentFrame()
	local hookPage, hookText
	hookPage = mw.title.new("Manual:Hooks/" .. name)
	hookText = hookPage:getContent()
	if hookText == nil then
		error("Bogus hook: " .. name) 
	end
	local summary = hookText:match("\n%s*|%s*summary%s*=%s*([^\n]*)\n") 
	local introduced = hookText:match("\n%s*|%s*version%s*=%s*([^|\n]-)%.?0?\n")
	local removed = hookText:match("\n%s*|%s*removed%s*=%s*([^|\n]-)%.?0?\n")
	local deprecated = hookText:match("\n%s*|%s*deprecated%s*=%s*([^|\n]-)%.?0?\n")
	if summary then
		local prefix = ""
		if removed and removed ~= "" then
			local num = versiontonumber(removed)
			if num and num < 1.27 then
				return ""
			end
			prefix = "{{removed-inline|" .. tostring(removed) .. "}} "
		elseif deprecated and deprecated ~= "" then
			prefix = "{{deprecated-inline|" .. tostring(deprecated) .. "}} "
		end
		local verstring = tostring(versiontonumber(introduced))
		while #verstring < 5 do
			verstring = verstring .. "0"
		end
		local output = "|-\n|data-sort-value=\"" .. verstring .. "\"| " .. introduced
		output = output .. "\n| {{ll|Manual:Hooks/" .. name .. "|" .. name .. "}}\n|" .. prefix .. summary
		return output
	else
		error("Could not find summary for " .. name)
	end
end
function p.main(frame)
	return p._main(frame.args.name)
end
return p;