Jump to content

Module:Wikt

From Wikisource

local p = {} --p stands for package

local getArgs = require('Module:Arguments').getArgs
local yesno = require('Module:Yesno')

function p._wikt(args)
	local link = args.link or args[1] or ""
	local text = args.text or args[2] or link
	local anchor = args.anchor or args[3] or ""
	local gray = yesno(args.gray or false)
	
	if gray then
		text = '<span style="color:dimgray;">' .. text .. '</span>'
	end
	
	if anchor then
		anchor = '&#35;' .. mw.uri.anchorEncode(anchor)
	end
	
	return '[[wikt:' .. link .. anchor .. '|' .. text .. ']]'
end

function p.wikt(frame)
	return p._wikt(getArgs(frame))
end

return p