mirror of
http://git.carcosa.net/jmcbray/brutaldon.git
synced 2024-11-23 07:13:52 -05:00
Fix mentions regex, add tags fixup
This commit is contained in:
parent
d80e049bb0
commit
59b149eede
@ -766,10 +766,17 @@ def redraft(request, id):
|
|||||||
toot_content = re.sub("(^\n)|(\n$)", "", re.sub("\n\n", "\n", toot_content))
|
toot_content = re.sub("(^\n)|(\n$)", "", re.sub("\n\n", "\n", toot_content))
|
||||||
# Fix up references
|
# Fix up references
|
||||||
for mention in toot.mentions:
|
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(
|
toot_content = menchie_re.sub(
|
||||||
" @" + mention.acct + " ", toot_content, count=1
|
" @" + 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(
|
form = PostForm(
|
||||||
{
|
{
|
||||||
"status": toot_content.strip(),
|
"status": toot_content.strip(),
|
||||||
|
Loading…
Reference in New Issue
Block a user