Module:Delink: Difference between revisions
From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
Content added Content deleted
(whitespace test) |
(handle multiple-line links) |
||
Line 4:
local function delinkReversePipeTrick(s)
if mw.ustring.match(s, "^%[%[|.*[|\n]") then -- Check for newlines or multiple pipes.
return s
else
Line 83:
if mw.ustring.match(s, "|") then -- Find if we're dealing with a piped link.
display = mw.ustring.match(s, "^%[%[.-|(.+)%]%]")
-- Remove new lines from the display of multiline piped links,
-- where the pipe is before the first new line.
display = mw.ustring.gsub(display, "\n", "")
else
display = mw.ustring.match(s, "^%[%[(.-)%]%]")
Line 152 ⟶ 155:
text = delinkLinkClass(text, "^%[.-%]", delinkURL) -- De-link URLs.
end
text = mw.ustring.gsub(text, "[^\\n](\\n)[^\\n]", "") -- Remove single new lines (but not double new lines).
return text
end
|