Module:StripLink: Difference between revisions
From Trans People Together Wiki
No edit summary |
No edit summary |
||
Line 2: | Line 2: | ||
function p.strip(frame) | function p.strip(frame) | ||
local input = frame.args[1] or '' | local input = frame.args[1] or '' | ||
-- | -- Extract content inside single brackets | ||
local | local inner = input:match('%[%s*(.-)%s*%]') | ||
-- | if inner then | ||
return | -- Return only the first whitespace-delimited segment (the URL) | ||
local url = inner:match('^(%S+)') | |||
return url or input | |||
end | |||
return input | |||
end | end | ||
return p | return p |
Latest revision as of 03:06, 11 May 2025
Documentation for this module may be created at Module:StripLink/doc
local p = {}
function p.strip(frame)
local input = frame.args[1] or ''
-- Extract content inside single brackets
local inner = input:match('%[%s*(.-)%s*%]')
if inner then
-- Return only the first whitespace-delimited segment (the URL)
local url = inner:match('^(%S+)')
return url or input
end
return input
end
return p