Anonymous user
Module:Hatnote: Difference between revisions
factor out some of the main code to a shared function
(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:
return ret
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.
local links = {}▼
for i, t in ipairs(pages) do▼
local link = t[1]▼
local display = t[2]▼
end▼
return links
end
local function makeWikitextError(msg)
Line 225 ⟶ 236:
firstPageTable = {firstPage}
pages[1] = firstPageTable
▲ end
▲ local links = {}
▲ for i, t in ipairs(pages) do
▲ local link = t[1]
▲ local display = t[2]
▲ links[#links + 1] = formatLink(link, display)
end
Line 238 ⟶ 241:
local firstPageNs = findNamespaceId(firstPage)
local pagetype = firstPageNs == 0 and 'article' or 'page'
-- Make the formatted link text
local links = formatPageTables(pages)
links = mw.text.listToText(links)▼
-- Build the text.
local isPlural = #
local currentNs = currentTitle.namespace
local isCategoryNamespace = currentNs - currentNs % 2 == 14
▲ links = mw.text.listToText(links)
local stringToFormat
if isCategoryNamespace then
|