mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-11-10 00:34:28 +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("-_")
|