Módulo:Distinguir

Origem: Wikipédia, a enciclopédia livre.
local mHatnote = require('Módulo:Hatnote')
local mHatlist = require('Módulo:Hatnote list')
local mArguments -- inicializa preguiçosamente
local mTableTools -- inicializa preguiçosamente
local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType
local p = {}

function p.distinguish(frame)
	mArguments = require('Módulo:Arguments')
	mTableTools = require('Módulo:TableTools')
	local args = mArguments.getArgs(frame)
	local selfref = args.selfref or args.autorref
	local text = args.text or args.texto
	args = mTableTools.compressSparseArray(args)
	return p._distinguish(args, text, selfref)
end

function p._distinguish(args, text, selfref)
	checkType("_distinguish", 1, args, 'table')
	if #args == 0 and not text then return '' end
	local text = string.format(
		'Não confundir com %s.',
		text or mHatlist.orList(args, true)
	)
	hnOptions = {selfref = selfref}
	return mHatnote._hatnote(text, hnOptions)
end

return p