Module:Linker

From Moegirlpedia
Revision as of 20:42, 25 March 2022 by LiaMinina (talk | contribs) (Created page with "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.canLi...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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