Module:Solar eclipse/sandbox: Difference between revisions

Content deleted Content added
Minor cleanup
preference for date over full link
Line 85:
 
local function createLink(label, suffix)
if not label or label == '' then
return ''
end
 
-- if label is a valid link or not
local prefix = "Solar eclipse of "
if mw.ustring.match(label, "^%[%[.*%]%]$") then
-- check if label starts with the prefix
return label
if mw.ustring.find(label, "^" .. prefix) then
end
-- extract the date part from the label
-- create a link otherwise
local linkdateLabel = mw.ustring.formatsub('%slabel, solar#prefix eclipse',+ label1)
local page = label -- this is the full page title to link to
if ifexist(link) then
 
return string.format('[[%s|%s]]', link, label)
if ifexist(linkpage) then
else
return string.format('[[%s|%s]]', linkpage, labeldateLabel)
return label
else
end
-- if page doesn't exist, display the date
return dateLabel
end
else
-- if the label is a valida link, orkeep notit
if mw.ustring.match(label, "^%[%[.*%]%]$") then
return label
else
-- for labels without the prefix, display as plain text
return label
end
end
end