diff --git a/src/formatters.nim b/src/formatters.nim
index 4662c68..bef2c71 100644
--- a/src/formatters.nim
+++ b/src/formatters.nim
@@ -6,9 +6,9 @@ import ./types, ./utils
from unicode import Rune, `$`
const
- urlRegex = re"((https?|ftp)://(-\.)?([^\s/?\.#]+\.?)+(/[^\s]*)?)"
+ urlRegex = re"((https?|ftp)://(-\.)?([^\s/?\.#]+\.?)+(/[^\s\)]*)?)"
emailRegex = re"([a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+)"
- usernameRegex = re"(^|[^\S\n]|\.|>)@([A-z0-9_]+)"
+ usernameRegex = re"(^|[^\S]|\.|>)@([A-z0-9_]+)"
picRegex = re"pic.twitter.com/[^ ]+"
cardRegex = re"(https?://)?cards.twitter.com/[^ ]+"
ellipsisRegex = re" ?…"
@@ -52,10 +52,9 @@ proc linkifyText*(text: string): string =
result = result.replace(ellipsisRegex, "")
result = result.replace(emailRegex, reEmailToLink)
result = result.replace(urlRegex, reUrlToLink)
- result = result.replace("\n", "
")
result = result.replace(usernameRegex, reUsernameToLink)
- result = result.replace(re"([^\s\(\n])\s+([;.,!\)']|')", "$1")
+ result = result.replace(re"([^\s\(\n%])\s+([;.,!\)'%]|')", "$1")
proc stripTwitterUrls*(text: string): string =
result = text