Module:Isotopen
Uiterlijk
Module voor sjabloon:Navigatie isotopen.
Gebruikt Module:Chemie.
local chemistry = require('Module:Chemie')
local p = {}
function p.isotopePage(element, suffix)
local title = mw.title.new(element .. '-' .. suffix)
if title.isRedirect then
local target = title.redirectTarget
if not string.match(target.text, '^Isotopen van ') then
title = target
end
end
return title.text
end
local function navigationFromArgs(element, symbol, isotopes)
local s = ''
for i, v in ipairs(isotopes) do
if i ~= 1 then
s = s .. ' · '
end
local pagename = p.isotopePage(element, v)
local label = '<sup>' .. v .. '</sup>' .. symbol
s = s .. '[[' .. pagename .. '|' .. label .. ']]'
end
return mw.getCurrentFrame():expandTemplate{ title = 'Navigatie', args = {
naam = 'Navigatie isotopen van ' .. element,
titel = '[[Isotopen van ' .. element .. ']] (' .. symbol .. ')',
inhoud = s
} }
end
function p.navigatie(frame)
local args = frame:getParent().args
local element = args[1]
-- if not element then -- arguments: all or nothing
-- return navigationFromWikidata()
-- end
local symbol = args[2]
local isotopes = {}
do -- iterate over numbered arguments
local i = 1, v
while true do
v = args[i + 2]
if not v then
break
end
isotopes[i] = v
i = i + 1
end
end
return navigationFromArgs(element, symbol, isotopes)
end
function p.isotoopPagina(frame)
local args = frame:getParent().args
local arg = args[1]
if not arg then
arg = args[2]
end
local element = chemistry.elementName(arg)
return p.isotopePage(element, args[3])
end
return p