1
0

Added cashtags and fixed regex error

This commit is contained in:
Salastil
2026-05-15 16:03:02 -04:00
parent 74f5ff8acc
commit 59b631f01e
4 changed files with 7 additions and 6 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
+1 -1
View File
@@ -8,7 +8,7 @@ const
"media", "images", "twimg", "videos",
"native_video", "consumer_video", "spaces",
"links", "news", "quote", "mentions",
"replies", "retweets", "nativeretweets"
"replies", "retweets", "nativeretweets", "cashtags"
]
emptyQuery* = "include:nativeretweets"
+2 -1
View File
@@ -15,7 +15,8 @@ const toggles = {
"links": "Links",
"images": "Images",
"quote": "Quotes",
"spaces": "Spaces"
"spaces": "Spaces",
"cashtags": "Cashtags"
}.toOrderedTable
proc renderSearch*(): VNode =