mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-21 23:01:00 +00:00
Fix hashtag extraction
This commit is contained in:
parent
17107618a0
commit
8139ccffdb
2 changed files with 4 additions and 2 deletions
|
@ -176,7 +176,7 @@ class Hashtag(StatorModel):
|
|||
leading '#'.
|
||||
"""
|
||||
hashtag_hits = cls.hashtag_regex.findall(strip_html(content))
|
||||
hashtags = sorted({tag[1].lower() for tag in hashtag_hits})
|
||||
hashtags = sorted({tag.lower() for tag in hashtag_hits})
|
||||
return list(hashtags)
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -9,11 +9,13 @@ def test_hashtag_from_content():
|
|||
"with",
|
||||
]
|
||||
assert Hashtag.hashtags_from_content("#hashtag.") == ["hashtag"]
|
||||
assert Hashtag.hashtags_from_content("More text\n#one # two ##three #hashtag;") == [
|
||||
assert Hashtag.hashtags_from_content("More text\n#one # two ##three #hashtag!") == [
|
||||
"hashtag",
|
||||
"one",
|
||||
"three",
|
||||
]
|
||||
assert Hashtag.hashtags_from_content("my #html loves   entities") == ["html"]
|
||||
assert Hashtag.hashtags_from_content("<span class='hash'>#</span>tag") == ["tag"]
|
||||
|
||||
|
||||
def test_linkify_hashtag():
|
||||
|
|
Loading…
Reference in a new issue