Discord: Remove extra newlines around links

Since links are converted into embeds, links put on their own line often
lead to extra newlines that looks pretty weird. They should now be
stripped.
pull/102/head
Harvey Tindall 4 years ago
parent e98c9b46f1
commit 44558b8109
No known key found for this signature in database
GPG Key ID: BBC65952848FB1A2

@ -44,6 +44,16 @@ func StripAltText(md string, links bool) (string, []*dg.MessageEmbed) {
out += md[URLStart : URLEnd+1] out += md[URLStart : URLEnd+1]
} }
previousURLEnd = URLEnd previousURLEnd = URLEnd
// Removing links often leaves a load of extra newlines which look weird, this removes them.
if links {
next := 2
for md[URLEnd+next] == '\n' {
next++
}
if next >= 3 {
previousURLEnd += next - 2
}
}
altTextStart, URLStart, URLEnd = -1, -1, -1 altTextStart, URLStart, URLEnd = -1, -1, -1
continue continue
} }

Loading…
Cancel
Save