"""Slug generation for artists, tags, and paths.""" import re import unicodedata _SLUG_RE = re.compile(r"[^a-z0-9]+") def slugify(value: str) -> str: """Lowercase ASCII slug. Empty input becomes 'untitled'. Examples: slugify("Bob Ross") -> "bob-ross" slugify("hello, world!") -> "hello-world" slugify("naïve café") -> "naive-cafe" """ if not value: return "untitled" normalized = unicodedata.normalize("NFKD", value).encode("ascii", "ignore").decode() normalized = normalized.lower() slug = _SLUG_RE.sub("-", normalized).strip("-") return slug or "untitled"