Changes
Jump to navigation
Jump to search
← Older edit
Module:Labelled list hatnote
(view source)
Revision as of 10:27, 4 January 2026
286 bytes added
,
4 January
m
1 revision imported
Line 86:
Line 86:
}
}
return p._labelledList(pages, labels, options)
return p._labelledList(pages, labels, options)
+
end
+
local function exists(title)
+
local success, result = pcall(function() return title.exists end)
+
if success then
+
return result
+
else
+
return true
+
end
end
end
function p._labelledList (pages, labels, options)
function p._labelledList (pages, labels, options)
+
local removednonexist = false
if options.ifexists then
if options.ifexists then
for k = #pages, 1, -1 do --iterate backwards to allow smooth removals
for k = #pages, 1, -1 do --iterate backwards to allow smooth removals
local v = pages[k]
local v = pages[k]
−
local title = mw.title.new(getTarget(v), namespace)
+
if mw.ustring.sub(mw.text.trim(v), 1, 1) ~= "#" then
−
if (v == '') or title == nil or not title
.exists
then
+
local title = mw.title.new(getTarget(v), namespace)
−
table.remove(pages, k)
+
if (v == '') or
(
title == nil
)
or not
exists(
title
)
then
+
table.remove(pages, k)
+
removednonexist = true
+
end
end
end
end
end
Line 111:
Line 123:
end
end
if #pages == 0 then
if #pages == 0 then
−
if
options.ifexists
then
+
if
removednonexist
then
mw.addWarning(
mw.addWarning(
string.format(
string.format(
Krizar
confirmed, superuser,
Administrators
1,033
edits
Navigation menu
Personal tools
Create account
Log in
Namespaces
Module
Discussion
Variants
Views
Read
View source
View history
More
Search
Navigation
About
Main page
Recent changes
Random page
WikiData entry
WineDB entry
IGDB entry
Chocolatey Package
Help about MediaWiki
Tools
Special pages
Printable version