Module:Delink: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
Content added Content deleted
(deal with categories/interwikis and the colon trick)
(move cat/interwiki/file check earlier to the start of the processing chain)
Line 16:
-- First, we check whether or not there are colons in the link, and trim it accordingly.
if mw.ustring.match(s, ":") then
-- If the link contains a colon, it could be a category or an interwiki,
-- or it could use the [[Help:Colon trick]].
-- Check for categories and interwikis.
local colonprefix = mw.ustring.match(s, "%[%[(.-):.*|%]%]") or "" -- Get the text before the first colon.
if mw.language.isKnownLanguageTag(colonprefix) or mw.ustring.match(colonprefix, "^[Cc]ategory$") then
s = ""
-- Check for the colon[[Help:Colon trick]].
elseifif mw.ustring.match(s, "%[%[:") then
s = mw.ustring.match(s, "%[%[:.-:(.*)|%]%]")
Line 48 ⟶ 41:
 
local function delinkOne(text)
-- CheckFirst, check for categories, interwikis, and interwikisfiles.
local colonprefix = mw.ustring.match(stext, "%[%[(.-):.*|%]%]") or "" -- Get the text before the first colon.
if mw.language.isKnownLanguageTag(colonprefix)
if mw.language.isKnownLanguageTag(colonprefix) or mw.ustring.match(colonprefix, "^[Cc]ategory$") then
or mw.ustring.match(colonprefix, "^[Ff]ile$")
or mw.ustring.match(colonprefix, "^[Ii]mage$") then
s =return ""
end
if mw.ustring.match(text, "[^|].*|%]%]") or mw.ustring.match(text, "%[%[|") then -- Weed out the pipe tricks first.
return delinkPipeTrick(text)