Module:Link

local p = {}

local function link(x, y, note) local inner if note == nil then inner = x .. "|" .. y	elseif note:sub(1, 1) == "&" then inner = x .. "|" .. y .. " " .. note else inner = x .. "|" .. y .. "]] [[File:" .. note .. "|20x20px|link=" end return "" .. inner .. "" end

local function Set (list) local set = {} for _, l in ipairs(list) do set[l] = true end return set end

local metals = { aluminum = "Aluminium alt 2.svg", aluminium = "Aluminium alt 2.svg", antimony = "&#9793;", arsenic = "	&#128826;", bismuth = "	&#128792;", boron = "&#61;", copper = "Copper symbol.svg", silver ="&#9789;", sulfur = "&#128783;", magnesium = "&#8859;", gold = "&#128794;", iron = "&#9794;", lead = "&#9796;", tin = "&#9795;", lithium = "Stone symbol.svg", zinc = "Zinc-alchemy symbols.svg", phosphorous = "Phosphorus symbol.svg", platinum = "Platinum-symbol.svg" }

local planets = { venus = "&#9792;", jupiter = "&#9795;", saturn = "&#9796;", uranus = "&#9797;", neptune = "&#9798;", pluto = "&#9799;", mercury = "&#9791;", mars = "&#9794;" }

function p.metal(frame) local x = frame.args[1] local xlo = x:lower if xlo == "mercury" then return "Mercury &#9791;" end return link(x, x, metals[xlo]) end

function p.planet(frame) local x = frame.args[1] local xlo = x:lower if xlo == "earth" then return "Earth &#128808;" else return link(x .. " (planet)", x, planets[xlo]) end end

local function buildNormal(tag, set) return function(frame) local x = frame.args[1] local xlo = x:lower if set[xlo] == nil then return link(x, x)		else return link(x .. " (" .. tag .. ")", x)		end end end

p.god = buildNormal('god', Set { }) p.angel = buildNormal('angel', Set { }) p.demon = buildNormal('demon', Set { })

return p