Module:Delink: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
Content added Content deleted
(Reorder whitespace testing)
(account for lines containing only spaces)
Line 161: Line 161:
end
end
if not (args.whitespace == "no") then
if not (args.whitespace == "no") then
text = mw.ustring.gsub(text, "([^\n])(\n)([^\n])", "%1 %3") -- Remove single new lines (but not double new lines).
-- Replace single new lines with a single space, but leave double new lines
-- and new lines only containing spaces or tabs before a second new line.
text = mw.ustring.gsub(text, "([^\n \t][ \t]*)\n([ \t]*[^\n \t])", "%1 %2")
text = mw.ustring.gsub(text, "[ \t]+", " ") -- Remove extra tabs and spaces.
text = mw.ustring.gsub(text, "[ \t]+", " ") -- Remove extra tabs and spaces.
end
end