Module:Hatnote: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
(format p._main to accept a list of page/display tables as input) |
(factor out some of the main code to a shared function) |
||
Line 93: | Line 93: | ||
return ret |
return ret |
||
end |
end |
||
local function formatPageTables(pages) |
|||
-- Takes a list of page/display tables and returns it as a list of |
|||
-- formatted links. Nil values are not allowed. |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
return links |
|||
end |
|||
local function makeWikitextError(msg) |
local function makeWikitextError(msg) |
||
Line 225: | Line 236: | ||
firstPageTable = {firstPage} |
firstPageTable = {firstPage} |
||
pages[1] = firstPageTable |
pages[1] = firstPageTable |
||
⚫ | |||
-- Make the list of formatted links |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
end |
end |
||
Line 238: | Line 241: | ||
local firstPageNs = findNamespaceId(firstPage) |
local firstPageNs = findNamespaceId(firstPage) |
||
local pagetype = firstPageNs == 0 and 'article' or 'page' |
local pagetype = firstPageNs == 0 and 'article' or 'page' |
||
-- Make the formatted link text |
|||
local links = formatPageTables(pages) |
|||
⚫ | |||
-- Build the text. |
-- Build the text. |
||
local isPlural = # |
local isPlural = #pages > 1 |
||
local currentNs = currentTitle.namespace |
local currentNs = currentTitle.namespace |
||
local isCategoryNamespace = currentNs - currentNs % 2 == 14 |
local isCategoryNamespace = currentNs - currentNs % 2 == 14 |
||
⚫ | |||
local stringToFormat |
local stringToFormat |
||
if isCategoryNamespace then |
if isCategoryNamespace then |