From 15826a1e1eb4fe515fd6140a1bdef9a4bd477367 Mon Sep 17 00:00:00 2001
From: Zed <zedeus@pm.me>
Date: Wed, 3 Jul 2019 12:20:23 +0200
Subject: [PATCH] Workaround for .@usernames

---
 src/formatters.nim | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/formatters.nim b/src/formatters.nim
index 83b2835..fe78d69 100644
--- a/src/formatters.nim
+++ b/src/formatters.nim
@@ -8,7 +8,7 @@ from unicode import Rune, `$`
 const
   urlRegex = re"((https?|ftp)://(-\.)?([^\s/?\.#]+\.?)+([/\?][^\s\)]*)?)"
   emailRegex = re"([a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+)"
-  usernameRegex = re"(^|[^A-z])@([A-z0-9_]+)"
+  usernameRegex = re"(^|[^A-z0-9_?])@([A-z0-9_]+)"
   picRegex = re"pic.twitter.com/[^ ]+"
   cardRegex = re"(https?://)?cards.twitter.com/[^ ]+"
   ellipsisRegex = re" ?…"
@@ -55,6 +55,7 @@ proc linkifyText*(text: string): string =
   result = result.replace(usernameRegex, reUsernameToLink)
   result = result.replace(re"([^\s\(\n%])<a", "$1 <a")
   result = result.replace(re"</a>\s+([;.,!\)'%]|&apos;)", "</a>$1")
+  result = result.replace(re"^\. <a", ".<a")
 
 proc stripTwitterUrls*(text: string): string =
   result = text