Anonymous user
Module:Hatnote: Difference between revisions
split out the namespace-detecting part of formatLink to a new function
(add Template:Further) |
(split out the namespace-detecting part of formatLink to a new function) |
||
Line 35:
-- 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▼
end
return 0
end
local function formatLink(link, display)
Line 45 ⟶ 59:
-- colon trick for categories and files, as otherwise category links
-- categorise the page and file links display the file.
local namespace = findNamespaceId(link
local colon
if namespace
else
▲ local nsid = mw.site.namespaces[namespace].id
▲ colon = ':'
▲ end
end
▲ colon = colon or ''
-- Find the display value.
|