Modul:Hatnote: Unterschied zwischen den Versionen

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")
Zeile 36: Zeile 36:
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------


local function findNamespaceId(link)
local function findNamespaceId(link, removeColon)
-- Finds the namespace id (namespace number) of a link or a pagename. This
-- 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 or if
-- function will not work if the link is enclosed in double brackets. If the
-- the link has been escaped with the colon trick.
-- removeColon parameter is set to true, the function will remove initial
-- colons from the link.
if removeColon then
link = link:match('^:?(.*)')
end
local namespace = link:match('^(.-):')
local namespace = link:match('^(.-):')
if namespace then
if namespace then
Zeile 59: Zeile 63:
-- colon trick for categories and files, as otherwise category links
-- colon trick for categories and files, as otherwise category links
-- categorise the page and file links display the file.
-- categorise the page and file links display the file.
link = link:match('^:(.*)') or link -- Remove initial colon if specified.
link = link:match('^:?(.*)') -- Remove initial colon if specified.
local namespace = findNamespaceId(link)
local namespace = findNamespaceId(link)
local colon
local colon
Zeile 240: Zeile 244:


-- Find the pagetype.
-- Find the pagetype.
local firstPageNs = findNamespaceId(firstPage)
local firstPageNs = findNamespaceId(firstPage, true)
local pagetype = firstPageNs == 0 and 'article' or 'page'
local pagetype = firstPageNs == 0 and 'article' or 'page'


Anonymer Benutzer