1
0
Fork 1
mirror of https://git.sr.ht/~tsileo/microblog.pub synced 2025-01-13 00:24:27 +00:00
microblog.pub/app/utils/text.py

9 lines
214 B
Python
Raw Normal View History

2022-10-30 16:51:57 +00:00
import re
import unicodedata
def slugify(text: str) -> str:
value = unicodedata.normalize("NFKC", text)
value = re.sub(r"[^\w\s-]", "", value.lower())
return re.sub(r"[-\s]+", "-", value).strip("-_")