Toot-Mastodon-CLI-TUI-clien.../toot/tui/utils.py

11 lines
211 B
Python
Raw Normal View History

2019-08-24 14:14:46 +02:00
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)
]