Generate a URL-Safe Slug from Text in Larzscript
Turn an arbitrary title into a clean, URL-safe slug - accented characters transliterated, not just stripped.
slugify.slug() lowercases, collapses non-alphanumeric runs into a separator and trims the edges; unique_slug() appends -2/-3/... until the result isn't already taken.
larzscript pkg install slugify
Code
import "slugify" as slugify
print(slugify.slug("What Is Larzscript? A Guide"))
print(slugify.slug("café résumé"))
print(slugify.unique_slug("Hello", ["hello", "hello-2"]))Output
what-is-larzscript-a-guide cafe-resume hello-3
Related
larzslugTurn text into a clean URL slug, accented Latin transliterated to ASCII→Build a CLI Tool with Subcommands in LarzscriptBuild a real command-line tool with named subcommands and auto-generated help, the shape every larzscript-* showcase app in this ecosystem uses.→Parse Command-Line Arguments in LarzscriptParse --flag=value pairs and positional arguments out of argv, without a full CLI framework.→Read a File Line by Line in LarzscriptRead a text file's contents and split it into lines - the everyday first step of any script that processes a file.→