summaryrefslogtreecommitdiffstats
path: root/activities/models
diff options
context:
space:
mode:
authorAndrew Godwin2022-11-28 22:34:14 -0700
committerAndrew Godwin2022-11-28 22:34:14 -0700
commitfb342cfb5488d3e6d1c0c13d5454b6fb3c2a6dbf (patch)
tree244b2460738108f4e3b7bd98f64ac26f04fa43bf /activities/models
parent4420507f62bffd38ed9e8ce31a11fa002756143d (diff)
downloadtakahe-fb342cfb5488d3e6d1c0c13d5454b6fb3c2a6dbf.tar.gz
takahe-fb342cfb5488d3e6d1c0c13d5454b6fb3c2a6dbf.tar.bz2
takahe-fb342cfb5488d3e6d1c0c13d5454b6fb3c2a6dbf.zip
Fix hashtagging of HTML entities
Diffstat (limited to 'activities/models')
-rw-r--r--activities/models/hashtag.py6
1 files changed, 3 insertions, 3 deletions
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'<a class="hashtag" href="/tags/{hashtag.lstrip("#").lower()}/">{hashtag}</a>'
+ hashtag = match.group(1)
+ return f'<a class="hashtag" href="/tags/{hashtag.lower()}/">#{hashtag}</a>'
return mark_safe(Hashtag.hashtag_regex.sub(replacer, content))