Module:Link Label
Jump to navigation
Jump to search
Documentation for this module may be created at Module:Link Label/doc
local p = {}
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame, {
parentFirst = true,
wrapper = { 'Template:Link Label' }
})
return p._main(args)
end
function p._main(args)
local link = args[1]
if (link == nil) then return "" end
if (link:find("%|")) then return link end
-- if link contains multiple links
local _, count = link:gsub("%[%[", "")
if (count > 1) then return link end
if (link:find("%[%[") and link:find("%]%]")) then
link = link:gsub("%[%[", ""):gsub("%]%]", "")
end
local label = link
if (link:find(" %(Weapon%)")) then label = link:gsub(" %(Weapon%)", "") end
if (link:find(" %(Item%)")) then label = link:gsub(" %(Item%)", "") end
return "[[" .. link .. "|" .. label .. "]]"
end
return p