Expand description
Text utilities — slugify, html_escape, truncate. Text utilities — slug generation, HTML escaping, truncation.
Small zero-dep helpers for the common bits of text-handling boilerplate every web app needs.
Functions§
- html_
escape - Escape a string for safe insertion into HTML element content or double-quoted HTML attributes.
- slugify
- Convert a string into a URL-safe slug.
- slugify_
unicode - Like
slugifybut preserves Unicode letters/digits (lowercased). Useful when your URL infrastructure handles UTF-8 paths. - truncate
- Truncate
sto at mostmax_charscharacters. If truncation happens, appendsuffix(typically"…"or"..."). - unique_
slug - Generate a unique slug by appending
-2,-3, … untilis_takenreturns false. Useful for URL slugs where the naturalslugify(title)might collide with an existing row. - unique_
slug_ async - Async variant of
unique_slugfor DB-backed uniqueness checks.