Adjust ActivityPub hashtag delinkifier for markdown tag links

Since we now convert HTML to Markdown.
mentions
Jason Robinson 2019-08-29 23:35:32 +03:00
rodzic 1070831b2d
commit d85126d605
1 zmienionych plików z 2 dodań i 2 usunięć

Wyświetl plik

@ -41,13 +41,13 @@ class ActivitypubEntityMixin(BaseEntity):
class CleanContentMixin(RawContentMixin): class CleanContentMixin(RawContentMixin):
def post_receive(self) -> None: def post_receive(self) -> None:
""" """
Make linkified Mastodon tags normal tags. Make linkified tags normal tags.
""" """
def cleaner(match): def cleaner(match):
return f"#{match.groups()[0]}" return f"#{match.groups()[0]}"
self.raw_content = re.sub( self.raw_content = re.sub(
r'<a href=\"[^\"]*\" class=\"mention hashtag\" rel=\"tag\">#<span>([a-zA-Z0-9-_]+)</span></a>', r'\[#([\w\-_]+)\]\(http?s://.+\)',
cleaner, cleaner,
self.raw_content, self.raw_content,
re.MULTILINE, re.MULTILINE,