Content deleted Content added
m quick regex fix |
more pipe trick stuff (there's more to wikilinks than I thought) |
||
Line 2:
local yesno = require("Module:Yesno")
-- Behaviour for these functions determined via [[Help:Pipe trick]]
local function replicatePipeTrick(target)▼
target = target:gsub("^[a-zA-Z0-9 _-]-:(.*)$", "%1") --Remove the namespace if
else
end
return
end
local current = mw.title.getCurrentTitle().prefixedText
if current:find("%(.+%)$") then --If ending parenthesis
target = target .. current:gsub("^.-( *%(.+%))$", "%1") --Append ending parenthesis
else
target = target .. current:gsub("^.-(, .*)$", "%1") --Else, append ending comma
end
return target
end
Line 20 ⟶ 31:
local displayText = string.sub(trimmed, firstPipe+1)
if target == "" then -- [[|XYZ]]
return trim(wlReversePipeTrick(displayText)),
elseif displayText == "" then -- [[XYZ|]]
return trim(target), trim(
else --[[ABC|XYZ]]
return trim(target), trim(displayText)
end
else
if out:find("^/.-/+$") and mw.title.getCurrentTitle().namespace ~= 0 then -- [[/Test/]]
return out, out:gsub("^/(.-)/+$", "%1")
else -- [[Test]]
return out, nil
end
end
end
|