Module:Hatnote: Difference between revisions

prevent categories escaped with the colon trick being displayed as "article"
(fix colon-removing pattern)
(prevent categories escaped with the colon trick being displayed as "article")
Line 36:
--------------------------------------------------------------------------------
 
local function findNamespaceId(link, removeColon)
-- Finds the namespace id (namespace number) of a link or a pagename. This
-- function will not work if the link is enclosed in double brackets. orIf ifthe
-- removeColon parameter is set to true, the function will remove initial
-- the link has been escaped with the colon trick.
-- colons from the link.
if removeColon then
link = link:match('^:?(.*)')
end
local namespace = link:match('^(.-):')
if namespace then
Line 59 ⟶ 63:
-- colon trick for categories and files, as otherwise category links
-- categorise the page and file links display the file.
link = link:match('^:?(.*)') or link -- Remove initial colon if specified.
local namespace = findNamespaceId(link)
local colon
Line 240 ⟶ 244:
 
-- Find the pagetype.
local firstPageNs = findNamespaceId(firstPage, true)
local pagetype = firstPageNs == 0 and 'article' or 'page'