Module:Sandbox/Gonnym/Infobox disambiguation check

Revision as of 16:05, 2 July 2020 by imported>Gonnym
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Sandbox/Gonnym/Infobox disambiguation check/doc

local p = {}

function p.main(frame)
	local getArgs = require('Module:Arguments').getArgs
	local args = getArgs(frame)
	title = args[1]
	page = mw.title.new(title, 0)

	if (not page.exists) then
		return "empty"
	end

	if (page.isRedirect) then
		return "redirect"
	end

	local content = page:getContent()
	if content and content:match('{{%s*[Dd]isambig%s*}}') or content:match('{{%s*[Dd]ab%s*}}') then
		return "dab"
	end

	return "article"
end

return p