Module:ExtractPageNameFromInternalLink: Difference between revisions
From Trans People Together Wiki
Created page with "local p = {} -- Entry point for {{#invoke:ExtractPageNameFromInternalLink|extract|link}} function p.extract(frame) -- Get the first positional argument (the full link markup) local link = frame.args[1] or "" -- Pattern breakdown: -- ^%[%[ : match the literal "[[" at the start -- :? : optionally match a leading colon (to allow ... -- ([^%[%|]+): capture one or more characters that are not "[" or "|" local name = lin..." |
(No difference)
|
Latest revision as of 15:42, 18 May 2025
Documentation for this module may be created at Module:ExtractPageNameFromInternalLink/doc
local p = {}
-- Entry point for {{#invoke:ExtractPageNameFromInternalLink|extract|link}}
function p.extract(frame)
-- Get the first positional argument (the full link markup)
local link = frame.args[1] or ""
-- Pattern breakdown:
-- ^%[%[ : match the literal "[[" at the start
-- :? : optionally match a leading colon (to allow [[:Page|...]]
-- ([^%[%|]+): capture one or more characters that are not "[" or "|"
local name = link:match("^%[%[:?([^%[%|]+)")
-- Return the captured page name, or an empty string if none
return name or ""
end
return p