mirror of
https://github.com/ihabunek/toot
synced 2024-12-24 08:00:39 +01:00
11 lines
211 B
Python
11 lines
211 B
Python
import re
|
|
|
|
HASHTAG_PATTERN = re.compile(r'(?<!\w)(#\w+)\b')
|
|
|
|
|
|
def highlight_hashtags(line):
|
|
return [
|
|
("hashtag", p) if p.startswith("#") else p
|
|
for p in re.split(HASHTAG_PATTERN, line)
|
|
]
|