「モジュール:Labelled list hatnote」の版間の差分

Exclude section anchors from ifexists, properly show "no input" error message when ifexists=true
(1版 をインポートしました)
bsd>Ahecht
(Exclude section anchors from ifexists, properly show "no input" error message when ifexists=true)
97行目: 97行目:


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 exists(title) 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
119行目: 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(
匿名利用者