Module:Hatnote list: Difference between revisions
Content added Content deleted
(Moved form of for-see statement into options) |
m (Changed some variable and structure names: forRow's second item is a table called "pages" instead of a table called "see" now; more logical naming) |
||
Line 78: | Line 78: | ||
if not args[i] then terminated = true end |
if not args[i] then terminated = true end |
||
-- New empty list of pages |
-- New empty list of pages |
||
forRow. |
forRow.pages = {} |
||
-- If there's not at least one page listed, assume the list's ended, use |
-- If there's not at least one page listed, assume the list's ended, use |
||
-- the default, and break at end of this loop-through. |
-- the default, and break at end of this loop-through. |
||
table.insert(forRow. |
table.insert(forRow.pages, args[i + 1] or (options.title .. options.disambiguator)) |
||
-- If the option after next is "and", do an inner loop where we collect |
-- If the option after next is "and", do an inner loop where we collect |
||
-- items following "and"'s until the "and"'s stop. If there's a blank |
-- items following "and"'s until the "and"'s stop. If there's a blank |
||
Line 87: | Line 87: | ||
while args[i + 2] == 'and' do |
while args[i + 2] == 'and' do |
||
if args[i + 3] then |
if args[i + 3] then |
||
table.insert(forRow. |
table.insert(forRow.pages, args[i + 3]) |
||
end |
end |
||
-- Increment to the next "and" |
-- Increment to the next "and" |
||
Line 102: | Line 102: | ||
for k, v in pairs(forTable) do |
for k, v in pairs(forTable) do |
||
local useStr = v.use |
local useStr = v.use |
||
local |
local pagesStr = p.andList(mHatnote.formatPages(unpack(v.pages))) |
||
table.insert(strList, string.format(options.forseeForm, useStr, |
table.insert(strList, string.format(options.forseeForm, useStr, pagesStr)) |
||
end |
end |
||
return mw.text.listToText(strList, ' ', ' ') |
return mw.text.listToText(strList, ' ', ' ') |