Module:Delink: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
handle multiple-line links
(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
-- if not (args.whitespace == "no") then
-- text = mw.ustring.gsub(text, "%s[ \t]+", " ") -- Remove extra whitespacetabs and spaces.
text = mw.ustring.gsub(text, "[^\\n](\\n)[^\\n]", "") -- Remove single new lines (but not double new lines).
-- end
return text
end
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu