Zum Inhalt springen

Modul:Hatnote list: Unterschied zwischen den Versionen

Simplified a few things, mostly re: calls to mw.listToText().
K (Derped on that comment fix before. Removed more incorrect/obsolete comment text.)
(Simplified a few things, mostly re: calls to mw.listToText().)
Zeile 13: Zeile 13:
local p = {}
local p = {}


function p.andList (andTable)
function p.andList (list)
-- Stringifies a list with "and"
-- Stringifies a list with "and"
local andString = (#andTable > 2 and mw.text.listToText(andTable, nil, ', and ')) or
return mw.text.listToText(list, nil, (#list > 2 and ',' or '') .. ' and ')
mw.text.listToText(andTable)
return andString
end
end


function p.orList (orTable)
function p.orList (list)
-- Stringifies a list with "or"
-- Stringifies a list with "or"
local orString = (#andTable > 2 and mw.text.listToText(andTable, nil, ', or ')) or
return mw.text.listToText(list, nil, (#list > 2 and ',' or '') .. ' or ')
mw.text.listToText(andTable, nil, ' or ')
return orString
end
end


Zeile 104: Zeile 100:
table.insert(strList, string.format(options.forseeForm, useStr, pagesStr))
table.insert(strList, string.format(options.forseeForm, useStr, pagesStr))
end
end
return mw.text.listToText(strList, ' ', ' ')
return table.concat(strList, ' ')
end
end


return p
return p
Anonymer Benutzer