Slugify a title

Turn any title into a lowercase, URL-safe slug.

python-slugify.py
import re
import unicodedata


def slugify(text: str) -> str:
    text = unicodedata.normalize("NFKD", text).encode("ascii", "ignore").decode()
    text = re.sub(r"[^a-zA-Z0-9]+", "-", text).strip("-").lower()
    return text or "item"


print(slugify("Café & Bakery: Summer Menu!"))   # cafe-bakery-summer-menu