From fb342cfb5488d3e6d1c0c13d5454b6fb3c2a6dbf Mon Sep 17 00:00:00 2001
From: Andrew Godwin
Date: Mon, 28 Nov 2022 22:34:14 -0700
Subject: Fix hashtagging of HTML entities
---
activities/models/hashtag.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'activities/models')
diff --git a/activities/models/hashtag.py b/activities/models/hashtag.py
index 7085b15..9cfb21d 100644
--- a/activities/models/hashtag.py
+++ b/activities/models/hashtag.py
@@ -123,7 +123,7 @@ class Hashtag(StatorModel):
delete = "{edit}delete/"
timeline = "/tags/{self.hashtag}/"
- hashtag_regex = re.compile(r"((?:\B#)([a-zA-Z0-9(_)]{1,}\b))")
+ hashtag_regex = re.compile(r"\B#([a-zA-Z0-9(_)]+\b)(?!;)")
def save(self, *args, **kwargs):
self.hashtag = self.hashtag.lstrip("#")
@@ -182,7 +182,7 @@ class Hashtag(StatorModel):
@classmethod
def linkify_hashtags(cls, content) -> str:
def replacer(match):
- hashtag = match.group()
- return f'{hashtag}'
+ hashtag = match.group(1)
+ return f'#{hashtag}'
return mark_safe(Hashtag.hashtag_regex.sub(replacer, content))
--
cgit v1.2.3