"ഘടകം:Hatnote" എന്ന താളിന്റെ പതിപ്പുകൾ തമ്മിലുള്ള വ്യത്യാസം

Content deleted Content added
prefix all links with colons to allow interwiki links to work.
tidy up the code now that we are adding colons to all the links
വരി 28:
-- Removes the initial colon from a string, if present.
return s:match('^:?(.*)')
end
 
function p.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. Colons
-- are trimmed from the start of the link by default. To skip colon
-- trimming, set the removeColon parameter to true.
checkType('findNamespaceId', 1, link, 'string')
checkType('findNamespaceId', 2, removeColon, 'boolean', true)
if removeColon ~= false then
link = removeInitialColon(link)
end
local namespace = link:match('^(.-):')
if namespace then
local nsTable = mw.site.namespaces[namespace]
if nsTable then
return nsTable.id
end
end
return 0
end
 
Line 135 ⟶ 115:
 
function p._formatLink(link, display)
-- Find whether we need to use the colon trick or not. We need to use the
-- colon trick for categories and files, as otherwise category links
-- categorise the page and file links display the file.
checkType('_formatLink', 1, link, 'string')
checkType('_formatLink', 2, display, 'string', true)
 
-- Remove the initial colon for links where it was specified manually.
link = removeInitialColon(link)
local namespace = p.findNamespaceId(link, false)
local colon = ':'
-- The following lines were commented out to allow interwiki links to work,
-- as there is no harm in prefixing all links with colons.
-- if namespace == 6 or namespace == 14 then
-- colon = ':'
-- else
-- colon = ''
-- end
 
-- Find whether a faux display value has been added with the {{!}} magic
Line 169 ⟶ 139:
-- Assemble the link.
if display then
return string.format('[[%s:%s|%s]]', colon, link, display)
else
return string.format('[[%s:%s]]', colon, link)
end
end
"https://ml.wikipedia.org/wiki/ഘടകം:Hatnote" എന്ന താളിൽനിന്ന് ശേഖരിച്ചത്