Module:Hatnote: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
(add Template:Further) |
(split out the namespace-detecting part of formatLink to a new function) |
||
Line 35: | Line 35: | ||
-- Helper functions |
-- Helper functions |
||
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
||
local function findNamespaceId(link) |
|||
-- 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 |
|||
-- the link has been escaped with the colon trick. |
|||
local namespace = link:match('^(.-):') |
|||
if namespace then |
|||
⚫ | |||
if nsTable then |
|||
return nsTable.id |
|||
⚫ | |||
end |
|||
return 0 |
|||
end |
|||
local function formatLink(link, display) |
local function formatLink(link, display) |
||
Line 45: | Line 59: | ||
-- 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. |
||
local namespace = link |
local namespace = findNamespaceId(link) |
||
local colon |
local colon |
||
if namespace |
if namespace == 6 or namespace == 14 then |
||
⚫ | |||
-- The start of the link is a valid namespace name; check whether it is |
|||
else |
|||
-- a category or a file. |
|||
⚫ | |||
⚫ | |||
if nsid == 6 or nsid == 14 then |
|||
⚫ | |||
⚫ | |||
end |
end |
||
⚫ | |||
-- Find the display value. |
-- Find the display value. |