Zum Inhalt springen

Modul:Hatnote: Unterschied zwischen den Versionen

sorry about that; we need to keep findNamespaceId around for other modules
(Reverted 1 edit by Mr. Stradivarius (talk): Error in module:main while using module:sports table. (TW))
(sorry about that; we need to keep findNamespaceId around for other modules)
Zeile 35: Zeile 35:
-- are trimmed from the start of the link by default. To skip colon
-- are trimmed from the start of the link by default. To skip colon
-- trimming, set the removeColon parameter to true.
-- trimming, set the removeColon parameter to true.
--
-- This function is used by other modules, e.g. [[Module:Main]].
checkType('findNamespaceId', 1, link, 'string')
checkType('findNamespaceId', 1, link, 'string')
checkType('findNamespaceId', 2, removeColon, 'boolean', true)
checkType('findNamespaceId', 2, removeColon, 'boolean', true)
Zeile 135: Zeile 137:


function p._formatLink(link, display)
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', 1, link, 'string')
checkType('_formatLink', 2, display, 'string', true)
checkType('_formatLink', 2, display, 'string', true)
-- Remove the initial colon for links where it was specified manually.
link = removeInitialColon(link)
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
-- Find whether a faux display value has been added with the {{!}} magic
Zeile 169: Zeile 161:
-- Assemble the link.
-- Assemble the link.
if display then
if display then
return string.format('[[%s%s|%s]]', colon, link, display)
return string.format('[[:%s|%s]]', link, display)
else
else
return string.format('[[%s%s]]', colon, link)
return string.format('[[:%s]]', link)
end
end
end
end
Anonymer Benutzer