Fix hashtag extraction
This commit is contained in:
parent
17107618a0
commit
8139ccffdb
|
@ -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 New Issue