mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-22 00:50:12 +00:00
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.
This commit is contained in:
parent
e98c9b46f1
commit
44558b8109
10
stripmd.go
10
stripmd.go
@ -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…
Reference in New Issue
Block a user