Module:Delink: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
move the colon trick processing to earlier in the chain
(move cat/interwiki/file check earlier to the start of the processing chain)
(move the colon trick processing to earlier in the chain)
Line 14:
-- We need to deal with colons, brackets, and commas, per [[Help:Pipe trick]].
-- First, weremove checkthe whethertext orbefore notthe therefirst are colons in the linkcolon, and trim itif accordinglyany.
if mw.ustring.match(s, ":") then
s = mw.ustring.match(s, "%[%[.-:(.*)|%]%]")
-- Check for the [[Help:Colon trick]].
if mw.ustring.match(s, "%[%[:") then
s = mw.ustring.match(s, "%[%[:.-:(.*)|%]%]")
-- Otherwise, remove the text before the first colon.
else
s = mw.ustring.match(s, "%[%[.-:(.*)|%]%]")
end
-- If there are no colons, grab all of the text apart from the square brackets and the pipe.
else
Line 40 ⟶ 31:
end
 
local function delinkOne(texts)
-- First, check for categories, interwikis, and files.
local colonprefix = mw.ustring.match(texts, "%[%[(.-):.*%]%]") or "" -- Get the text before the first colon.
if mw.language.isKnownLanguageTag(colonprefix)
or mw.ustring.match(colonprefix, "^[Cc]ategory$")
Line 49 ⟶ 40:
return ""
end
if mw.ustring.match(text, "[^|].*|%]%]") or mw.ustring.match(text, "%[%[|") then -- Weed out the pipe tricks first.
-- Remove the colon --if the link Checkis forusing the [[Help:Colon trick]].
return delinkPipeTrick(text)
if mw.ustring.match(s, "%[%[:") then
s = "[[" .. mw.ustring.match(s, "%[%[:.-:(.*)|%]%])")
end
if mw.ustring.match(texts, "[^|].*|%]%]") or mw.ustring.match(texts, "%[%[|") then -- Weed out the pipe tricks first.
return delinkPipeTrick(texts)
end
-- Find the link area and display area of the wikilink
local linkarea, display
if mw.ustring.match(texts, "|") then -- Find if we're dealing with a piped link.
linkarea, display = mw.ustring.match(texts, "^%[%[(.-)|(.+)%]%]")
else
-- If the link isn't piped, the display area and the link area are the same.
linkarea = mw.ustring.match(texts, "^%[%[(.-)%]%]")
display = linkarea
end
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu