Module:Hatnote: Difference between revisions
Jump to navigation
Jump to search
tidy up the code now that we are adding colons to all the links
>Ahecht (prefix all links with colons to allow interwiki links to work.) |
>Mr. Stradivarius (tidy up the code now that we are adding colons to all the links) |
||
Line 28: | Line 28: | ||
-- Removes the initial colon from a string, if present. | -- Removes the initial colon from a string, if present. | ||
return s:match('^:?(.*)') | return s:match('^:?(.*)') | ||
end | end | ||
Line 135: | Line 115: | ||
function p._formatLink(link, display) | function p._formatLink(link, display) | ||
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) | ||
-- Find whether a faux display value has been added with the {{!}} magic | -- Find whether a faux display value has been added with the {{!}} magic | ||
Line 169: | Line 139: | ||
-- Assemble the link. | -- Assemble the link. | ||
if display then | if display then | ||
return string.format('[[ | return string.format('[[:%s|%s]]', link, display) | ||
else | else | ||
return string.format('[[ | return string.format('[[:%s]]', link) | ||
end | end | ||
end | end |