mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-08-20 00:54:38 +00:00
9 lines
214 B
Python
9 lines
214 B
Python
|
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("-_")
|