From 59b631f01edcc3e76ea30e3528424617ffdda04a Mon Sep 17 00:00:00 2001 From: Salastil Date: Fri, 15 May 2026 16:03:02 -0400 Subject: [PATCH] Added cashtags and fixed regex error --- src/experimental/parser/user.nim | 6 +++--- src/parserutils.nim | 2 +- src/query.nim | 2 +- src/views/search.nim | 3 ++- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/experimental/parser/user.nim b/src/experimental/parser/user.nim index 8b98e7f..6ebbb3f 100644 --- a/src/experimental/parser/user.nim +++ b/src/experimental/parser/user.nim @@ -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@$2" - htRegex = nre.re"""(*U)(^|[^\w-_.?])([##$])([\w_]*+)(?!|">|#)""" + htRegex = re.re"(^|[^a-zA-Z0-9_-_.?])([##$])([a-zA-Z0-9_]+)" htReplace = "$1$2$3" 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: diff --git a/src/parserutils.nim b/src/parserutils.nim index 8d6ea2e..097dbff 100644 --- a/src/parserutils.nim +++ b/src/parserutils.nim @@ -16,7 +16,7 @@ let unRegex = re"(^|[^A-z0-9-_./?])@([A-z0-9_]{1,15})" unReplace = "$1@$2" - htRegex = re"(^|[^\w-_./?])([#$]|#)([\w_]+)" + htRegex = re"(^|[^a-zA-Z0-9_-_.?])([#$]|#)([a-zA-Z0-9_]+)" htReplace = "$1$2$3" type diff --git a/src/query.nim b/src/query.nim index 38fe6f4..9decd23 100644 --- a/src/query.nim +++ b/src/query.nim @@ -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" diff --git a/src/views/search.nim b/src/views/search.nim index c79f3fe..737eeb4 100644 --- a/src/views/search.nim +++ b/src/views/search.nim @@ -15,7 +15,8 @@ const toggles = { "links": "Links", "images": "Images", "quote": "Quotes", - "spaces": "Spaces" + "spaces": "Spaces", + "cashtags": "Cashtags" }.toOrderedTable proc renderSearch*(): VNode =