From 59b149eede438f1e99cdd331d2d4d220fdaabcc7 Mon Sep 17 00:00:00 2001 From: Jason McBrayer Date: Wed, 16 Oct 2024 17:47:09 -0400 Subject: [PATCH] Fix mentions regex, add tags fixup --- brutaldon/views.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/brutaldon/views.py b/brutaldon/views.py index 2608ab8..dd0b5c2 100644 --- a/brutaldon/views.py +++ b/brutaldon/views.py @@ -766,10 +766,17 @@ def redraft(request, id): toot_content = re.sub("(^\n)|(\n$)", "", re.sub("\n\n", "\n", toot_content)) # Fix up references for mention in toot.mentions: - menchie_re = re.compile(r"\s?@\s" + mention.acct + r"\s", re.I) + menchie_re = re.compile(r"@\s" + mention.acct + r"\b", re.I) toot_content = menchie_re.sub( " @" + mention.acct + " ", toot_content, count=1 ) + # And tags + for tag in toot.tags: + tag_re = re.compile(r"#\s" + tag.name +r"\b", re.I) + toot_content = tag_re.sub( + " #" + tag.name + " ", toot_content, count=1 + ) + form = PostForm( { "status": toot_content.strip(),