Module:Linker

From Moegirlpedia
Jump to: navigation, search
Template-info.svg Module Documentation  [Create] [Refresh]
local p = {}

function p._canLink(name)
	if string.find(name, '[%[{<]') or mw.text.killMarkers(name) ~= name then
		return false
	else
		return true
	end
end

function p.canLink(frame)
	local target = frame.args[1]

	if p._canLink(target) then
		return target
	else
		return ''
	end
end

function p.tryLink(frame)
	local target = frame.args[1]

	if p._canLink(target) then
		return '[[' .. target .. ']]'
	else
		return target
	end
end

return p