Modul:Format link: Forskjell mellom sideversjoner
m Én sideversjon ble importert |
Don't prepend colon for section-only links, fix comment |
||
| Linje 45: | Linje 45: | ||
-- These components are: | -- These components are: | ||
-- - link: the link, stripped of any initial colon (always present) | -- - link: the link, stripped of any initial colon (always present) | ||
-- - page: the page name ( | -- - page: the page name (may be nil) | ||
-- - section: the | -- - section: the section name (may be nil) | ||
-- - display: the display text, if manually entered after a pipe (may be nil) | -- - display: the display text, if manually entered after a pipe (may be nil) | ||
link = removeInitialColon(link) | link = removeInitialColon(link) | ||
| Linje 72: | Linje 72: | ||
section = postHash | section = postHash | ||
end | end | ||
return { | return { | ||
link = link, | link = link, | ||
| Linje 175: | Linje 175: | ||
end | end | ||
end | end | ||
-- Prepend colon if appropriate | |||
local colon = parsed.page and ":" or "" | |||
-- Format the result as a link | -- Format the result as a link | ||
if parsed.link == display then | if parsed.link == display then | ||
return mw.ustring.format('[[ | return mw.ustring.format('[[%s%s]]%s', colon, parsed.link, category) | ||
else | else | ||
return mw.ustring.format('[[ | return mw.ustring.format('[[%s%s|%s]]%s', colon, parsed.link, display, category) | ||
end | end | ||
end | end | ||