Regex fixes, nre is not compiling

This commit is contained in:
Salastil
2026-05-15 17:05:46 -04:00
parent a78d4655cd
commit 85a03a575e
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -1,4 +1,4 @@
import std/[algorithm, unicode, re, strutils, strformat, options, nre]
import std/[algorithm, unicode, re, strutils, strformat, options]
import jsony
import utils, slices
import ../types/user as userType
@@ -8,7 +8,7 @@ let
unRegex = re.re"(^|[^A-z0-9-_./?])@([A-z0-9_]{1,15})"
unReplace = "$1<a href=\"/$2\">@$2</a>"
htRegex = nre.re"""(*U)(^|[^\w-_.?])([#$])([\w_]*+)(?!</a>|">|#)"""
htRegex = re.re"(^|[^a-zA-Z0-9_-_.?])([#$])([a-zA-Z0-9_]+)"
htReplace = "$1<a href=\"/search?f=tweets&q=%23$3\">$2$3</a>"
proc expandUserEntities(user: var User; raw: RawUser) =
@@ -29,7 +29,7 @@ proc expandUserEntities(user: var User; raw: RawUser) =
user.bio = orig.replacedWith(replacements, 0 .. orig.len)
.replacef(unRegex, unReplace)
.replace(htRegex, htReplace)
.replacef(htRegex, htReplace)
proc getBanner(user: RawUser): string =
if user.profileBannerUrl.len > 0:
+1 -1
View File
@@ -16,7 +16,7 @@ let
unRegex = re"(^|[^A-z0-9-_./?])@([A-z0-9_]{1,15})"
unReplace = "$1<a href=\"/$2\">@$2</a>"
htRegex = re"(^|[^\w-_./?])([#$]|)([\w_]+)"
htRegex = re"(^|[^a-zA-Z0-9_-_.?])([#$]|)([a-zA-Z0-9_]+)"
htReplace = "$1<a href=\"/search?f=tweets&q=%23$3\">$2$3</a>"
type