m
change by Sizable
mNo edit summary |
m (change by Sizable) |
||
end
return ''
end
-- Copied from [[wp:Module:Delink]]
-- Arguments should be supplied from other modules where "s" is the link without brackets
-- Returns the link text to be displayed from this link after applying the pipe trick
local function linktext( s )
if type(s) ~= "string" then
return nil
end
-- We need to deal with colons, brackets, and commas, per [[wp:Help:Pipe trick]].
-- First, remove the text before the first colon, if any.
if mw.ustring.match(s, ":") then
s = mw.ustring.match(s, ".-:(.*)")
end
-- Next up, brackets and commas.
if mw.ustring.match(s, "%(.-%)$") then -- Brackets trump commas.
s = mw.ustring.match(s, "(.-) ?%(.-%)$")
elseif s:match(",") then -- If there are no brackets, display only the text before the first comma.
s = mw.ustring.match(s, "(.-),.*$")
end
return s
end
-- See {{L}}
p.link = function( f )
-- Set keepEmptyArgs to true to allow pipe trick
local args = processArgs.normDefault( f, true )
-- Get language suffix for links
end
local usePipeTrick = args.o == '' or args[2] == ''
-- Get page link with suffix and specified text▼
local display
return '[[' .. page .. '|' .. ( args.o or args[2] or args[1] ) .. ']]'▼
-- The pipe trick should only be used with English; but we have to support /en pages
if usePipeTrick then
-- Run pipe trick on page title without langauage code; otherwise it breaks
display = linktext(args[1])
else
display = args.o or args[2] or args[1]
end
▲ -- Get page link with suffix and specified display text
end
|