More actions
Created page with "-------------------------------------------------------------------------------- -- Module:Hatnote list -- -- -- -- This module produces and formats lists for use in hatnotes. In particular, -- -- it implements the for-see list, i.e. lists of "For X, see Y" statements, -- -- as used in {{about}}, {{redirect}}, and their variants. Also introd..." |
No edit summary |
||
Line 63: | Line 63: | ||
end | end | ||
end | end | ||
-- Set the conjunction, apply Oxford comma, and force a comma if #1 has " " | -- Set the conjunction, apply Oxford comma, and force a comma if #1 has "§" | ||
local conjunction = s .. options.conjunction .. s | local conjunction = s .. options.conjunction .. s | ||
if #list == 2 and searchDisp(list[1], " ") or #list > 2 then | if #list == 2 and searchDisp(list[1], "§") or #list > 2 then | ||
conjunction = separator .. conjunction | conjunction = separator .. conjunction | ||
end | end | ||
Line 96: | Line 96: | ||
} | } | ||
--Collapses duplicate punctuation | --Collapses duplicate punctuation at end of string, ignoring italics and links | ||
local function punctuationCollapse (text) | local function punctuationCollapse (text) | ||
return text:match("[.?!]('?)%1(%]?)%2%.$") and text:sub(1, -2) or text | |||
end | end | ||
Line 148: | Line 139: | ||
table.insert(forRow.pages, args[i + 1]) | table.insert(forRow.pages, args[i + 1]) | ||
-- If the param after next is "and", do inner loop to collect params | -- If the param after next is "and", do inner loop to collect params | ||
-- until the "and"'s stop. Blanks are ignored: "1|and||and|3" | -- until the "and"'s stop. Blanks are ignored: "1|and||and|3" → {1, 3} | ||
while args[i + 2] == options.andKeyword do | while args[i + 2] == options.andKeyword do | ||
if args[i + 3] then | if args[i + 3] then | ||
table.insert(forRow.pages, args[i + 3]) | table.insert(forRow.pages, args[i + 3]) | ||
end | end | ||
Line 161: | Line 152: | ||
table.insert(forTable, forRow) | table.insert(forTable, forRow) | ||
until terminated or i > maxArg | until terminated or i > maxArg | ||
return forTable | return forTable | ||
end | end |