Module:Sandbox/Aidan9382/Link once: Difference between revisions

Content deleted Content added
more pipe trick stuff (there's more to wikilinks than I thought)
Dont process category links
 
(3 intermediate revisions by the same user not shown)
Line 23:
end
 
local function getWikilinkInfo(wikilink)
-- [=[
Returns the wikilink's target and everythingits display elsetext.
Automatically recreates the effect of any [[Help:pipe tricks|]]
--]=]
local trim = mw.text.trim
local trimmed = string.sub(wikilink, 3, -3)
Line 54 ⟶ 58:
%[%[.-%]%] wouldn't work for the exact same testcase for other reasons
--]=]
local options = options or {follow_redirects=true}
local newText = {}
local scannerPosition = 1
Line 80 ⟶ 84:
 
local newContainer = (openWikilinks[#openWikilinks] or {Text=newText}).Text
if wlTarget:find("^[Ii]mage:") or wlTarget:find("^[Ff]ile:") or wlTarget:find("^[Cc]ategory:") then --Files/Images/Categories aren't processed (they aren't really wikilinks)
newContainer[#newContainer+1] = wlText
else
Line 124 ⟶ 128:
local args = require('Module:Arguments').getArgs(frame)
return linkOnce(args[1] or "", {
follow_redirects = yesno(args.follow_redirects) or falsetrue,
})
end
Line 133 ⟶ 137:
linkOnce = linkOnce,
-- Helper functions
wlPipeTrick = wlPipeTrick,
replicatePipeTrick = replicatePipeTrick,
wlReversePipeTrick = wlReversePipeTrick,
getWikilinkInfo = getWikilinkInfo
}