Module:Hatnote list: Difference between revisions

Content added Content deleted
m (Derped on that comment fix before. Removed more incorrect/obsolete comment text.)
(Simplified a few things, mostly re: calls to mw.listToText().)
Line 13: Line 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


Line 104: Line 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